Pillow
Pillow copied to clipboard
Raise a TypeError when Image() is called
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.
@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?
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.