mirror of
https://github.com/python-pillow/Pillow.git
synced 2025-03-14 15:22:13 +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")
|
||||
with pytest.raises(SystemError):
|
||||
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)
|
||||
if errcode:
|
||||
break
|
||||
if _fp:
|
||||
try:
|
||||
os.close(_fp)
|
||||
except OSError:
|
||||
pass
|
||||
if errcode < 0:
|
||||
msg = f"encoder error {errcode} when writing image file"
|
||||
raise OSError(msg)
|
||||
|
|
Loading…
Reference in New Issue
Block a user