-
-
Notifications
You must be signed in to change notification settings - Fork 30.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
bpo-30530: Descriptor HowTo: update Function.__get__ #1845
bpo-30530: Descriptor HowTo: update Function.__get__ #1845
Conversation
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.
@rmariano, thanks for your PR! By analyzing the history of the files in this pull request, we identified @birkenfeld, @serhiy-storchaka and @rhettinger to be potential reviewers. |
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) |
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.
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.
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.
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.
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.
Do you want me to remove that as well?
You're right, it should match, it was my initial brainfart.
I did sign the CLA, please check and let me know if I need to review.
You should wait at least a day until it gets checked, see https://docs.python.org/devguide/pullrequest.html#licensing
@the-knights-who-say-ni please recheck? |
Thanks @rmariano, and congrats on your first contribution to CPython 🎉 |
Update the code example in Functions and Methods section Remove objtype argument in MethodType (cherry picked from commit 1bced56)
Update the code example in Functions and Methods section Remove objtype argument in MethodType (cherry picked from commit 1bced56)
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.