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
Fix UnboundLocalError in ImageFile #1131
Fix UnboundLocalError in ImageFile #1131
Conversation
@davarisg It would be nice to add a unit test for this. Can this image be distributed under a MIT licence? Or do you have one which can be? |
@hugovk I am afraid it can't be distributed. Not sure if I can find another one. |
@davarisg Can you find out if |
I think And style wise, I'd rather see it defined outside the for loop, rather than have two code paths that initially define it. |
Sorry guys, but I cant find an image that can be distributed under the MIT licence. So I cant write a unit test right now. I ll keep looking though. |
Changes Unknown when pulling 68663ad on mixcloud:gd-unbound-local-variable into * on python-pillow:master*. |
@davarisg Can we create an image and/or add a stub for the test so we don't forget? Thanks |
Fix UnboundLocalError in ImageFile
I've merged this. It's just a single line to initialise a variable before use. Of course it'd be great to find a test image matching the problem one and add a test, but there's no need for that to delay this from today's release. |
Thanks |
Thanks guys. Also have you considered adding the |
+1 for mock |
Steps to reproduce:
It seems like
d.setimage(self.im, e)
(https://github.com/python-pillow/Pillow/blob/master/PIL/ImageFile.py#L203) raises a ValueError so the variablet
will never be set.I am not 100% sure if
t = None
is the right default value, but this seems to work.