Skip to content

Fix exception handling when saving images#4838

Closed
liZe wants to merge 1 commit into
python-pillow:masterfrom
liZe:patch-1
Closed

Fix exception handling when saving images#4838
liZe wants to merge 1 commit into
python-pillow:masterfrom
liZe:patch-1

Conversation

@liZe

@liZe liZe commented Aug 3, 2020

Copy link
Copy Markdown
Contributor

The e variable is already used in the for loop, use exc to store the exception.

The e variable is already used in the for loop, use exc to store the exception.
@radarhere

Copy link
Copy Markdown
Member

Thanks for this. Is there a test situation that you know of that triggers the bug, so that we can add it to the test suite and prevent this from re-appearing in the future?

@radarhere radarhere added the Bug Any unexpected behavior, until confirmed feature. label Aug 3, 2020
@liZe

liZe commented Aug 4, 2020

Copy link
Copy Markdown
Contributor Author

Thanks for this. Is there a test situation that you know of that triggers the bug, so that we can add it to the test suite and prevent this from re-appearing in the future?

Sure!

from io import BytesIO
from PIL import Image
Image.new('P', (1, 1)).save(BytesIO(), 'JPEG2000')

This should raise the OSError, not TypeError: exception causes must derive from BaseException.

@radarhere

Copy link
Copy Markdown
Member

@liZe you've deleted your Pillow repository. I'd like to add the test situation you've mentioned though, so I've recreated this PR as #4885. Let us know if you have anything further to add.

@radarhere radarhere closed this Aug 24, 2020
@liZe

liZe commented Aug 24, 2020

Copy link
Copy Markdown
Contributor Author

I'd like to add the test situation you've mentioned though, so I've recreated this PR as #4885. Let us know if you have anything further to add.

Sorry, I didn’t check, I thought it was already merged.

#4885 is OK for me!

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

Labels

Bug Any unexpected behavior, until confirmed feature.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants