Improved warning message when the tiff exif byte order is bad. #230

This commit is contained in:
jevans 2014-05-10 17:39:40 -04:00
commit c01774c036
2 changed files with 7 additions and 1 deletions

View file

@ -37,7 +37,9 @@ def tiff_header(read_buffer):
# big endian
endian = '>'
else:
msg = "Bad byte order indication: {0}".format(read_buffer[6:8])
msg = "The byte order indication in the TIFF header ({0}) is invalid. "
msg += "It should be either {1} or {2}."
msg = msg.format(read_buffer[6:8], bytes([73, 73]), bytes([77, 77]))
raise IOError(msg)
_, offset = struct.unpack(endian + 'HI', read_buffer[8:14])

View file

@ -167,6 +167,10 @@ class TestUUIDExif(unittest.TestCase):
warnings.simplefilter('always')
j = glymur.Jp2k(tfile.name)
self.assertTrue(issubclass(w[0].category, UserWarning))
msg = 'The byte order indication in the TIFF header '
msg += "(b'JI') is invalid. "
msg += "It should be either b'II' or b'MM'."
self.assertTrue(msg in str(w[0].message))
self.assertEqual(j.box[-1].box_id, 'uuid')