Skip to content

Commit

Permalink
Fix python 3 bytes to string concat error
Browse files Browse the repository at this point in the history
  • Loading branch information
kkopachev committed Jun 29, 2016
1 parent c3b970f commit 885297d
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion PIL/PngImagePlugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ def crc(self, cid, data):

# Skip CRC checks for ancillary chunks if allowed to load truncated images
# 5th byte of first char is 1 [specs, section 5.4]
if ImageFile.LOAD_TRUNCATED_IMAGES and (ord(cid[0]) >> 5 & 1):
if ImageFile.LOAD_TRUNCATED_IMAGES and (i8(cid[0]) >> 5 & 1):
self.crc_skip(cid, data)
return

Expand Down
4 changes: 2 additions & 2 deletions Tests/test_file_png.py
Original file line number Diff line number Diff line change
Expand Up @@ -324,7 +324,7 @@ def test_verify_ignores_crc_error(self):
# check ignores crc errors in ancillary chunks

chunk_data = chunk(b'tEXt', b'spam')
broken_crc_chunk_data = chunk_data[:-1] + 'q' # break CRC
broken_crc_chunk_data = chunk_data[:-1] + b'q' # break CRC

image_data = HEAD + broken_crc_chunk_data + TAIL
self.assertRaises(SyntaxError,
Expand All @@ -340,7 +340,7 @@ def test_verify_ignores_crc_error(self):
def test_verify_not_ignores_crc_error_in_required_chunk(self):
# check does not ignore crc errors in required chunks

image_data = MAGIC + IHDR[:-1] + 'q' + TAIL
image_data = MAGIC + IHDR[:-1] + b'q' + TAIL

ImageFile.LOAD_TRUNCATED_IMAGES = True
try:
Expand Down

0 comments on commit 885297d

Please sign in to comment.