This repository has been archived by the owner on Jan 30, 2023. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
build/pkgs/gmpy2/patches: Add patches from Fedora @python/python3.10
- Loading branch information
Matthias Koeppe
committed
May 25, 2021
1 parent
d6c5cd9
commit 8cd9ece
Showing
3 changed files
with
89 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
--- a/src/gmpy2_hash.c 2020-07-30 20:21:41.000000000 -0600 | ||
+++ b/src/gmpy2_hash.c 2021-05-10 10:47:42.838963521 -0600 | ||
@@ -147,7 +147,7 @@ _mpfr_hash(mpfr_t f) | ||
} | ||
} | ||
else { | ||
- return _PyHASH_NAN; | ||
+ return 0; | ||
} | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
--- a/test/test_gmpy2_mpz_inplace.txt 2020-07-30 20:21:41.000000000 -0600 | ||
+++ b/test/test_gmpy2_mpz_inplace.txt 2021-03-09 13:59:09.754648136 -0700 | ||
@@ -149,14 +149,12 @@ mpz(25) | ||
mpz(625) | ||
>>> x **= -2 | ||
Traceback (most recent call last): | ||
- File "<stdin>", line 1, in <module> | ||
-TypeError: unsupported operand type(s) for ** or pow(): 'mpz' and 'int' | ||
+ ... | ||
+ValueError: pow() exponent cannot be negative | ||
>>> x **= 2; x | ||
mpz(390625) | ||
->>> x **= mpfr(2) | ||
-Traceback (most recent call last): | ||
- File "<stdin>", line 1, in <module> | ||
-TypeError: unsupported operand type(s) for ** or pow(): 'mpz' and 'mpfr' | ||
+>>> x **= mpfr(2); x | ||
+mpfr('152587890625.0') | ||
>>> 1 | ||
1 | ||
|
||
--- a/test/test_gmpy2_xmpz_inplace.txt 2020-07-30 20:21:41.000000000 -0600 | ||
+++ b/test/test_gmpy2_xmpz_inplace.txt 2021-03-09 14:14:50.675340634 -0700 | ||
@@ -134,14 +134,12 @@ xmpz(25) | ||
xmpz(625) | ||
>>> x **= -2 | ||
Traceback (most recent call last): | ||
- File "<stdin>", line 1, in <module> | ||
-TypeError: unsupported operand type(s) for ** or pow(): 'xmpz' and 'int' | ||
+ ... | ||
+ValueError: pow() exponent cannot be negative | ||
>>> x **= 2; x | ||
xmpz(390625) | ||
->>> x **= mpfr(2) | ||
-Traceback (most recent call last): | ||
- File "<stdin>", line 1, in <module> | ||
-TypeError: unsupported operand type(s) for ** or pow(): 'xmpz' and 'mpfr' | ||
+>>> x **= mpfr(2); x | ||
+mpfr('152587890625.0') | ||
>>> 1 | ||
1 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
diff --git a/src/gmpy2_convert_gmp.c b/src/gmpy2_convert_gmp.c | ||
index 2550560..f4a2679 100644 | ||
--- a/src/gmpy2_convert_gmp.c | ||
+++ b/src/gmpy2_convert_gmp.c | ||
@@ -222,10 +222,18 @@ GMPy_PyLong_From_MPZ(MPZ_Object *obj, CTXT_Object *context) | ||
while ((size>0) && (result->ob_digit[size-1] == 0)) { | ||
size--; | ||
} | ||
+#if PY_VERSION_HEX >= 0x030900A0 | ||
+ Py_SET_SIZE(result, size); | ||
+#else | ||
Py_SIZE(result) = size; | ||
+#endif | ||
|
||
if (negative) { | ||
+#if PY_VERSION_HEX >= 0x030900A0 | ||
+ Py_SET_SIZE(result, - Py_SIZE(result)); | ||
+#else | ||
Py_SIZE(result) = - Py_SIZE(result); | ||
+#endif | ||
} | ||
return (PyObject*)result; | ||
} | ||
diff --git a/test/runtests.py b/test/runtests.py | ||
index fb9f2b3..5e5842d 100644 | ||
--- a/test/runtests.py | ||
+++ b/test/runtests.py | ||
@@ -75,7 +75,7 @@ print(" Caching Values: (Cache size) {0}".format(gmpy2.get_cache()[0])) | ||
print(" Caching Values: (Size in limbs) {0}".format(gmpy2.get_cache()[1])) | ||
print() | ||
|
||
-if sys.version.startswith('3.1'): | ||
+if sys.version.startswith('3.1.'): | ||
print("Due to differences in formatting of exceptions and Python 3.x, there") | ||
print("will be test failures for exception handling when the tests are run") | ||
print("with Python 3.1. The doctest module in Python 3.2 and later does not") |