prompt: You will be provided with a partial code base and an issue statement explaining a problem to resolve.
  <issue>
  Load STL files into vispy
  Hi there, I think  I found a bug in vispy/vispy/io/mesh.py  in col 42:
  mesh = load_stl(fname)
  when I try to import a  *.stl file by read_mesh(fname), an error occured like this: 
   File "D:\Python3.5\lib\site-packages\vispy\io\mesh.py", line 43, in read_mesh
      mesh = load_stl(fname)
    File "D:\Python3.5\lib\site-packages\vispy\io\stl.py", line 43, in load_stl
      file_pos = file_obj.tell()
  AttributeError: 'str' object has no attribute 'tell'
  by change col42 into :mesh = trimesh.load(fname), problem soved!
  
  
  </issue>
  <code>
  [start of vispy/io/mesh.py]
  1 # -*- coding: utf-8 -*-
  2 # Copyright (c) Vispy Development Team. All Rights Reserved.
  3 # Distributed under the (new) BSD License. See LICENSE.txt for more info.
  4 
  5 """ Reading and writing of data like images and meshes.
  6 """
  7 
  8 from os import path as op
  9 
  10 from .wavefront import WavefrontReader, WavefrontWriter
  11 from .stl import load_stl
  12 
  13 
  14 def read_mesh(fname):
  15     """Read mesh data from file.
  16 
  17     Parameters
  18     ----------
  19     fname : str
  20         File name to read. Format will be inferred from the filename.
  21         Currently only '.obj' and '.obj.gz' are supported.
  22 
  23     Returns
  24     -------
  25     vertices : array
  26         Vertices.
  27     faces : array | None
  28         Triangle face definitions.
  29     normals : array
  30         Normals for the mesh.
  31     texcoords : array | None
  32         Texture coordinates.
  33     """
  34     # Check format
  35     fmt = op.splitext(fname)[1].lower()
  36     if fmt == '.gz':
  37         fmt = op.splitext(op.splitext(fname)[0])[1].lower()
  38 
  39     if fmt in ('.obj'):
  40         return WavefrontReader.read(fname)
  41     elif fmt in ('.stl'):
  42         mesh = load_stl(fname)
  43         vertices = mesh.vertices
  44         faces = mesh.faces
  45         normals = mesh.face_normals
  46         texcoords = None
  47         return vertices, faces, normals, texcoords
  48     elif not format:
  49         raise ValueError('read_mesh needs could not determine format.')
  50     else:
  51         raise ValueError('read_mesh does not understand format %s.' % fmt)
  52 
  53 
  54 def write_mesh(fname, vertices, faces, normals, texcoords, name='',
  55                format='obj', overwrite=False, reshape_faces=True):
  56     """ Write mesh data to file.
  57 
  58     Parameters
  59     ----------
  60     fname : str
  61         Filename to write. Must end with ".obj" or ".gz".
  62     vertices : array
  63         Vertices.
  64     faces : array | None
  65         Triangle face definitions.
  66     normals : array
  67         Normals for the mesh.
  68     texcoords : array | None
  69         Texture coordinates.
  70     name : str
  71         Name of the object.
  72     format : str
  73         Currently only "obj" is supported.
  74     overwrite : bool
  75         If the file exists, overwrite it.
  76     reshape_faces : bool
  77         Reshape the `faces` array to (Nf, 3). Set to `False`
  78         if you need to write a mesh with non triangular faces.
  79     """
  80     # Check file
  81     if op.isfile(fname) and not overwrite:
  82         raise IOError('file "%s" exists, use overwrite=True' % fname)
  83 
  84     # Check format
  85     if format not in ('obj'):
  86         raise ValueError('Only "obj" format writing currently supported')
  87     WavefrontWriter.write(fname, vertices, faces,
  88                           normals, texcoords, name, reshape_faces)
  89
  [end of vispy/io/mesh.py]
  </code>
  
  I need you to solve this issue by generating a single patch file that I can apply directly to this repository using git apply. Please respond with a single patch file in the following format.
  <patch>
  diff --git a/file.py b/file.py
  --- a/file.py
  +++ b/file.py
  @@ -1,27 +1,35 @@
   def euclidean(a, b):
  -    while b:
  -        a, b = b, a % b
  -    return a
  +    if b == 0:
  +        return a
  +    return euclidean(b, a % b)
   
   
   def bresenham(x0, y0, x1, y1):
       points = []
       dx = abs(x1 - x0)
       dy = abs(y1 - y0)
  -    sx = 1 if x0 < x1 else -1
  -    sy = 1 if y0 < y1 else -1
  -    err = dx - dy
  +    x, y = x0, y0
  +    sx = -1 if x0 > x1 else 1
  +    sy = -1 if y0 > y1 else 1
   
  -    while True:
  -        points.append((x0, y0))
  -        if x0 == x1 and y0 == y1:
  -            break
  -        e2 = 2 * err
  -        if e2 > -dy:
  -            err -= dy
  -            x0 += sx
  -        if e2 < dx:
  -            err += dx
  -            y0 += sy
  +    if dx > dy:
  +        err = dx / 2.0
  +        while x != x1:
  +            points.append((x, y))
  +            err -= dy
  +            if err < 0:
  +                y += sy
  +                err += dx
  +            x += sx
  +    else:
  +        err = dy / 2.0
  +        while y != y1:
  +            points.append((x, y))
  +            err -= dx
  +            if err < 0:
  +                x += sx
  +                err += dy
  +            y += sy
  +
  +    points.append((x, y))
       return points
  
  </patch>
