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
classmethod does not pass "type/owner" when invoking wrapped __get__ #86239
Comments
The following is new to Python 3.9, and I consider the implementation incomplete. I have code that works for Python 3.8 and before, but not for Python 3.9: "Class methods can now wrap other :term:`descriptors <descriptor>` such as :func:`property`." #8405 As implemented, Here is a minimal example:
This pattern would typically be used to do something extra in __call__. For the sake of discussion, let's call the two arguments to __get__ "instance" and "owner". Typically, "instance" is an instance of "owner", or, equivalently, "owner" is the type of "instance". If "owner" is None, it is generally assumed to be the type of "instance". In bpo-19072 (and gh8405), classmethod was changed to call I believe it would be better for classmethod to call This is kind of difficult to explain. I will make a PR with more informative tests shortly. Here is the simple diff to make the above example pass:
Since I consider the new behavior to have introduced a regression, I think this change should be applied to both 3.9 and 3.10. Cheers! |
Thanks! ✨ 🍰 ✨ |
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: