Skip to content

Commit 78f8317

Browse files
committed
CLN: make sure we close the image file we open
In imread.pil_read the image file never gets explicitly closed. This removes a warning from the tests.
1 parent e0da0b1 commit 78f8317

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

lib/matplotlib/image.py

+3-1
Original file line numberDiff line numberDiff line change
@@ -1260,7 +1260,9 @@ def pilread(fname):
12601260
except ImportError:
12611261
return None
12621262
image = Image.open(fname)
1263-
return pil_to_array(image)
1263+
ret = pil_to_array(image)
1264+
image.close()
1265+
return ret
12641266

12651267
handlers = {'png': _png.read_png, }
12661268
if format is None:

0 commit comments

Comments
 (0)