]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
gh-88071: Update docstrings of dataclass' astuple and asdict (#101806)
authorIlya V. Schurov <ilya@schurov.com>
Sat, 11 Mar 2023 00:27:41 +0000 (01:27 +0100)
committerGitHub <noreply@github.com>
Sat, 11 Mar 2023 00:27:41 +0000 (17:27 -0700)
Update dataclasses.astuple and dataclasses.asdict docstrings to reflect that they deep copy objects in the field values.

Lib/dataclasses.py

index 24f3779ebb8ec8e7ae2a563d92e45cbaeec5e319..f4617b1dbdac669473d348d06df08df68c27bf99 100644 (file)
@@ -1281,7 +1281,7 @@ def asdict(obj, *, dict_factory=dict):
     If given, 'dict_factory' will be used instead of built-in dict.
     The function applies recursively to field values that are
     dataclass instances. This will also look into built-in containers:
-    tuples, lists, and dicts.
+    tuples, lists, and dicts. Other objects are copied with 'copy.deepcopy()'.
     """
     if not _is_dataclass_instance(obj):
         raise TypeError("asdict() should be called on dataclass instances")
@@ -1353,7 +1353,7 @@ def astuple(obj, *, tuple_factory=tuple):
     If given, 'tuple_factory' will be used instead of built-in tuple.
     The function applies recursively to field values that are
     dataclass instances. This will also look into built-in containers:
-    tuples, lists, and dicts.
+    tuples, lists, and dicts. Other objects are copied with 'copy.deepcopy()'.
     """
 
     if not _is_dataclass_instance(obj):