From 671d7808e2dd60b9ebdd0ceddeb6d94d1a744e73 Mon Sep 17 00:00:00 2001 From: Yay295 Date: Sun, 18 Aug 2024 20:38:41 -0500 Subject: [PATCH] add more data to error message --- src/PIL/TiffImagePlugin.py | 24 +++++++++++++++++------- 1 file changed, 17 insertions(+), 7 deletions(-) diff --git a/src/PIL/TiffImagePlugin.py b/src/PIL/TiffImagePlugin.py index ff5a6f9e9..66eba84f2 100644 --- a/src/PIL/TiffImagePlugin.py +++ b/src/PIL/TiffImagePlugin.py @@ -2188,13 +2188,23 @@ class AppendingTiffWriter(io.BytesIO): if tag in self.Tags: cur_pos = self.f.tell() - if is_local: - self._fixOffsets(count, field_size) - self.f.seek(cur_pos + 4) - else: - self.f.seek(offset) - self._fixOffsets(count, field_size) - self.f.seek(cur_pos) + try: + if is_local: + self._fixOffsets(count, field_size) + self.f.seek(cur_pos + 4) + else: + self.f.seek(offset) + self._fixOffsets(count, field_size) + self.f.seek(cur_pos) + except RuntimeError as e: + msg = ( + f"{e}:" + f" Tag ID {tag}" + f" Field Type {field_type}" + f" Field Size {field_size}" + f" Count {count}" + ) + raise RuntimeError(msg) from e elif is_local: # skip the locally stored value that is not an offset