Pillow
Pillow copied to clipboard
Change the exception type when parsing bad data
Right now PIL/Pillow recommends raising SyntaxError when dealing with bad data. Example in PaletteFile
:
if len(s) > 100:
raise SyntaxError("bad palette file")
It'd be a lot nicer raising a custom exception. Abusing SyntaxError is nasty.
Hi. Thanks for contributing with this suggestion. My only input here is that there are many SyntaxError
exceptions thrown throughout the image plugins, so if done properly, this is actually a bigger change than simply PaletteFile.
I agree, yes.
Each encoder should catch and homogenize potential errors thrown to this more canonical form.
@jleclanche You want to take a whack at this one?
@aclark4life yeah sure, but this is quite the backwards incompatible change. fine with that?
If only we had looked at a list of things to do for a breaking change release
#7425 and #7489 would also like custom exceptions instead of OSError
s.