Skip to content

Improve error messages from C#9784

Open
akx wants to merge 5 commits into
python-pillow:mainfrom
akx:wrong-mode-exc
Open

Improve error messages from C#9784
akx wants to merge 5 commits into
python-pillow:mainfrom
akx:wrong-mode-exc

Conversation

@akx

@akx akx commented Jul 9, 2026

Copy link
Copy Markdown
Contributor

Inspired by #6667 (comment)

  • New internal exception type NotSupportedError for operations that are currently not supported; derives from both ValueError and NotImplementedError for backward compatibility.
    • Deriving from NotImplementedError allows for try-excepting in tests, so we can do better than (e.g.) Tests.test_image_filter.test_sanity where the test just quietly does nothing when a mode combo is not (yet, or currently) supported. (This wasn't wired up here yet.)
  • The internal 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! ✨
  • Image nullness checks used to occasionally do ModeErrors, occasionally ValueErrors; now they're all ValueError.

@akx akx marked this pull request as ready for review July 9, 2026 11:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant