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
…xists. This allows the descriptor protocol's __set_name__ to work.
|
This is part of PEP 487 and the descriptor protocol. |
|
Thanks @ericvsmith for the PR |
|
GH-6261 is a backport of this pull request to the 3.7 branch. |
…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>
| # 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) |
There was a problem 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).
There was a problem 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.
…fault argument. (pythonGH-6260) This is part of PEP 487 and the descriptor protocol.
https://bugs.python.org/issue33141