Close the file pointer copy (_fp) in the libtiff encoder if it is still open.

This commit is contained in:
Frédéric Carron 2023-03-03 11:41:37 +01:00
parent 01520de6f7
commit 2299490082

View File

@ -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)