Repository navigation
Conversation
fbf0a1d to
5b9e30f
Compare
|
Rebased post #9794. |
92f9165 to
31a972d
Compare
49db676 to
3a45fc5
Compare
Merging this PR will not alter performance1 warning
Comparing Footnotes
|
>>> from PIL import Image, ImagePalette
>>> im = Image.new("L", (1, 1))
>>> im.palette = ImagePalette.ImagePalette()
>>> im.palette.mode = "L"
>>> im.palette.dirty = 1
>>> im.load()
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "PIL/Image.py", line 995, in load
self.im.putpalette(self.palette.mode, mode, arr)
PIL._imaging.NotSupportedError: only modes RGB/RGBA/CMYK supportedI don't like that it's raising an error that resides in >>> Image.open("setup.py")
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "PIL/Image.py", line 3822, in open
raise UnidentifiedImageError(msg)
PIL.UnidentifiedImageError: cannot identify image file 'setup.py' |
If the objection is that it lives in
All of these will effectively make the new exception type a public API, contrary to the idea of it being an internal type (as noted in the PR description). Would you like me to do any of these? |
The fact that my earlier comment raised it from I would prefer a Python declaration, to be consistent with Line 78 in b9a029a |
Internal as in "not reachable from user code". (Unless, well, if you get the C code to raise one, then catch
Alright. Cooking... |
Is this not reaching it from user code?
|
|
|
# Conflicts: # src/libImaging/Point.c
|
Merged |
|
I've created a few PRs based on this, and the only remaining changes are
https://docs.python.org/3/builtins/exceptions.html#NotImplementedError
I don't know if that describes these situations. https://docs.python.org/3/builtins/exceptions.html#ValueError
Is the problem that Pillow hasn't added functionality, or is the problem that the user passed in the wrong image mode, size or other value? I lean towards the latter, as I think the user hasn't followed instructions. @aclark4life could you explain your thinking on |
might be phrased a little narrowly. The Python standard library also extends Whether or not to double-inherit is just a backward compatibility question, as noted. CPython did happily change the above |
Inspired by #6667 (comment)
NotSupportedErrorfor operations that are currently not supported; derives from bothValueErrorandNotImplementedErrorfor backward compatibility.NotImplementedErrorallows for try-excepting in tests, so we can do better than (e.g.)Tests.test_image_filter.test_sanitywhere the test just quietly does nothing when a mode combo is not (yet, or currently) supported. (This wasn't wired up here yet.)ImagingError_*()C APIs now all support an optional message text, and message texts were added where practical. No longer "image has wrong mode" or "images do not match" for everything! ✨