Skip to content
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

UnboundLocalError when opening images #3883

Closed
Wicloz opened this issue Jun 2, 2019 · 3 comments
Closed

UnboundLocalError when opening images #3883

Wicloz opened this issue Jun 2, 2019 · 3 comments
Projects

Comments

@Wicloz
Copy link

Wicloz commented Jun 2, 2019

What did you do?

Open an image

What did you expect to happen?

The image is opened and available for use

What actually happened?

The following error is thrown:

Traceback (most recent call last):
  File "C:/Users/wdboer/Desktop/RIP PIL/main.py", line 2, in <module>
    Image.open('broken.jpg')
  File "C:\Users\wdboer\AppData\Local\Programs\Python\Python37\lib\site-packages\PIL\Image.py", line 2690, in open
    im = _open_core(fp, filename, prefix)
  File "C:\Users\wdboer\AppData\Local\Programs\Python\Python37\lib\site-packages\PIL\Image.py", line 2676, in _open_core
    im = factory(fp, filename)
  File "C:\Users\wdboer\AppData\Local\Programs\Python\Python37\lib\site-packages\PIL\JpegImagePlugin.py", line 783, in jpeg_factory
    im = JpegImageFile(fp, filename)
  File "C:\Users\wdboer\AppData\Local\Programs\Python\Python37\lib\site-packages\PIL\ImageFile.py", line 103, in __init__
    self._open()
  File "C:\Users\wdboer\AppData\Local\Programs\Python\Python37\lib\site-packages\PIL\JpegImagePlugin.py", line 373, in _open
    handler(self, i)
  File "C:\Users\wdboer\AppData\Local\Programs\Python\Python37\lib\site-packages\PIL\JpegImagePlugin.py", line 139, in APP
    self.info["photoshop"] = photoshop
UnboundLocalError: local variable 'photoshop' referenced before assignment

What are your OS, Python and Pillow versions?

  • OS: Windows 10
  • Python: 3.7.2
  • Pillow: 6.0.0

Please include code that reproduces the issue and whenever possible, an image that demonstrates the issue. Please upload images to GitHub, not to third-party file hosting sites. If necessary, add the image to a zip or tar archive.

The best reproductions are self-contained scripts with minimal dependencies. If you are using a framework such as plone, Django, or buildout, try to replicate the issue just using Pillow.

from PIL import Image
Image.open('broken.jpg')

broken

@Wicloz
Copy link
Author

Wicloz commented Jun 3, 2019

I just looked at JpegImagePlugin.py and it would seem this issue has been resolved on master. The code at

elif marker == 0xFFED:
looks different from the other elif statements though, which might lead to other obscure issues.

@hugovk
Copy link
Member

hugovk commented Jun 3, 2019

Thanks for the report. This has been fixed in #3769 and will be in the next release.

@radarhere radarhere added this to In progress in Pillow Jun 7, 2019
@radarhere
Copy link
Member

Pillow 6.1.0 has now been released, with the fix for this.

@hugovk hugovk closed this as completed Jul 3, 2019
Pillow automation moved this from In progress to Closed Jul 3, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Pillow
  
Closed
Development

No branches or pull requests

3 participants