Add more data to error message
This changes the error message from
offset is neither short nor long
to
offset is neither short nor long: Tag ID 273 Field Type 16 Field Size 8 Count 1
Could you give an example of how to trigger this error?
With #8317, test_bigtiff() in test_file_tiff.py triggers this error if del im.tag_v2[273] is removed from the test.
Would it not be more consistent with the rest of TiffImagePlugin to log the extra information instead?
https://github.com/python-pillow/Pillow/blob/eeb3d04843996117457af2481ca242f97e646b5e/src/PIL/TiffImagePlugin.py#L1429-L1435
It might. Logging is only used in five files in Pillow though (Image, PcxImagePlugin, PngImagePlugin, TiffImagePlugin, helper).
With #8317,
test_bigtiff()intest_file_tiff.pytriggers this error ifdel im.tag_v2[273]is removed from the test.
Just a note: this specific example stopped triggering the error after #8417 added support for LONG8.
I've created https://github.com/python-pillow/Pillow/pull/8568 as an alternative to this, using my suggestion of logging.
#8568 has been merged instead.