Skip to content

Return zero from ImagePath compact() if there are no points to remove - #10126

Merged
radarhere merged 1 commit into
python-pillow:mainfrom
radarhere:path_count
Oct 6, 2026
Merged

radarhere merged 1 commit into
python-pillow:mainfrom
radarhere:path_count

Conversation

@radarhere

@radarhere radarhere commented Oct 5, 2026 •

Copy link
Copy Markdown
Member

Creating an ImagePath with zero points, and then calling compact() should return the number of points that were removed in the compacting process.

from PIL import ImagePath
p = ImagePath.Path(0)
print(p.compact())

Instead this gives -1, as it is presumed that is at least 1 point in the path.

for (i = j = 1; i < self->count; i++) {

i = self->count - j;

return Py_BuildValue("i", i); /* number of removed vertices */

Instead, let's return early, saying that zero points were removed.

@radarhere
radarhere merged commit 17a2ad8 into python-pillow:main Oct 6, 2026
58 checks passed
@radarhere
radarhere deleted the path_count branch October 6, 2026 03:08
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.

1 participant