mirror of
https://github.com/python-pillow/Pillow.git
synced 2024-12-25 17:36:18 +03:00
Close exclusive fp before discarding
This commit is contained in:
parent
e3d5494a51
commit
b637b5f7a2
|
@ -17,7 +17,10 @@ class TestFileIcns(PillowTestCase):
|
||||||
# Loading this icon by default should result in the largest size
|
# Loading this icon by default should result in the largest size
|
||||||
# (512x512@2x) being loaded
|
# (512x512@2x) being loaded
|
||||||
im = Image.open(TEST_FILE)
|
im = Image.open(TEST_FILE)
|
||||||
im.load()
|
|
||||||
|
# Assert that there is no unclosed file warning
|
||||||
|
self.assert_warning(None, im.load)
|
||||||
|
|
||||||
self.assertEqual(im.mode, "RGBA")
|
self.assertEqual(im.mode, "RGBA")
|
||||||
self.assertEqual(im.size, (1024, 1024))
|
self.assertEqual(im.size, (1024, 1024))
|
||||||
self.assertEqual(im.format, "ICNS")
|
self.assertEqual(im.format, "ICNS")
|
||||||
|
|
|
@ -327,7 +327,9 @@ class TestFilePng(PillowTestCase):
|
||||||
# Check open/load/verify exception (@PIL150)
|
# Check open/load/verify exception (@PIL150)
|
||||||
|
|
||||||
im = Image.open(TEST_PNG_FILE)
|
im = Image.open(TEST_PNG_FILE)
|
||||||
im.verify()
|
|
||||||
|
# Assert that there is no unclosed file warning
|
||||||
|
self.assert_warning(None, im.verify)
|
||||||
|
|
||||||
im = Image.open(TEST_PNG_FILE)
|
im = Image.open(TEST_PNG_FILE)
|
||||||
im.load()
|
im.load()
|
||||||
|
|
|
@ -311,6 +311,8 @@ class IcnsImageFile(ImageFile.ImageFile):
|
||||||
self.im = im.im
|
self.im = im.im
|
||||||
self.mode = im.mode
|
self.mode = im.mode
|
||||||
self.size = im.size
|
self.size = im.size
|
||||||
|
if self._exclusive_fp:
|
||||||
|
self.fp.close()
|
||||||
self.fp = None
|
self.fp = None
|
||||||
self.icns = None
|
self.icns = None
|
||||||
self.tile = ()
|
self.tile = ()
|
||||||
|
|
|
@ -600,6 +600,8 @@ class PngImageFile(ImageFile.ImageFile):
|
||||||
self.png.verify()
|
self.png.verify()
|
||||||
self.png.close()
|
self.png.close()
|
||||||
|
|
||||||
|
if self._exclusive_fp:
|
||||||
|
self.fp.close()
|
||||||
self.fp = None
|
self.fp = None
|
||||||
|
|
||||||
def load_prepare(self):
|
def load_prepare(self):
|
||||||
|
|
Loading…
Reference in New Issue
Block a user