-
-
Notifications
You must be signed in to change notification settings - Fork 31.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
bpo-44698: Restore complex pow behaviour for small integral exponents #27772
bpo-44698: Restore complex pow behaviour for small integral exponents #27772
Conversation
@@ -174,12 +174,7 @@ c_powi(Py_complex x, long n) | |||
{ | |||
Py_complex cn; | |||
|
|||
if (n > 100 || n < -100) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This branch is now redundant: the bounds check is performed in the code that calls c_powi
.
Thanks @mdickinson for the PR 🌮🎉.. I'm working now to backport this PR to: 3.9, 3.10. |
GH-27796 is a backport of this pull request to the 3.10 branch. |
GH-27797 is a backport of this pull request to the 3.9 branch. |
@gpshead Thank you for the review! |
…pythonGH-27772) (cherry picked from commit 4b9a2dc) Co-authored-by: Mark Dickinson <mdickinson@enthought.com>
…pythonGH-27772) (cherry picked from commit 4b9a2dc) Co-authored-by: Mark Dickinson <mdickinson@enthought.com>
PR #27278 fixed undefined behaviour in complex exponentiation, but also changed the behaviour for exponentiations whose exponent was a small integer but not actually an
int
, for example as in(3+4j)**2.0
. In particular, the overflow behaviour for these expressions changed:Prior to #27278:
After #27278 :
This PR restores the old behaviour, but does not re-introduce the undefined behaviour fixed by the original PR.
https://bugs.python.org/issue44698