mirror of
https://github.com/python-pillow/Pillow.git
synced 2025-08-17 18:54:46 +03:00
Merge 5bab56ca16
into d48dabfd97
This commit is contained in:
commit
af15102bbe
|
@ -1092,10 +1092,6 @@ class TiffImageFile(ImageFile.ImageFile):
|
||||||
|
|
||||||
self.tile = []
|
self.tile = []
|
||||||
self.readonly = 0
|
self.readonly = 0
|
||||||
# libtiff closed the fp in a, we need to close self.fp, if possible
|
|
||||||
if hasattr(self.fp, 'close'):
|
|
||||||
if not self.__next:
|
|
||||||
self.fp.close()
|
|
||||||
self.fp = None # might be shared
|
self.fp = None # might be shared
|
||||||
|
|
||||||
if err < 0:
|
if err < 0:
|
||||||
|
|
|
@ -370,7 +370,8 @@ class TestFileLibTiff(LibTiffTestCase):
|
||||||
fn = im.fp.fileno()
|
fn = im.fp.fileno()
|
||||||
|
|
||||||
os.fstat(fn)
|
os.fstat(fn)
|
||||||
im.load() # this should close it.
|
im.load()
|
||||||
|
im.close() # this should close it.
|
||||||
self.assertRaises(OSError, lambda: os.fstat(fn))
|
self.assertRaises(OSError, lambda: os.fstat(fn))
|
||||||
im = None # this should force even more closed.
|
im = None # this should force even more closed.
|
||||||
self.assertRaises(OSError, lambda: os.fstat(fn))
|
self.assertRaises(OSError, lambda: os.fstat(fn))
|
||||||
|
@ -399,6 +400,19 @@ class TestFileLibTiff(LibTiffTestCase):
|
||||||
|
|
||||||
TiffImagePlugin.READ_LIBTIFF = False
|
TiffImagePlugin.READ_LIBTIFF = False
|
||||||
|
|
||||||
|
def test_multipage_nframes(self):
|
||||||
|
# issue #862
|
||||||
|
TiffImagePlugin.READ_LIBTIFF = True
|
||||||
|
im = Image.open('Tests/images/multipage.tiff')
|
||||||
|
frames = im.n_frames
|
||||||
|
self.assertEqual(frames, 3)
|
||||||
|
for idx in range(frames):
|
||||||
|
im.seek(0)
|
||||||
|
# Should not raise ValueError: I/O operation on closed file
|
||||||
|
im.load()
|
||||||
|
|
||||||
|
TiffImagePlugin.READ_LIBTIFF = False
|
||||||
|
|
||||||
def test__next(self):
|
def test__next(self):
|
||||||
TiffImagePlugin.READ_LIBTIFF = True
|
TiffImagePlugin.READ_LIBTIFF = True
|
||||||
im = Image.open('Tests/images/hopper.tif')
|
im = Image.open('Tests/images/hopper.tif')
|
||||||
|
@ -521,7 +535,7 @@ class TestFileLibTiff(LibTiffTestCase):
|
||||||
except:
|
except:
|
||||||
self.fail("Should not get permission error here")
|
self.fail("Should not get permission error here")
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
|
|
Loading…
Reference in New Issue
Block a user