[issue45135] dataclasses.asdict() incorrectly calls __deepcopy__() on values.

Thomas Fischbacher report at bugs.python.org
Wed Sep 8 13:39:37 EDT 2021


Thomas Fischbacher <tfish at google.com> added the comment:

The current behavior deviates from the documentation in a way that might evade tests and hence has the potential to cause production outages.

Is there a way to fix the documentation so that it correctly describes current behavior - without having to wait for a new release? Eliminating the risk in such a way would be highly appreciated.

In the longer run, there may be some value in having a differently named method (perhaps .as_dict()?) that basically returns
{k: v for k, v in self.__dict__.items()}, but without going through reflection? The current approach to recurse looks as if it were based on quite a few doubtful assumptions.

(Context: some style guides, such as Google's Python style guide,
limit the use of reflection in order to keep some overall undesirable processes in check: https://google.github.io/styleguide/pyguide.html#2191-definition)

----------

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue45135>
_______________________________________


More information about the Python-bugs-list mailing list