Skip to content

regular_polygon: raise a clear error for numSides below 1 - #2069

Merged
andersonhc merged 1 commit into
py-pdf:masterfrom
RavSinghChandan:regular-polygon-sides-validation
Oct 28, 2026
Merged

andersonhc merged 1 commit into
py-pdf:masterfrom
RavSinghChandan:regular-polygon-sides-validation

Conversation

@RavSinghChandan

Copy link
Copy Markdown

FPDF.regular_polygon() with numSides=0 or a negative value computed no vertices and passed an empty list to polygon(), which wrote a path with no points: the content stream got a bare h S, closing a path that was never started (there is no m before it), and no error was raised.

It now raises ValueError: 'numSides' parameter must be equal or greater than 1: 0, using the same wording as insert_toc_placeholder() for pages and #2066 for star(). Added test_regular_polygon_invalid_num_sides in test/shapes/test_regular_polygon.py, and a CHANGELOG entry.

@andersonhc
andersonhc merged commit d4fab24 into py-pdf:master Oct 28, 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