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
__rdiv__ vs new-style classes #37325
Comments
In 2.2.2 and 2.3, consider this: """ class F2(F):
def __init__(self):
print 'built an F2' 3 / F2() This displays what I expect: """ However, change F to derive from object: class F(object): and it's in infinite recursion, starting like so: """ Despite that F.__rdiv__ creates an explicit F() instance Maybe this is intentional? I confess I've lost track of the Changing the end of F.__rdiv__ to return F().__div__(self) brute-forces the desired outcome, so there is a |
Logged In: YES I've got a dilemma. The cause of the recursion is in line 3509 of typeobject.c, if (do_other && \ (introduced by rev 2.82 of thatfile) tries to call the right This is intended to "do the right thing" in cases where D The endless recursion reported above is caused by the fact My dilemma is that this feature is not documented, and But checking that D's __rdiv__ is really the same as C's I'm going to think about this some more... |
Logged In: YES OK, I've checked in a fix that checks whether other actually Sigh, this was hard work. |
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: