mirror of
https://github.com/python-pillow/Pillow.git
synced 2024-11-11 04:07:21 +03:00
Merge pull request #1416 from wiredfool/pr1309
Fix for UnicodeDecodeError in TiffImagePlugin
This commit is contained in:
commit
f631ddb1ef
|
@ -550,6 +550,8 @@ class ImageFileDirectory(collections.MutableMapping):
|
|||
# contains a 7-bit ASCII code; the last byte must be
|
||||
# NUL (binary zero). Also, I don't think this was well
|
||||
# exercised before.
|
||||
if sys.version_info[0] == 2:
|
||||
value = value.decode('ascii','replace')
|
||||
data = value = b"" + value.encode('ascii', 'replace') + b"\0"
|
||||
else:
|
||||
# integer data
|
||||
|
|
|
@ -15,7 +15,8 @@ class TestFileTiffMetadata(PillowTestCase):
|
|||
|
||||
img = hopper()
|
||||
|
||||
textdata = "This is some arbitrary metadata for a text field"
|
||||
basetextdata = "This is some arbitrary metadata for a text field"
|
||||
textdata = basetextdata + " \xff"
|
||||
floatdata = 12.345
|
||||
doubledata = 67.89
|
||||
|
||||
|
@ -35,8 +36,8 @@ class TestFileTiffMetadata(PillowTestCase):
|
|||
|
||||
loaded = Image.open(f)
|
||||
|
||||
self.assertEqual(loaded.tag[50838], (len(textdata),))
|
||||
self.assertEqual(loaded.tag[50839], textdata)
|
||||
self.assertEqual(loaded.tag[50838], (len(basetextdata + " ?"),))
|
||||
self.assertEqual(loaded.tag[50839], basetextdata + " ?")
|
||||
self.assertAlmostEqual(loaded.tag[tag_ids['RollAngle']][0], floatdata,
|
||||
places=5)
|
||||
self.assertAlmostEqual(loaded.tag[tag_ids['YawAngle']][0], doubledata)
|
||||
|
|
Loading…
Reference in New Issue
Block a user