From 290189596ec77808d98ce6ea57fbf41f611a60dd Mon Sep 17 00:00:00 2001 From: Andrew Murray Date: Mon, 30 Sep 2019 21:11:40 +1000 Subject: [PATCH 1/2] Removed redundant return --- src/PIL/TiffImagePlugin.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/PIL/TiffImagePlugin.py b/src/PIL/TiffImagePlugin.py index 7f596b9ed..ab53483c5 100644 --- a/src/PIL/TiffImagePlugin.py +++ b/src/PIL/TiffImagePlugin.py @@ -327,8 +327,6 @@ class IFDRational(Rational): if denominator == 0: self._val = float("nan") - return - elif denominator == 1: self._val = Fraction(value) else: From 887a7e503cbff8f42704d1323b01e46c4f1f2ce1 Mon Sep 17 00:00:00 2001 From: Andrew Murray Date: Mon, 30 Sep 2019 21:18:52 +1000 Subject: [PATCH 2/2] Only assign once --- src/PIL/TiffImagePlugin.py | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/src/PIL/TiffImagePlugin.py b/src/PIL/TiffImagePlugin.py index ab53483c5..a685009e8 100644 --- a/src/PIL/TiffImagePlugin.py +++ b/src/PIL/TiffImagePlugin.py @@ -310,20 +310,18 @@ class IFDRational(Rational): float/rational/other number, or an IFDRational :param denominator: Optional integer denominator """ - self._denominator = denominator - self._numerator = value - self._val = float(1) + if isinstance(value, IFDRational): + self._numerator = value.numerator + self._denominator = value.denominator + self._val = value._val + return if isinstance(value, Fraction): self._numerator = value.numerator self._denominator = value.denominator - self._val = value - - if isinstance(value, IFDRational): - self._denominator = value.denominator - self._numerator = value.numerator - self._val = value._val - return + else: + self._numerator = value + self._denominator = denominator if denominator == 0: self._val = float("nan")