From d3085cd9a58acac9e79e09c86787839ca8c9aa42 Mon Sep 17 00:00:00 2001 From: johnslavik Date: Tue, 2 Jun 2026 01:34:56 +0200 Subject: [PATCH 1/4] Document sys.lazy_modules --- Doc/library/sys.rst | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/Doc/library/sys.rst b/Doc/library/sys.rst index 6a4314f1098609d..a48c9236ea562b4 100644 --- a/Doc/library/sys.rst +++ b/Doc/library/sys.rst @@ -1481,6 +1481,21 @@ always available. Unless explicitly noted otherwise, all variables are read-only They hold the legacy representation of ``sys.last_exc``, as returned from :func:`exc_info` above. + +.. data:: lazy_modules + + A :class:`set` of fully-qualified module name strings that have been lazily + imported in the current interpreter but not yet reified (loaded). When a + lazily-imported module is accessed for the first time, its name is removed + from this set. + + This attribute is intended for debugging and introspection. + + See also :func:`set_lazy_imports` and :pep:`810`. + + .. versionadded:: next + + .. data:: maxsize An integer giving the maximum value a variable of type :c:type:`Py_ssize_t` can From e0b5af4f05be3f51378a8d9c1af2fba38ce4afd1 Mon Sep 17 00:00:00 2001 From: johnslavik Date: Tue, 2 Jun 2026 01:39:57 +0200 Subject: [PATCH 2/4] Fix cross-refs --- Misc/NEWS.d/3.15.0a8.rst | 2 +- .../2026-05-18-18-36-28.gh-issue-148587.-RD3z5.rst | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Misc/NEWS.d/3.15.0a8.rst b/Misc/NEWS.d/3.15.0a8.rst index eceb9257672c158..28e9ca85166620f 100644 --- a/Misc/NEWS.d/3.15.0a8.rst +++ b/Misc/NEWS.d/3.15.0a8.rst @@ -340,7 +340,7 @@ Fix :func:`repr` for lists and tuples containing ``NULL``\ s. .. nonce: aB3xKm .. section: Core and Builtins -Fixed ``sys.lazy_modules`` to include lazy modules without submodules. Patch +Fixed :py:attr:`sys.lazy_modules` to include lazy modules without submodules. Patch by Bartosz Sławecki. .. diff --git a/Misc/NEWS.d/next/Core_and_Builtins/2026-05-18-18-36-28.gh-issue-148587.-RD3z5.rst b/Misc/NEWS.d/next/Core_and_Builtins/2026-05-18-18-36-28.gh-issue-148587.-RD3z5.rst index 61bfdcdd37362cd..d623dbdd75f0c8e 100644 --- a/Misc/NEWS.d/next/Core_and_Builtins/2026-05-18-18-36-28.gh-issue-148587.-RD3z5.rst +++ b/Misc/NEWS.d/next/Core_and_Builtins/2026-05-18-18-36-28.gh-issue-148587.-RD3z5.rst @@ -1 +1 @@ -``sys.lazy_modules`` is now a set instead of a dict as initially spelled out in PEP 810. +:py:attr:`sys.lazy_modules` is now a set instead of a dict as initially spelled out in PEP 810. From 090a01b5e65445b25d7c4e2018be70b2e8a9f16a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bartosz=20S=C5=82awecki?= Date: Tue, 2 Jun 2026 12:27:26 +0200 Subject: [PATCH 3/4] Apply suggestions from code review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Stan Ulbrych Co-authored-by: Hugo van Kemenade <1324225+hugovk@users.noreply.github.com> Co-authored-by: Bartosz Sławecki --- Doc/library/sys.rst | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Doc/library/sys.rst b/Doc/library/sys.rst index a48c9236ea562b4..7b1ad841dacd766 100644 --- a/Doc/library/sys.rst +++ b/Doc/library/sys.rst @@ -1485,8 +1485,8 @@ 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 reified (loaded). When a - lazily-imported module is accessed for the first time, its name is removed + 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. This attribute is intended for debugging and introspection. From 0baf5b149a30f88dfc88b8a0a6bc694a314b66e0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bartosz=20S=C5=82awecki?= Date: Tue, 2 Jun 2026 13:48:26 +0200 Subject: [PATCH 4/4] Apply suggestions from code review Co-authored-by: Stan Ulbrych --- Doc/library/sys.rst | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Doc/library/sys.rst b/Doc/library/sys.rst index 7b1ad841dacd766..d0fe0625deb5133 100644 --- a/Doc/library/sys.rst +++ b/Doc/library/sys.rst @@ -1484,7 +1484,7 @@ 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 + 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. @@ -1493,7 +1493,7 @@ always available. Unless explicitly noted otherwise, all variables are read-only See also :func:`set_lazy_imports` and :pep:`810`. - .. versionadded:: next + .. versionadded:: 3.15 .. data:: maxsize