-
-
Notifications
You must be signed in to change notification settings - Fork 29.9k
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
[3.10] __pow__ and __rpow__ are not reached when __ipow__ returns NotImplemented for **= #82483
Comments
Due to shared code between the 2 and 3 forms of pow, the following code causes a TypeError: class A:
def __init__(self, val):
self.val = val
def __ipow__(self, other):
return NotImplemented
class B:
def __init__(self, val):
self.val = val
def __rpow__(self, other):
return A(other.val ** self.val)
a = A(2)
b = B(2)
a **= b |
Meant to say "... 2 and 3 arguments forms of pow, ..." |
The document says(https://docs.python.org/3.9/reference/datamodel.html?highlight=__rpow__#object.\_\_rpow__):
|
This isn't the ternary form of pow(), the documentation there is referring to the |
Oh, I see. Thank you. |
It turns out **= ONLY calls __ipow__ and neither __pow__ or __rpow__ as the data model says should be called.
|
I have opened https://bugs.python.org/issue41688 to track the documentation fixes so that this can become a release blocker for Python 3.10. |
Friendly reminder that this issue is currently blocking the 3.10a5 release. If you are ok with waiting for the next release to include the fix, please say so here or drop me an email/ |
I'm totally fine with pushing this until b1 since this has been broken for ages. |
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
bugs.python.org fields:
The text was updated successfully, but these errors were encountered: