If the value set for a field default is callable, it is called when the default is used. Else, the default value is effectively set to lambda: copy.deepcopy(<default>).
Calling copy.deepcopy on some values may have unexpected results, including a frame overflow if the object is recursively nested.
Desired Behavior
If the value set for a field default is callable, it is called when the default is used.
If the value is mutable, TypeError should be raised with a useful message.
Else, the default object should be used directly.
Current Behavior
If the value set for a field default is callable, it is called when the default is used. Else, the default value is effectively set to
lambda: copy.deepcopy(<default>)
.Calling
copy.deepcopy
on some values may have unexpected results, including a frame overflow if the object is recursively nested.Desired Behavior
If the value set for a field default is callable, it is called when the default is used. If the value is mutable,
TypeError
should be raised with a useful message. Else, the default object should be used directly.