Pillow icon indicating copy to clipboard operation
Pillow copied to clipboard

Raise a TypeError when Image() is called

Open radarhere opened this issue 2 years ago • 2 comments

Resolves #7455

When running

from PIL import Image
Image.Image()

this PR will raise a TypeError

Traceback (most recent call last):
  File "test.py", line 2, in <module>
    Image.Image()
  File "PIL/Image.py", line 488, in __init__
TypeError: Images should not be instantiated directly. Use the module new() function instead.

radarhere avatar Oct 13 '23 08:10 radarhere

@hugovk is there any particular problem with this? My guess would be that it is perhaps too complex of a change for an edge case, and the user in question should just use our API as intended?

radarhere avatar Apr 01 '24 11:04 radarhere

I was waiting to see if @homm had more to say (re: https://github.com/python-pillow/Pillow/pull/7461#discussion_r1413726539).

But it does seem like a edge case (they're getting an error calling the API in the wrong way, and this changes it to another error) and I don't think this has come up before, so I'm leaning towards the status quo.

hugovk avatar Apr 01 '24 14:04 hugovk