Skip to content

Commit

Permalink
close file before
Browse files Browse the repository at this point in the history
  • Loading branch information
François Boulogne committed Feb 16, 2016
1 parent 379a0c4 commit dbcdf6d
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion skimage/io/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@ def file_or_url_context(resource_name):
with tempfile.NamedTemporaryFile(delete=False, suffix=ext) as f:
u = urlopen(resource_name)
f.write(u.read())
yield f.name
# f must be closed before yielding
yield f.name
finally:
os.remove(f.name)
else:
Expand Down

0 comments on commit dbcdf6d

Please sign in to comment.