mirror of
https://github.com/python/cpython.git
synced 2025-08-04 08:59:19 +00:00
bpo-33175: dataclasses should look up __set_name__ on class, not instance (GH-6305)
This commit is contained in:
parent
b9e7fe38a0
commit
521995205a
3 changed files with 38 additions and 7 deletions
|
@ -248,11 +248,11 @@ class Field:
|
|||
# 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)
|
||||
func = getattr(type(self.default), '__set_name__', None)
|
||||
if func:
|
||||
# There is a __set_name__ method on the descriptor,
|
||||
# call it.
|
||||
func(owner, name)
|
||||
func(self.default, owner, name)
|
||||
|
||||
|
||||
class _DataclassParams:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue