https://github.com/python/cpython/commit/b00e8fd9061751a529f1d25336767c4a4706ba77
commit: b00e8fd9061751a529f1d25336767c4a4706ba77
branch: 3.15
author: Miss Islington (bot) <[email protected]>
committer: ngoldbaum <[email protected]>
date: 2026-10-19T19:31:23Z
summary:

[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 42c7e265320dd84f95b37bf0120f20d58a692fb0)

Co-authored-by: Nathan Goldbaum <[email protected]>

files:
M Doc/library/gc.rst

diff --git a/Doc/library/gc.rst b/Doc/library/gc.rst
index 65533e7e57adc3..84edd0a5b56115 100644
--- a/Doc/library/gc.rst
+++ b/Doc/library/gc.rst
@@ -75,6 +75,12 @@ The :mod:`!gc` module provides the following functions:
    returned. If *generation* is not ``None``, return only the objects tracked 
by
    the collector that are in that generation.
 
+   .. warning::
+      Care must be taken when using objects returned by :func:`get_objects` 
because
+      some of them could still be under construction and hence in a temporarily
+      invalid state. Avoid using :func:`get_objects` for any purpose other than
+      debugging.
+
    .. versionchanged:: 3.8
       New *generation* parameter.
 

_______________________________________________
Python-checkins mailing list -- [email protected]
To unsubscribe send an email to [email protected]
https://mail.python.org/mailman3//lists/python-checkins.python.org
Member address: [email protected]

Reply via email to