Skip to content

Commit b00e8fd

Browse files
[3.15] gh-159730: Warn that gc.get_objects() can expose objects under construction (GH-159731) (#159738)
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 625519f commit b00e8fd

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
@@ -75,6 +75,12 @@ The :mod:`!gc` module provides the following functions:
7575
returned. If *generation* is not ``None``, return only the objects tracked by
7676
the collector that are in that generation.
7777

78+
.. warning::
79+
Care must be taken when using objects returned by :func:`get_objects` because
80+
some of them could still be under construction and hence in a temporarily
81+
invalid state. Avoid using :func:`get_objects` for any purpose other than
82+
debugging.
83+
7884
.. versionchanged:: 3.8
7985
New *generation* parameter.
8086

0 commit comments

Comments
 (0)