`ImageDraw.arc()` segfaults on a tuple subclass whose `__len__` is too large

Open
#10,358 2 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

@Parsiffall1 is already working on this.

Since Oct 29, 2026.

  • #10359 by @Parsiffall1 — open

Assessment

Difficulty
4/5
Estimated time
1-2 days
Newbie friendliness
58/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Active
Tech stack
python
Domain
backend

Research direction

Start by tracing ImageDraw.arc() from its Python entry point into the coordinate handling used for tuple subclasses; compare that path with the list subclass behavior described in the report. Reproduce with the supplied MyTuple example under Python 3.13.5. Done means the tuple input raises a safe exception instead of crashing the interpreter.

Written by the indexing model from the issue text.

Description

Summary

Passing coordinates as a tuple subclass whose __len__ reports more items than the tuple holds crashes the interpreter.

The same input as a list subclass raises a clean IndexError: list index out of range, so only the tuple path is affected.

Environment

  • Pillow 13.0.0
  • Python 3.13.5

Reproducer

from PIL import Image, ImageDraw


class MyTuple(tuple):
    def __len__(self):
        return 10


ImageDraw.Draw(Image.new("RGB", (50, 50))).arc(MyTuple((0.0,)), 0, 90)
Segmentation fault (core dumped)
Dominant language
Python
Stars
13.9k
Forks
2.6k
Avg merge
1d 2h
Merged PRs (30d)
176

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from python-pillow/Pillow

All issues in python-pillow/Pillow

Similar issues

More Python issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.