Skip to content

Commit

Permalink
Convert to float for comparison with float in IFDRational __eq__
Browse files Browse the repository at this point in the history
  • Loading branch information
radarhere committed Apr 17, 2021
1 parent 9b6fe1b commit 7655175
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
2 changes: 2 additions & 0 deletions Tests/test_tiff_ifdrational.py
Expand Up @@ -28,6 +28,8 @@ def test_sanity():
_test_equal(1, 2, Fraction(1, 2))
_test_equal(1, 2, IFDRational(1, 2))

_test_equal(7, 5, 1.4)


def test_ranges():
for num in range(1, 10):
Expand Down
5 changes: 4 additions & 1 deletion src/PIL/TiffImagePlugin.py
Expand Up @@ -354,9 +354,12 @@ def __hash__(self):
return self._val.__hash__()

def __eq__(self, other):
val = self._val
if isinstance(other, IFDRational):
other = other._val
return self._val == other
if isinstance(other, float):
val = float(val)
return val == other

def _delegate(op):
def delegate(self, *args):
Expand Down

0 comments on commit 7655175

Please sign in to comment.