close fp if it was opened in ImageFile constructor

This commit is contained in:
homm 2016-07-17 06:33:23 +03:00 committed by wiredfool
parent 88ec0bb52f
commit 091d0c400c

View File

@ -120,6 +120,8 @@ class ImageFile(Image.Image):
# raise exception if something's wrong. must be called
# directly after open, and closes file when finished.
if self._exclusive_fp:
self.fp.close()
self.fp = None
def load(self):
@ -239,7 +241,9 @@ class ImageFile(Image.Image):
self.tile = []
self.readonly = readonly
self.fp = None # might be shared
if self._exclusive_fp:
self.fp.close()
self.fp = None
if not self.map and not LOAD_TRUNCATED_IMAGES and err_code < 0:
# still raised if decoder fails to return anything