Skip to content

Commit 2632610

Browse files
authored
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.
1 parent 59a6913 commit 2632610

1 file changed

Lines changed: 17 additions & 4 deletions

File tree

Doc/library/sys.rst

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1488,11 +1488,24 @@ always available. Unless explicitly noted otherwise, all variables are read-only
14881488
.. data:: lazy_modules
14891489

14901490
A :class:`set` of fully qualified module name strings that have been lazily
1491-
imported in the current interpreter but not yet loaded. When a
1492-
lazily imported module is accessed for the first time, its name is removed
1493-
from this set.
1491+
imported in the current interpreter but not yet loaded.
1492+
When a lazily imported module is accessed for the first time, its name is
1493+
typically removed from this set.
14941494

1495-
This attribute is intended for debugging and introspection.
1495+
The set may contain some additional strings.
1496+
It is intended for debugging and introspection, and consumers are expected
1497+
to verify each entry's status.
1498+
1499+
.. impl-detail::
1500+
1501+
Currently, :data:`!lazy_modules` may also contain:
1502+
1503+
* names of *attributes* (non-modules), such as ``"pathlib.Path"`` after
1504+
running ``lazy from pathlib import Path``, and
1505+
* names of items than have already been accessed.
1506+
1507+
In future versions of Python, these may be removed, and/or additional
1508+
extras may be added.
14961509

14971510
See also :func:`set_lazy_imports` and :pep:`810`.
14981511

0 commit comments

Comments
 (0)