From f53b86b6730aa730c3bf73e5d868ceadecdfd026 Mon Sep 17 00:00:00 2001 From: Bei Pang Date: Mon, 28 Oct 2019 09:48:37 -0700 Subject: [PATCH] Removed TypeError exception check in JpegImagePlugin; Updated comments in test --- Tests/test_file_jpeg.py | 4 ++-- src/PIL/JpegImagePlugin.py | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Tests/test_file_jpeg.py b/Tests/test_file_jpeg.py index 2d9864d9a..1ad9961a2 100644 --- a/Tests/test_file_jpeg.py +++ b/Tests/test_file_jpeg.py @@ -635,11 +635,11 @@ class TestFileJpeg(PillowTestCase): self.assertEqual(im.info.get("dpi"), (72, 72)) def test_invalid_exif_x_resolution(self): - # When no x or y resolution defined in EXIF + # When no x or y resolution is defined in EXIF im = Image.open("Tests/images/invalid-exif-without-x-resolution.jpg") # This should return the default, and not a ValueError or - # OSError for unidentified image. + # OSError for an unidentified image. self.assertEqual(im.info.get("dpi"), (72, 72)) def test_ifd_offset_exif(self): diff --git a/src/PIL/JpegImagePlugin.py b/src/PIL/JpegImagePlugin.py index 00ea95e41..193ca4bd0 100644 --- a/src/PIL/JpegImagePlugin.py +++ b/src/PIL/JpegImagePlugin.py @@ -172,7 +172,7 @@ def APP(self, marker): # 1 dpcm = 2.54 dpi dpi *= 2.54 self.info["dpi"] = int(dpi + 0.5), int(dpi + 0.5) - except (KeyError, TypeError, SyntaxError, ValueError, ZeroDivisionError): + except (KeyError, SyntaxError, ValueError, ZeroDivisionError): # SyntaxError for invalid/unreadable EXIF # KeyError for dpi not included # ZeroDivisionError for invalid dpi rational value