Note: This is a public test instance of Red Hat Bugzilla. The data contained within is a snapshot of the live data so any changes you make will not be reflected in the production Bugzilla. Email is disabled so feel free to test any aspect of the site that you want. File any problems you find or give feedback at bugzilla.redhat.com.
Bug 1936947
Summary: | python-gmpy2 fails to build with Python 3.10: TypeError: unsupported operand type(s) for ** or pow(): 'xmpz' and 'mpfr' | ||
---|---|---|---|
Product: | [Fedora] Fedora | Reporter: | Tomáš Hrnčiar <thrnciar> |
Component: | python-gmpy2 | Assignee: | Jerry James <loganjerry> |
Status: | CLOSED RAWHIDE | QA Contact: | Fedora Extras Quality Assurance <extras-qa> |
Severity: | unspecified | Docs Contact: | |
Priority: | unspecified | ||
Version: | rawhide | CC: | loganjerry, mhroncok, orion, thrnciar |
Target Milestone: | --- | ||
Target Release: | --- | ||
Hardware: | Unspecified | ||
OS: | Unspecified | ||
Whiteboard: | |||
Fixed In Version: | python-gmpy2-2.1.0-0.22.b5.fc35 | Doc Type: | If docs needed, set a value |
Doc Text: | Story Points: | --- | |
Clone Of: | Environment: | ||
Last Closed: | 2021-03-09 21:31:22 UTC | Type: | Bug |
Regression: | --- | Mount Type: | --- |
Documentation: | --- | CRM: | |
Verified Versions: | Category: | --- | |
oVirt Team: | --- | RHEL 7.3 requirements from Atomic Host: | |
Cloudforms Team: | --- | Target Upstream Version: | |
Embargoed: | |||
Bug Depends On: | |||
Bug Blocks: | 1890881 |
Description
Tomáš Hrnčiar
2021-03-09 14:16:56 UTC
Both of those tests are expected to fail with a TypeError. Taking the power of a negative integer is supposed to throw this exception: TypeError: unsupported operand type(s) for ** or pow(): 'mpz' and 'int' but now it throws this exception: ValueError: pow() exponent cannot be negative suggesting that -2 was automatically converted to an mpz. In the second test, taking the power of an mpfr floating point number is supposed to throw this exception: TypeError: unsupported operand type(s) for ** or pow(): 'mpz' and 'mpfr' but now it produces a value: mpfr('152587890625.0') suggesting that mpz(390625) was automatically converted to an mpfr. Has something changed in python 3.10 regarding automatic promotion of operands? The difference is that, with python 3.9, "x **= -2" results in a call through the nb_inplace_power slot of GMPy_MPZ_number_methods (of type PyNumberMethods). With the latest python 3.10 alpha, that same expression results in a call through the nb_power slot instead. Why isn't it using the inplace slot? Anyway, gmpy2, for whatever reason, treats type promotions differently in the methods used to implement those two slots, which is why the tests are failing. https://docs.python.org/3.10/whatsnew/3.10.html only mentions this: If object.__ipow__() returns NotImplemented, the operator will correctly fall back to object.__pow__() and object.__rpow__() as expected. https://bugs.python.org/issue38302 Maybe it is related? Yes, that's exactly it. With python 3.9, we try the __ipow__ method, get NotImplemented and fail. With python 3.10, we fall back to __pow__ or __rpow__ and either get a different error or succeed, respectively. I actually like the python 3.10 results better. I'll let upstream know to expect this change and try to come up with a way to unblock your work. Upstream issue: https://github.com/aleaxit/gmpy/issues/296 I added a patch to Rawhide, applied if and only if building with python >= 3.10, that changes the test suite to expect the new results. A Rawhide build just completed. So did the copr build. https://copr.fedorainfracloud.org/coprs/g/python/python3.10/package/python-gmpy2/ Thanks! |