https://github.com/python/cpython/commit/0ca288a8cec08f04314d2b320549cf8ae299419c commit: 0ca288a8cec08f04314d2b320549cf8ae299419c branch: 3.15 author: Miss Islington (bot) <[email protected]> committer: hugovk <[email protected]> date: 2026-09-04T15:29:34+01:00 summary:
[3.15] gh-142349: Clarify that sys.lazy_modules may contain extra items (GH-155547) (#156934) gh-142349: Clarify that sys.lazy_modules may contain extra items (GH-155547) As an author of a debugging/introspection tool, I need an honest description of what's in `lazy_modules` and what kind of post-processing I'm expected to do. (cherry picked from commit 2632610ec19123f7fb85effd632775011f92ab35) Co-authored-by: Petr Viktorin <[email protected]> files: M Doc/library/sys.rst diff --git a/Doc/library/sys.rst b/Doc/library/sys.rst index e4ddc3a0e5a34f..82e8af611a6550 100644 --- a/Doc/library/sys.rst +++ b/Doc/library/sys.rst @@ -1485,11 +1485,24 @@ always available. Unless explicitly noted otherwise, all variables are read-only .. data:: lazy_modules A :class:`set` of fully qualified module name strings that have been lazily - imported in the current interpreter but not yet loaded. When a - lazily imported module is accessed for the first time, its name is removed - from this set. + imported in the current interpreter but not yet loaded. + When a lazily imported module is accessed for the first time, its name is + typically removed from this set. - This attribute is intended for debugging and introspection. + The set may contain some additional strings. + It is intended for debugging and introspection, and consumers are expected + to verify each entry's status. + + .. impl-detail:: + + Currently, :data:`!lazy_modules` may also contain: + + * names of *attributes* (non-modules), such as ``"pathlib.Path"`` after + running ``lazy from pathlib import Path``, and + * names of items than have already been accessed. + + In future versions of Python, these may be removed, and/or additional + extras may be added. See also :func:`set_lazy_imports` and :pep:`810`. _______________________________________________ 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]
