You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This will silently do the wrong thing instead of exploding if this is the second+ tag being serialized (as it will inherit values from the previous iteration of the loop.
It probably won't take that path for non-empty dictionaries, as those would have non-trivial data length.
A simple fix would be if len(data) >= 16 or is_ifd but I'm not super familiar with the codebase so it may not be the best choice.
The text was updated successfully, but these errors were encountered:
I've created #5556 to resolve this, with a simple test case. Rather than using or is_ifd, my suggestion is instead to set values when is_ifd is true as well.
radarhere
changed the title
"UnboundLocalError: local variable 'values' referenced before assignment" when image.getexif().tobytes() on specific JPEGS
"UnboundLocalError: local variable 'values' referenced before assignment" when image.getexif().tobytes() on specific JPEGs
Jun 25, 2021
I can't post the picture itself because it's from a customer, but the offending exif data trying to be serialized is:
That empty dictionary for 34665 seems to be the culprit.
The failing statement is the use of
str(values)
whenis_ifd
is true (and thusvalues
never gets defined):Pillow/src/PIL/TiffImagePlugin.py
Line 840 in 70ef50c
This will silently do the wrong thing instead of exploding if this is the second+ tag being serialized (as it will inherit
values
from the previous iteration of the loop.It probably won't take that path for non-empty dictionaries, as those would have non-trivial
data
length.A simple fix would be
if len(data) >= 16 or is_ifd
but I'm not super familiar with the codebase so it may not be the best choice.The text was updated successfully, but these errors were encountered: