From 0a46cbfea9f1e01cf5b51f89311d64636da4eddd Mon Sep 17 00:00:00 2001 From: Andrew Murray Date: Fri, 28 Aug 2020 20:55:47 +1000 Subject: [PATCH] Reverted NaN change, so that NaN != NaN --- Tests/test_tiff_ifdrational.py | 7 ------- src/PIL/TiffImagePlugin.py | 8 ++------ 2 files changed, 2 insertions(+), 13 deletions(-) diff --git a/Tests/test_tiff_ifdrational.py b/Tests/test_tiff_ifdrational.py index e97665278..1697a8d49 100644 --- a/Tests/test_tiff_ifdrational.py +++ b/Tests/test_tiff_ifdrational.py @@ -30,7 +30,6 @@ def test_sanity(): def test_ranges(): - for num in range(1, 10): for denom in range(1, 10): assert IFDRational(num, denom) == IFDRational(num, denom) @@ -50,12 +49,6 @@ def test_nonetype(): assert xres and yres -def test_nan(): - # usually NaN != NaN, but this would break exif self-equality - - assert IFDRational(123, 0) == IFDRational(123, 0) - - def test_ifd_rational_save(tmp_path): methods = (True, False) if not features.check("libtiff"): diff --git a/src/PIL/TiffImagePlugin.py b/src/PIL/TiffImagePlugin.py index ea88ef0f7..cb925246d 100644 --- a/src/PIL/TiffImagePlugin.py +++ b/src/PIL/TiffImagePlugin.py @@ -354,12 +354,8 @@ class IFDRational(Rational): def __eq__(self, other): if isinstance(other, IFDRational): - if self.denominator == 0 and other.denominator == 0: - # in this case self._val and other._val would be NaN - return self.numerator == other.numerator - return self._val == other._val - else: - return self._val == other + other = other._val + return self._val == other def _delegate(op): def delegate(self, *args):