mirror of
https://github.com/python-pillow/Pillow.git
synced 2025-01-26 17:24:31 +03:00
close fp if it was opened in ImageFile constructor
This commit is contained in:
parent
88ec0bb52f
commit
091d0c400c
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue
Block a user