bpo-30530: Descriptor HowTo: update Function.get by rmariano · Pull Request #1845 · python/cpython (original) (raw)
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 andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Conversation6 Commits1 Checks0 Files changed
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
[ Show hidden characters]({{ revealButtonHref }})
The creation of the method like in the example did not work, because in
Python 3.6 MethodType
takes 2 arguments (not 3). In Python 2 works,
so the fix is for Python 3.6 and up.
...
TypeError: method expected 2 arguments, got 3
The creation of the method like in the example did not work, because in
Python 3.6 MethodType
takes 2 arguments (not 3). In Python 2 works,
so the fix is for Python 3.6 and up.
Hello, and thanks for your contribution!
I'm a bot set up to make sure that the project can legally accept your contribution by verifying you have signed the PSF contributor agreement (CLA).
Unfortunately our records indicate you have not signed the CLA. For legal reasons we need you to sign this before we can look at your contribution. Please follow the steps outlined in the CPython devguide to rectify this issue.
Thanks again to your contribution and we look forward to looking at it!
@@ -282,7 +282,7 @@ this:: |
---|
. . . |
def __get__(self, obj, objtype=None): |
"Simulate func_descr_get() in Objects/funcobject.c" |
return types.MethodType(self, obj, objtype) |
return types.MethodType(self, obj) |
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A relic of the unbound-method days, seems it was never removed when the rest was. A relic of the unbound-method days, seems it was never removed when the rest was in the ff73795 changeset.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you want me to remove that as well? I left it because I think the signature should match __get__(self, instance, owner)
as in regular descriptors right?
btw, I did sign the CLA, please check and let me know if I need to review.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
rmariano changed the title
Descriptor HowTo: update Function.__get__ bpo-30530: Descriptor HowTo: update Function.__get__
Thanks @rmariano, and congrats on your first contribution to CPython 🎉
Mariatta pushed a commit to Mariatta/cpython that referenced this pull request
Update the code example in Functions and Methods section Remove objtype argument in MethodType (cherry picked from commit 1bced56)
Mariatta pushed a commit to Mariatta/cpython that referenced this pull request
Update the code example in Functions and Methods section Remove objtype argument in MethodType (cherry picked from commit 1bced56)
Mariatta added a commit that referenced this pull request
Update the code example in Functions and Methods section Remove objtype argument in MethodType (cherry picked from commit 1bced56)
Mariatta added a commit that referenced this pull request
Update the code example in Functions and Methods section Remove objtype argument in MethodType (cherry picked from commit 1bced56)
rmariano deleted the fix-example-method-type-descriptors-howto branch
Labels
Documentation in the Doc dir