golden_diff: diff --git a/vispy/io/mesh.py b/vispy/io/mesh.py
  --- a/vispy/io/mesh.py
  +++ b/vispy/io/mesh.py
  @@ -39,10 +39,11 @@
       if fmt in ('.obj'):
           return WavefrontReader.read(fname)
       elif fmt in ('.stl'):
  -        mesh = load_stl(fname)
  -        vertices = mesh.vertices
  -        faces = mesh.faces
  -        normals = mesh.face_normals
  +        file_obj = open(fname, mode='rb')
  +        mesh = load_stl(file_obj)
  +        vertices = mesh['vertices']
  +        faces = mesh['faces']
  +        normals = mesh['face_normals']
           texcoords = None
           return vertices, faces, normals, texcoords
       elif not format:
  
verification_info: {"golden_diff": "diff --git a/vispy/io/mesh.py b/vispy/io/mesh.py\n--- a/vispy/io/mesh.py\n+++ b/vispy/io/mesh.py\n@@ -39,10 +39,11 @@\n     if fmt in ('.obj'):\n         return WavefrontReader.read(fname)\n     elif fmt in ('.stl'):\n-        mesh = load_stl(fname)\n-        vertices = mesh.vertices\n-        faces = mesh.faces\n-        normals = mesh.face_normals\n+        file_obj = open(fname, mode='rb')\n+        mesh = load_stl(file_obj)\n+        vertices = mesh['vertices']\n+        faces = mesh['faces']\n+        normals = mesh['face_normals']\n         texcoords = None\n         return vertices, faces, normals, texcoords\n     elif not format:\n", "issue": "Load STL files into vispy\nHi there, I think  I found a bug in vispy/vispy/io/mesh.py  in col 42:\r\nmesh = load_stl(fname)\r\nwhen I try to import a  *.stl file by read_mesh(fname), an error occured like this: \r\n File \"D:\\Python3.5\\lib\\site-packages\\vispy\\io\\mesh.py\", line 43, in read_mesh\r\n    mesh = load_stl(fname)\r\n  File \"D:\\Python3.5\\lib\\site-packages\\vispy\\io\\stl.py\", line 43, in load_stl\r\n    file_pos = file_obj.tell()\r\nAttributeError: 'str' object has no attribute 'tell'\r\nby change col42 into :mesh = trimesh.load(fname), problem soved!\r\n\n", "before_files": [{"content": "# -*- coding: utf-8 -*-\n# Copyright (c) Vispy Development Team. All Rights Reserved.\n# Distributed under the (new) BSD License. See LICENSE.txt for more info.\n\n\"\"\" Reading and writing of data like images and meshes.\n\"\"\"\n\nfrom os import path as op\n\nfrom .wavefront import WavefrontReader, WavefrontWriter\nfrom .stl import load_stl\n\n\ndef read_mesh(fname):\n    \"\"\"Read mesh data from file.\n\n    Parameters\n    ----------\n    fname : str\n        File name to read. Format will be inferred from the filename.\n        Currently only '.obj' and '.obj.gz' are supported.\n\n    Returns\n    -------\n    vertices : array\n        Vertices.\n    faces : array | None\n        Triangle face definitions.\n    normals : array\n        Normals for the mesh.\n    texcoords : array | None\n        Texture coordinates.\n    \"\"\"\n    # Check format\n    fmt = op.splitext(fname)[1].lower()\n    if fmt == '.gz':\n        fmt = op.splitext(op.splitext(fname)[0])[1].lower()\n\n    if fmt in ('.obj'):\n        return WavefrontReader.read(fname)\n    elif fmt in ('.stl'):\n        mesh = load_stl(fname)\n        vertices = mesh.vertices\n        faces = mesh.faces\n        normals = mesh.face_normals\n        texcoords = None\n        return vertices, faces, normals, texcoords\n    elif not format:\n        raise ValueError('read_mesh needs could not determine format.')\n    else:\n        raise ValueError('read_mesh does not understand format %s.' % fmt)\n\n\ndef write_mesh(fname, vertices, faces, normals, texcoords, name='',\n               format='obj', overwrite=False, reshape_faces=True):\n    \"\"\" Write mesh data to file.\n\n    Parameters\n    ----------\n    fname : str\n        Filename to write. Must end with \".obj\" or \".gz\".\n    vertices : array\n        Vertices.\n    faces : array | None\n        Triangle face definitions.\n    normals : array\n        Normals for the mesh.\n    texcoords : array | None\n        Texture coordinates.\n    name : str\n        Name of the object.\n    format : str\n        Currently only \"obj\" is supported.\n    overwrite : bool\n        If the file exists, overwrite it.\n    reshape_faces : bool\n        Reshape the `faces` array to (Nf, 3). Set to `False`\n        if you need to write a mesh with non triangular faces.\n    \"\"\"\n    # Check file\n    if op.isfile(fname) and not overwrite:\n        raise IOError('file \"%s\" exists, use overwrite=True' % fname)\n\n    # Check format\n    if format not in ('obj'):\n        raise ValueError('Only \"obj\" format writing currently supported')\n    WavefrontWriter.write(fname, vertices, faces,\n                          normals, texcoords, name, reshape_faces)\n", "path": "vispy/io/mesh.py"}]}