From 5a49375d4fb0ed2c7b9d37fab49aec7db21d76ad Mon Sep 17 00:00:00 2001 From: George Davaris Date: Wed, 11 Mar 2015 15:37:02 +0000 Subject: [PATCH 1/2] Fix UnboundLocalError in ImageFile --- PIL/ImageFile.py | 1 + 1 file changed, 1 insertion(+) diff --git a/PIL/ImageFile.py b/PIL/ImageFile.py index 82691af92..f81ddf2a0 100644 --- a/PIL/ImageFile.py +++ b/PIL/ImageFile.py @@ -202,6 +202,7 @@ class ImageFile(Image.Image): try: d.setimage(self.im, e) except ValueError: + t = None continue b = prefix t = len(b) From 68663ad3529611e3a24d39efd43dfe810fcf7561 Mon Sep 17 00:00:00 2001 From: George Davaris Date: Wed, 1 Apr 2015 10:48:28 +0100 Subject: [PATCH 2/2] Define t variable in a more appropriate place --- PIL/ImageFile.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/PIL/ImageFile.py b/PIL/ImageFile.py index f81ddf2a0..79faff797 100644 --- a/PIL/ImageFile.py +++ b/PIL/ImageFile.py @@ -196,13 +196,15 @@ class ImageFile(Image.Image): except AttributeError: prefix = b"" + # Buffer length read; assign a default value + t = 0 + for d, e, o, a in self.tile: d = Image._getdecoder(self.mode, d, a, self.decoderconfig) seek(o) try: d.setimage(self.im, e) except ValueError: - t = None continue b = prefix t = len(b)