diff options
author | Eric V. Smith <ericvsmith@users.noreply.github.com> | 2018-03-20 01:07:51 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-03-20 01:07:51 (GMT) |
commit | 7389fd935c95b4b6f094312294e703ee0de18719 (patch) | |
tree | db6bb8cbf62b96d09d532d21f3bd939e1b64e8b0 /Lib/dataclasses.py | |
parent | 4573820d2a9156346392838d455e89f33067e9dd (diff) | |
download | cpython-7389fd935c95b4b6f094312294e703ee0de18719.zip cpython-7389fd935c95b4b6f094312294e703ee0de18719.tar.gz cpython-7389fd935c95b4b6f094312294e703ee0de18719.tar.bz2 |
bpo-33100: Dataclasses now handles __slots__ and default values correctly. (GH-6152)
If the class has a member that's a MemberDescriptorType, it's not a default value, it's from that member being in __slots__.
Diffstat (limited to 'Lib/dataclasses.py')
-rw-r--r-- | Lib/dataclasses.py | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/Lib/dataclasses.py b/Lib/dataclasses.py index 8ab04dd..a4afd50 100644 --- a/Lib/dataclasses.py +++ b/Lib/dataclasses.py @@ -519,6 +519,9 @@ def _get_field(cls, a_name, a_type): if isinstance(default, Field): f = default else: + if isinstance(default, types.MemberDescriptorType): + # This is a field in __slots__, so it has no default value. + default = MISSING f = field(default=default) # Assume it's a normal field until proven otherwise. |