Skip to content

Raise ValueError for invalid autocontrast cutoff tuple lengths - #10603

Merged
radarhere merged 3 commits into
python-pillow:mainfrom
YousefStudio:fix/autocontrast-invalid-cutoff-length
Nov 23, 2026
Merged

radarhere merged 3 commits into
python-pillow:mainfrom
YousefStudio:fix/autocontrast-invalid-cutoff-length

Conversation

@YousefStudio

Copy link
Copy Markdown
Contributor

What does this PR do?

Validate that tuple values passed to ImageOps.autocontrast(cutoff=...) contain exactly two elements.

Invalid tuples now raise a clear ValueError instead of being silently accepted or causing an IndexError.

Scalar cutoff values and valid two-element tuples retain their existing behavior.

Tests

  • Added regression tests for empty, one-element, and three-element tuples.
  • Local smoke tests passed for three invalid and four valid cases against Pillow 12.3.0.
  • Full upstream test suite not run locally.

Fixes #10590.

@radarhere
radarhere force-pushed the fix/autocontrast-invalid-cutoff-length branch from fb4257a to 0560c80 Compare November 23, 2026 12:18
@radarhere
radarhere merged commit 49c59a5 into python-pillow:main Nov 23, 2026
56 checks passed
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.

ImageOps.autocontrast() raises IndexError for a one-element cutoff tuple

2 participants