Skip to content

RadialGradient: raise a clear error for a negative or non-finite radius - #2135

Merged
andersonhc merged 2 commits into
py-pdf:masterfrom
RavSinghChandan:radial-gradient-radius
Nov 10, 2026
Merged

andersonhc merged 2 commits into
py-pdf:masterfrom
RavSinghChandan:radial-gradient-radius

Conversation

@RavSinghChandan

Copy link
Copy Markdown

RadialGradient(30, 30, 0, 50, 50, -5, colors) wrote /Coords [30 30 0 50 50 -5] into the shading, and a NaN radius wrote nan. The PDF specification requires both radii to be zero or more, and shape_radial_gradient() already raises ValueError for a negative r.

RadialGradient now raises ValueError: Gradient circle radius must be zero or a positive number: ... for a negative, NaN or infinite start or end radius. SVG gradients go through shape_radial_gradient() and are 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 67cfabe into py-pdf:master Nov 10, 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