diff --git a/Tests/test_file_tiff_metadata.py b/Tests/test_file_tiff_metadata.py index 035a4fcc1..edfeeb465 100644 --- a/Tests/test_file_tiff_metadata.py +++ b/Tests/test_file_tiff_metadata.py @@ -253,7 +253,7 @@ class TestFileTiffMetadata(PillowTestCase): # pair of 4 byte signed longs numerator = 2 ** 31 - 1 - denominator = -2 ** 31 + denominator = -(2 ** 31) info[37380] = TiffImagePlugin.IFDRational(numerator, denominator) @@ -265,7 +265,7 @@ class TestFileTiffMetadata(PillowTestCase): self.assertEqual(denominator, reloaded.tag_v2[37380].denominator) # pair of 4 byte signed longs - numerator = -2 ** 31 + numerator = -(2 ** 31) denominator = 2 ** 31 - 1 info[37380] = TiffImagePlugin.IFDRational(numerator, denominator) diff --git a/src/PIL/TiffImagePlugin.py b/src/PIL/TiffImagePlugin.py index f8993310e..e6a5fc63a 100644 --- a/src/PIL/TiffImagePlugin.py +++ b/src/PIL/TiffImagePlugin.py @@ -544,7 +544,7 @@ class ImageFileDirectory_v2(MutableMapping): elif all(isinstance(v, int) for v in values): if all(0 <= v < 2 ** 16 for v in values): self.tagtype[tag] = TiffTags.SHORT - elif all(-2 ** 15 < v < 2 ** 15 for v in values): + elif all(-(2 ** 15) < v < 2 ** 15 for v in values): self.tagtype[tag] = TiffTags.SIGNED_SHORT else: self.tagtype[tag] = ( @@ -715,7 +715,7 @@ class ImageFileDirectory_v2(MutableMapping): @_register_writer(10) def write_signed_rational(self, *values): return b"".join( - self._pack("2l", *_limit_signed_rational(frac, 2 ** 31 - 1, -2 ** 31)) + self._pack("2l", *_limit_signed_rational(frac, 2 ** 31 - 1, -(2 ** 31))) for frac in values )