Skip to content

Commit 42c7e26

Browse files
authored
gh-159730: Warn that gc.get_objects() can expose objects under construction (#159731)
1 parent 2dd5315 commit 42c7e26

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)