-
-
Notifications
You must be signed in to change notification settings - Fork 2.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Pillow silently fails with "Cannot identify image file" long after an image has been identified #1687
Comments
It's because of this: Line 2278 in 3d6e137
|
It just shouldn't catch everything... Plugins should raise an InvalidFile error or some such, and it should catch only that type of exception. This is related to the ticket I filed recently wrt SyntaxError. |
I'm guessing that the issue that @jleclanche is referring to is #1643 |
Partly, yes. |
You want to submit a PR for this one, too? Not sure about the logistics of getting it merged but always nice to have specific implementation to reference. |
@aclark4life I don't feel comfortable PRing something for this until the first PR is landed and has been pretty thoroughly tested. Also need to start using those new exception types everywhere and make sure PIL doesn't raise any of those errors anymore, always PIL-based exceptions. Once that happens, the except block can be replaced with a single |
The 'first PR' being referred to is #2339 |
I think the spirit is that if there is an error when loading an image, it doesn't necessarily mean that there is a problem with Pillow's code - it may mean that there is a problem with the file. I don't think Pillow's approach to this should be changed without a compelling reason. I had a thought that we could distinguish between not opening an image and not identifying an image. However, I don't think our formats allow for this.
It could have been a good idea if we were starting Pillow from scratch, but for a library concerned with backwards compatibility, I don't think it can be achieved without rewrites that seem excessive. |
When creating a custom image plugin, if Plugin._open() fails for whatever reason, Pillow will fail:
This hints at the error being in the magic check, which of course it isn't. It silently ignores errors and just thinks the image is simply not a valid file of that type and moves on, eventually raising an unrelated error. This is extremely frustrating.
The text was updated successfully, but these errors were encountered: