-
-
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
Added argument to raise warnings from factory errors on UnidentifiedImageError #8033
Conversation
with pytest.warns(UserWarning): | ||
with pytest.raises(UnidentifiedImageError): | ||
with Image.open(im, warn_possible_formats=True): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think these can all be in the same with
statement, separated by commas. Though that might make the line too long.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If I do that, and then run black, I get
with pytest.warns(UserWarning), pytest.raises(
UnidentifiedImageError
), Image.open(im, warn_possible_formats=True):
This does not look clearer to me.
# Leave disabled by default, spams the logs with image | ||
# opening failures that are entirely expected. | ||
# logger.debug("", exc_info=True) | ||
if warn_possible_formats: | ||
warning_messages.append(i + " opening failed. " + str(e)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
# Leave disabled by default, spams the logs with image | |
# opening failures that are entirely expected. | |
# logger.debug("", exc_info=True) | |
if warn_possible_formats: | |
warning_messages.append(i + " opening failed. " + str(e)) | |
if warn_possible_formats: | |
warning_messages.append(i + " opening failed. " + str(e)) |
The comment is probably no longer relevant with this change.
Closing due to #7993 (comment). See the issue for further discussion. |
Resolves #7993
If a user tries to open the image from that issue
they will see
If the user would like to investigate further, this PR adds "warn_possible_formats". It will show any errors raised during the checking of the formats as warnings.
giving