void-packages/srcpkgs/python3-sympy/patches/fix_integer_nthroot.patch

27 lines
848 B
Diff

Fix integer_nthroot(2, 10**10) in 32 bit.
See: https://github.com/sympy/sympy/issues/18374#issuecomment-1081196879
diff --git a/sympy/core/power.py b/sympy/core/power.py
index 59ab7c53a4..ae3ee25c93 100644
--- a/sympy/core/power.py
+++ b/sympy/core/power.py
@@ -21,6 +21,8 @@
from mpmath.libmp import sqrtrem as mpmath_sqrtrem
+from ctypes import c_ulong
+ULONG_MAX = c_ulong(-1).value
def isqrt(n):
@@ -74,7 +76,7 @@ def integer_nthroot(y, n):
raise ValueError("y must be nonnegative")
if n < 1:
raise ValueError("n must be positive")
- if HAS_GMPY and n < 2**63:
+ if HAS_GMPY and n <= ULONG_MAX:
# Currently it works only for n < 2**63, else it produces TypeError
# sympy issue: https://github.com/sympy/sympy/issues/18374
# gmpy2 issue: https://github.com/aleaxit/gmpy/issues/257