Skip to content

Commit 62f2fcc

Browse files
committed
Clarify that sys.lazy_modules may contain extra items
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 6d2b551 commit 62f2fcc

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
@@ -1485,11 +1485,24 @@ always available. Unless explicitly noted otherwise, all variables are read-only
14851485
.. data:: lazy_modules
14861486

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

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

14941507
See also :func:`set_lazy_imports` and :pep:`810`.
14951508

0 commit comments

Comments
 (0)