bpo-32896: Fix error when subclassing a dataclass with a field that u… · python/cpython@22136c9 (original) (raw)
`@@ -574,17 +574,18 @@ def _get_field(cls, a_name, a_type):
`
574
574
``
575
575
`def _find_fields(cls):
`
576
576
`# Return a list of Field objects, in order, for this class (and no
`
577
``
`-
base classes). Fields are found from annotations (which is
`
578
``
`-
guaranteed to be ordered). Default values are from class
`
579
``
`-
attributes, if a field has a default. If the default value is
`
580
``
`-
a Field(), then it contains additional info beyond (and
`
581
``
`-
possibly including) the actual default value. Pseudo-fields
`
582
``
`-
ClassVars and InitVars are included, despite the fact that
`
583
``
`-
they're not real fields. That's dealt with later.
`
584
``
-
585
``
`-
annotations = getattr(cls, 'annotations', {})
`
586
``
`-
return [_get_field(cls, a_name, a_type)
`
587
``
`-
for a_name, a_type in annotations.items()]
`
``
577
`+
base classes). Fields are found from the class dict's
`
``
578
`+
annotations (which is guaranteed to be ordered). Default
`
``
579
`+
values are from class attributes, if a field has a default. If
`
``
580
`+
the default value is a Field(), then it contains additional
`
``
581
`+
info beyond (and possibly including) the actual default value.
`
``
582
`+
Pseudo-fields ClassVars and InitVars are included, despite the
`
``
583
`+
fact that they're not real fields. That's dealt with later.
`
``
584
+
``
585
`+
If annotations isn't present, then this class adds no new
`
``
586
`+
annotations.
`
``
587
`+
annotations = cls.dict.get('annotations', {})
`
``
588
`+
return [_get_field(cls, name, type) for name, type in annotations.items()]
`
588
589
``
589
590
``
590
591
`def _set_new_attribute(cls, name, value):
`