Skip to content

Misleading error message when passing tuple of incorrect data type to ImageDraw methods #5939

Closed

Description

@moritzvonberg

What did you do?

Accidentally passed ('7', '9', '97', '106') to ImageDraw.Draw().rectangle()

for example:

from PIL import Image, ImageDraw

with Image.open('test_screenshots/just letters.png') as image:
    draw = ImageDraw.Draw(image)
    draw.rectangle(('10', '10', '110', '110'))
    image.show()

What did you expect to happen?

An Error to be raised stating that the parameter xy is not a tuple of integers or some other apt description.

What actually happened?

A SystemError is raised with the message: SystemError: new style getargs format but argument is not a tuple despite the input being a tuple (albeit with incorrect contents).

What are your OS, Python and Pillow versions?

  • OS: Windows 10 Build 19042
  • Python: 3.10.0
  • Pillow: 9.0.0

Activity

  1. radarhere commented on Jan 8, 2022

    @radarhere
    Member

    Fair enough. I've created PR #5942 to resolve this, changing the error to ValueError: incorrect coordinate type.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions