Pillow icon indicating copy to clipboard operation
Pillow copied to clipboard

Add more data to error message

Open Yay295 opened this issue 1 year ago • 4 comments

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

Yay295 avatar Aug 19 '24 01:08 Yay295

Could you give an example of how to trigger this error?

radarhere avatar Aug 19 '24 07:08 radarhere

With #8317, test_bigtiff() in test_file_tiff.py triggers this error if del im.tag_v2[273] is removed from the test.

Yay295 avatar Aug 19 '24 07:08 Yay295

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

radarhere avatar Aug 19 '24 08:08 radarhere

It might. Logging is only used in five files in Pillow though (Image, PcxImagePlugin, PngImagePlugin, TiffImagePlugin, helper).

Yay295 avatar Aug 19 '24 14:08 Yay295

With #8317, test_bigtiff() in test_file_tiff.py triggers this error if del 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.

radarhere avatar Nov 25 '24 05:11 radarhere

I've created https://github.com/python-pillow/Pillow/pull/8568 as an alternative to this, using my suggestion of logging.

radarhere avatar Nov 26 '24 03:11 radarhere

#8568 has been merged instead.

radarhere avatar Jan 16 '25 21:01 radarhere