Add -pow patch for python 3.10 compatibility.

This commit is contained in:
Jerry James 2021-03-09 14:19:49 -07:00
parent 73396431ef
commit ddda099b77
2 changed files with 56 additions and 2 deletions

42
python-gmpy2-pow.patch Normal file
View File

@ -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

View File

@ -3,7 +3,7 @@
Name: python-%{srcname}
Version: 2.1.0
Release: 0.21%{?prerelease:.%{prerelease}}%{?dist}
Release: 0.22%{?prerelease:.%{prerelease}}%{?dist}
Summary: Python interface to GMP, MPFR, and MPC
License: LGPLv3+
@ -12,6 +12,11 @@ Source0: https://github.com/aleaxit/gmpy/archive/%{srcname}-%{version}%{?
# Fix build with python 3.10
# https://github.com/aleaxit/gmpy/pull/283
Patch0: %{name}-python310.patch
# Some tests return different results in python 3.10 due to this change:
# "If object.__ipow__() returns NotImplemented, the operator will correctly
# fall back to object.__pow__() and object.__rpow__() as expected.
# https://bugs.python.org/issue38302"
Patch1: %{name}-pow.patch
BuildRequires: gcc
BuildRequires: gmp-devel
@ -44,7 +49,11 @@ Provides: bundled(jquery)
%{common_desc}
%prep
%autosetup -n gmpy-%{srcname}-%{version}%{?prerelease} -p1
%autosetup -N -n gmpy-%{srcname}-%{version}%{?prerelease}
%patch0 -p1
%if 0%{?python3_version_nodots} >= 310
%patch1 -p1
%endif
# Update the sphinx theme name
sed -i "s/'default'/'classic'/" docs/conf.py
@ -80,6 +89,9 @@ cd -
%{python3_sitearch}/%{srcname}*
%changelog
* Tue Mar 9 2021 Jerry James <loganjerry@gmail.com> - 2.1.0-0.22.b5
- Add -pow patch for python 3.10 compatibility
* Wed Jan 27 2021 Fedora Release Engineering <releng@fedoraproject.org> - 2.1.0-0.21.b5
- Rebuilt for https://fedoraproject.org/wiki/Fedora_34_Mass_Rebuild