diff --git a/PIL/ImageFile.py b/PIL/ImageFile.py index d892ba584..a3d34652f 100644 --- a/PIL/ImageFile.py +++ b/PIL/ImageFile.py @@ -33,7 +33,7 @@ import io import logging import os import sys -# import traceback +import struct logger = logging.getLogger(__name__) @@ -101,7 +101,8 @@ class ImageFile(Image.Image): except (IndexError, # end of data TypeError, # end of data (ord) KeyError, # unsupported mode - EOFError) as v: # got header but not the first frame + EOFError, # got header but not the first frame + struct.error) as v: logger.exception("%s") raise SyntaxError(v) @@ -204,7 +205,7 @@ class ImageFile(Image.Image): while True: try: s = read(self.decodermaxblock) - except IndexError as ie: # truncated png/gif + except (IndexError, struct.error) as ie: # truncated png/gif if LOAD_TRUNCATED_IMAGES: break else: