Skip to content

Commit b40200b

Browse files
[3.14] gh-159730: Warn that gc.get_objects() can expose objects under construction (GH-159731) (#159737)
gh-159730: Warn that gc.get_objects() can expose objects under construction (GH-159731) (cherry picked from commit 42c7e26) Co-authored-by: Nathan Goldbaum <nathan.goldbaum@gmail.com>
1 parent 1907e13 commit b40200b

1 file changed

Lines changed: 6 additions & 0 deletions

File tree

‎Doc/library/gc.rst‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,12 @@ The :mod:`!gc` module provides the following functions:
7878
returned. If *generation* is not ``None``, return only the objects tracked by
7979
the collector that are in that generation.
8080

81+
.. warning::
82+
Care must be taken when using objects returned by :func:`get_objects` because
83+
some of them could still be under construction and hence in a temporarily
84+
invalid state. Avoid using :func:`get_objects` for any purpose other than
85+
debugging.
86+
8187
.. versionchanged:: 3.8
8288
New *generation* parameter.
8389

0 commit comments

Comments
 (0)