From 78e971913ce9db7c5a4749fc1a22f901b44c5e9e Mon Sep 17 00:00:00 2001 From: luphord Date: Fri, 24 Jul 2020 16:17:15 +0200 Subject: [PATCH] fix IFDRational equality --- src/PIL/TiffImagePlugin.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/PIL/TiffImagePlugin.py b/src/PIL/TiffImagePlugin.py index 018789abf..ea88ef0f7 100644 --- a/src/PIL/TiffImagePlugin.py +++ b/src/PIL/TiffImagePlugin.py @@ -353,7 +353,13 @@ class IFDRational(Rational): return self._val.__hash__() def __eq__(self, other): - return self._val == 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 def _delegate(op): def delegate(self, *args):