Skip to content

rect: raise a clear error for a NaN or infinite corner_radius - #2128

Merged
andersonhc merged 2 commits into
py-pdf:masterfrom
RavSinghChandan:round-corner-radius-finite
Nov 7, 2026
Merged

andersonhc merged 2 commits into
py-pdf:masterfrom
RavSinghChandan:round-corner-radius-finite

Conversation

@RavSinghChandan

Copy link
Copy Markdown

pdf.rect(10, 10, 20, 20, round_corners=True, corner_radius=float("nan")) raised ValueError: cannot convert float NaN to integer. With corner_radius=float("inf") it wrote inf and nan nan nan nan nan nan c into the page, which are not valid PDF numbers.

Both now raise ValueError: corner_radius must be a finite number: .... A rectangle without round_corners is unchanged.

  • A unit test is covering the code added / modified by this PR
  • A mention of the change is present in CHANGELOG.md
  • This PR is ready to be merged

@andersonhc
andersonhc merged commit 06af55b into py-pdf:master Nov 7, 2026
23 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.

2 participants