]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
Remove unnecessary test for `xc == 1` in _pydecimal (GH-27102)
authorElisha Hollander <just4now666666@gmail.com>
Thu, 15 Jul 2021 10:48:46 +0000 (13:48 +0300)
committerGitHub <noreply@github.com>
Thu, 15 Jul 2021 10:48:46 +0000 (12:48 +0200)
- if `xc == 1` then the function returns on line 2140;
- other assignments to `xc` are inside the `y.sign == 1` condition block which always returns early

Lib/_pydecimal.py

index 3d6cece9676c93d84482331bdb0ecebd4bdb9534..f6d9ddf42e4734c5cbbb4efb5b842a5d2cf9737d 100644 (file)
@@ -2230,7 +2230,7 @@ class Decimal(object):
             if xe != 0 and len(str(abs(yc*xe))) <= -ye:
                 return None
             xc_bits = _nbits(xc)
-            if xc != 1 and len(str(abs(yc)*xc_bits)) <= -ye:
+            if len(str(abs(yc)*xc_bits)) <= -ye:
                 return None
             m, n = yc, 10**(-ye)
             while m % 2 == n % 2 == 0:
@@ -2243,7 +2243,7 @@ class Decimal(object):
         # compute nth root of xc*10**xe
         if n > 1:
             # if 1 < xc < 2**n then xc isn't an nth power
-            if xc != 1 and xc_bits <= n:
+            if xc_bits <= n:
                 return None
 
             xe, rem = divmod(xe, n)