Skip to content
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

Merged

Conversation

rmariano
Copy link
Contributor

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.
@mention-bot
Copy link

@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.

@the-knights-who-say-ni
Copy link

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)
Copy link
Contributor

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.

Copy link
Contributor Author

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.

Copy link
Contributor

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

@Mariatta Mariatta added needs backport to 3.5 docs Documentation in the Doc dir labels May 29, 2017
@rmariano
Copy link
Contributor Author

@the-knights-who-say-ni please recheck?
@Mariatta FYI :)

@rmariano rmariano changed the title Descriptor HowTo: update Function.__get__ bpo-30530: Descriptor HowTo: update Function.__get__ May 31, 2017
@rhettinger rhettinger self-assigned this Jun 2, 2017
@Mariatta Mariatta merged commit 1bced56 into python:master Jun 5, 2017
@Mariatta
Copy link
Member

Mariatta commented Jun 5, 2017

Thanks @rmariano, and congrats on your first contribution to CPython 🎉

Mariatta pushed a commit to Mariatta/cpython that referenced this pull request Jun 5, 2017
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 Jun 5, 2017
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 Jun 5, 2017
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 Jun 5, 2017
Update the code example in Functions and Methods section
Remove objtype argument in MethodType
(cherry picked from commit 1bced56)
@rmariano rmariano deleted the fix-example-method-type-descriptors-howto branch June 5, 2017 09:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
docs Documentation in the Doc dir
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants