File 003-Raise-error-if-dimension-is-a-string.patch of Package python-Pillow

From 9a977b975cd871ef9a9128b72414c0de3a292591 Mon Sep 17 00:00:00 2001
From: Andrew Murray <radarhere@users.noreply.github.com>
Date: Sun, 29 Sep 2019 14:15:48 +1000
Subject: [PATCH] Raise error if dimension is a string

---
 Tests/test_file_tiff.py            |   5 +++++
 src/PIL/TiffImagePlugin.py         |   4 ++--
 2 files changed, 7 insertions(+), 2 deletions(-)

diff --git a/Tests/test_file_tiff.py b/Tests/test_file_tiff.py
index 2baeb6ae05..2d15de2bd5 100644
--- a/Tests/test_file_tiff.py
+++ b/Tests/test_file_tiff.py
@@ -491,6 +491,11 @@ def test_close_on_load_nonexclusive(self):
             im.load()
             self.assertFalse(fp.closed)
 
+    def test_string_dimension(self):
+        # Assert that an error is raised if one of the dimensions is a string
+        with self.assertRaises(ValueError):
+            Image.open("Tests/images/string_dimension.tiff")
+
 
 @unittest.skipUnless(sys.platform.startswith('win32'), "Windows only")
 class TestFileTiffW32(PillowTestCase):
diff --git a/src/PIL/TiffImagePlugin.py b/src/PIL/TiffImagePlugin.py
index 9fcffb7427..a927cd3ed9 100644
--- a/src/PIL/TiffImagePlugin.py
+++ b/src/PIL/TiffImagePlugin.py
@@ -1178,8 +1178,8 @@ def _setup(self):
             print("- fill_order:", fillorder)
 
         # size
-        xsize = self.tag_v2.get(IMAGEWIDTH)
-        ysize = self.tag_v2.get(IMAGELENGTH)
+        xsize = int(self.tag_v2.get(IMAGEWIDTH))
+        ysize = int(self.tag_v2.get(IMAGELENGTH))
         self.size = xsize, ysize
 
         if DEBUG:
openSUSE Build Service is sponsored by