mirror of
https://github.com/python-pillow/Pillow.git
synced 2024-11-11 04:07:21 +03:00
Merge pull request #6986 from fcarron/fix_libtiff_file_pointer
Close file pointer copy in the libtiff encoder if still open
This commit is contained in:
commit
eda95342ae
|
@ -1065,3 +1065,9 @@ class TestFileLibTiff(LibTiffTestCase):
|
||||||
out = str(tmp_path / "temp.tif")
|
out = str(tmp_path / "temp.tif")
|
||||||
with pytest.raises(SystemError):
|
with pytest.raises(SystemError):
|
||||||
im.save(out, compression=compression)
|
im.save(out, compression=compression)
|
||||||
|
|
||||||
|
def test_save_many_compressed(self, tmp_path):
|
||||||
|
im = hopper()
|
||||||
|
out = str(tmp_path / "temp.tif")
|
||||||
|
for _ in range(10000):
|
||||||
|
im.save(out, compression="jpeg")
|
||||||
|
|
|
@ -1850,6 +1850,11 @@ def _save(im, fp, filename):
|
||||||
fp.write(data)
|
fp.write(data)
|
||||||
if errcode:
|
if errcode:
|
||||||
break
|
break
|
||||||
|
if _fp:
|
||||||
|
try:
|
||||||
|
os.close(_fp)
|
||||||
|
except OSError:
|
||||||
|
pass
|
||||||
if errcode < 0:
|
if errcode < 0:
|
||||||
msg = f"encoder error {errcode} when writing image file"
|
msg = f"encoder error {errcode} when writing image file"
|
||||||
raise OSError(msg)
|
raise OSError(msg)
|
||||||
|
|
Loading…
Reference in New Issue
Block a user