[proxy] web.archive.org← back | site home | direct (HTTPS) ↗ | proxy home | ◑ dark◐ light
/ cpython Public
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-33141: Have dataclasses.Field pass through __set_name__ to any default descriptor. #6260

Merged

Conversation

Copy link
Member

ericvsmith commented Mar 26, 2018

Copy link
Member Author

ericvsmith commented Mar 26, 2018

This is part of PEP 487 and the descriptor protocol.

ericvsmith merged commit de7a2f0 into python:master Mar 26, 2018
Copy link
Contributor

miss-islington commented Mar 26, 2018

Thanks @ericvsmith for the PR 🌮🎉.. I'm working now to backport this PR to: 3.7.
🐍🍒🤖

ericvsmith deleted the bpo-33141-descriptor-__set_name__ branch Mar 26, 2018
Copy link

bedevere-bot commented Mar 26, 2018

GH-6261 is a backport of this pull request to the 3.7 branch.

miss-islington pushed a commit to miss-islington/cpython that referenced this pull request Mar 26, 2018
…fault argument. (pythonGH-6260)

This is part of PEP 487 and the descriptor protocol.
(cherry picked from commit de7a2f0)

Co-authored-by: Eric V. Smith <ericvsmith@users.noreply.github.com>
miss-islington added a commit that referenced this pull request Mar 26, 2018
…fault argument. (GH-6260)

This is part of PEP 487 and the descriptor protocol.
(cherry picked from commit de7a2f0)

Co-authored-by: Eric V. Smith <ericvsmith@users.noreply.github.com>
# the default value, so the end result is a descriptor that had
# __set_name__ called on it at the right time.
def __set_name__(self, owner, name):
func = getattr(self.default, '__set_name__', None)
Copy link
Member

JelleZijlstra Mar 29, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I got here late, but shouldn't this check for __set_name__ on type(self.default) instead? That's how dunder protocols usually work, and it's also how typeobject.c itself implements __set_name__ (using _PyObject_LookupSpecial).

Copy link
Member Author

ericvsmith Mar 29, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch, thanks. I've created https://bugs.python.org/issue33175.

yahya-abou-imran pushed a commit to yahya-abou-imran/cpython that referenced this pull request Nov 2, 2018
…fault argument. (pythonGH-6260)

This is part of PEP 487 and the descriptor protocol.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants