SIGN IN SIGN UP

bpo-44649: Fix dataclasses(slots=True) with a field with a default, but init=False (GH-29692)

Special handling is needed, because for non-slots dataclasses the instance attributes are not set: reading from a field just references the class's attribute of the same name, which contains the default value. But this doesn't work for classes using __slots__: they don't read the class's attribute. So in that case (and that case only), initialize the instance attribute. Handle this for both normal defaults, and for fields using default_factory.
E
Eric V. Smith committed
d3062f672c92855b7e9e962ad4bf1a67abd4589b
Parent: 5b946ca
Committed by GitHub <noreply@github.com> on 11/22/2021, 1:26:12 PM