Skip to content

Fix ImagePath coordinate conversion errors - #10287

Open
shivanshjain456 wants to merge 12 commits into
python-pillow:mainfrom
shivanshjain456:fix-path-coordinates-10284
Open

shivanshjain456 wants to merge 12 commits into
python-pillow:mainfrom
shivanshjain456:fix-path-coordinates-10284

Conversation

@shivanshjain456

@shivanshjain456 shivanshjain456 commented Oct 22, 2026 •

Copy link
Copy Markdown

Fixes #10284

Changes proposed in this pull request:

  • Keep ImagePath.Path item assignment tuple-only, while converting unsupported non-tuple input into a normal TypeError rather than leaking SystemError.
  • Check numeric conversions while flattening coordinates and preserve their Python exceptions.
  • Convert Python integers to double precision without narrowing through C long or float.
  • Add regression tests for non-tuple assignment, coordinate-conversion exceptions, and integer precision.

Local validation: editable build succeeded; focused test_imagepath.py and test_imagedraw.py tests passed (302 passed, 1 xfailed); Mypy passed on 303 source files; pre-commit checks passed for both changed test files.

AI disclosure: AI was used for issue research, the initial implementation, regression-test development, local validation, and drafting this description. Maintainer feedback led to retaining tuple-only assignment; the updated behavior and tests were reviewed and validated after that change.

@radarhere radarhere added the 🤖-assisted AI-assisted label Oct 22, 2026
@radarhere

Copy link
Copy Markdown
Member

I don't think there's any need to start accepting path[0] = [1, 2]. I think the issue was merely reporting that there was an unexpected SystemError.

Comment thread Tests/test_imagedraw.py Outdated
def test_line_invalid_coordinate_conversion() -> None:
draw = ImageDraw.Draw(Image.new("RGB", (4, 4)))
with pytest.raises(ValueError, match="cannot convert signaling NaN to float"):
with pytest.raises(ValueError, match="(?i)cannot convert signaling NaN to float"):

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why add (?i)?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I added (?i) after CI showed this Decimal error with an uppercase C on PyPy 3.12 and Python 3.15. Since only the initial letter differed, I’ve narrowed the matcher to [Cc] and applied it to the nested list case too.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

🤖-assisted AI-assisted

Projects

None yet

Development

Successfully merging this pull request may close these issues.

SystemError in ImagePath.Path item assignment and ImageDraw coordinates

2 participants