mirror of
https://github.com/python-pillow/Pillow.git
synced 2025-06-02 04:03:33 +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
|
# raise exception if something's wrong. must be called
|
||||||
# directly after open, and closes file when finished.
|
# directly after open, and closes file when finished.
|
||||||
|
if self._exclusive_fp:
|
||||||
|
self.fp.close()
|
||||||
self.fp = None
|
self.fp = None
|
||||||
|
|
||||||
def load(self):
|
def load(self):
|
||||||
|
@ -239,7 +241,9 @@ class ImageFile(Image.Image):
|
||||||
self.tile = []
|
self.tile = []
|
||||||
self.readonly = readonly
|
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:
|
if not self.map and not LOAD_TRUNCATED_IMAGES and err_code < 0:
|
||||||
# still raised if decoder fails to return anything
|
# still raised if decoder fails to return anything
|
||||||
|
|
Loading…
Reference in New Issue
Block a user