From 5bbbc462403067c42dec782c11920aeecf9206a0 Mon Sep 17 00:00:00 2001 From: Andrew Murray Date: Sat, 1 Feb 2025 01:13:04 +1100 Subject: [PATCH] Fixed exceptions when closing AppendingTiffWriter --- Tests/test_file_tiff.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/Tests/test_file_tiff.py b/Tests/test_file_tiff.py index 67f808b60..af4bae5dc 100644 --- a/Tests/test_file_tiff.py +++ b/Tests/test_file_tiff.py @@ -780,15 +780,17 @@ class TestFileTiff: data = b"II\x2A\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" b = BytesIO(data) with TiffImagePlugin.AppendingTiffWriter(b) as a: + a.seek(-4, os.SEEK_CUR) a.writeLong(2**32 - 1) - assert b.getvalue() == data + b"\xff\xff\xff\xff" + assert b.getvalue() == data[:-4] + b"\xff\xff\xff\xff" def test_appending_tiff_writer_rewritelastshorttolong(self) -> None: data = b"II\x2A\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" b = BytesIO(data) with TiffImagePlugin.AppendingTiffWriter(b) as a: + a.seek(-2, os.SEEK_CUR) a.rewriteLastShortToLong(2**32 - 1) - assert b.getvalue() == data[:-2] + b"\xff\xff\xff\xff" + assert b.getvalue() == data[:-4] + b"\xff\xff\xff\xff" def test_saving_icc_profile(self, tmp_path: Path) -> None: # Tests saving TIFF with icc_profile set.