From accc0c8315dc53a639748b2dcd6094c3300eeb08 Mon Sep 17 00:00:00 2001 From: "Miss Islington (bot)" <31488909+miss-islington@users.noreply.github.com> Date: Wed, 3 Jun 2026 10:36:50 +0200 Subject: [PATCH] [3.15] gh-148587: Document `sys.lazy_modules` (GH-150742) MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit (cherry picked from commit e3fa52d953492772d36f5a4397262483bcf67641) Co-authored-by: Bartosz Sławecki --- Doc/library/sys.rst | 15 +++++++++++++++ Misc/NEWS.d/3.15.0a8.rst | 2 +- Misc/NEWS.d/3.15.0b2.rst | 2 +- 3 files changed, 17 insertions(+), 2 deletions(-) diff --git a/Doc/library/sys.rst b/Doc/library/sys.rst index 6946eb6eeaa5..4683fc03f843 100644 --- a/Doc/library/sys.rst +++ b/Doc/library/sys.rst @@ -1483,6 +1483,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 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:: 3.15 + + .. data:: maxsize An integer giving the maximum value a variable of type :c:type:`Py_ssize_t` can diff --git a/Misc/NEWS.d/3.15.0a8.rst b/Misc/NEWS.d/3.15.0a8.rst index ff7930aeb292..3c6da8b6ab48 100644 --- a/Misc/NEWS.d/3.15.0a8.rst +++ b/Misc/NEWS.d/3.15.0a8.rst @@ -350,7 +350,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/3.15.0b2.rst b/Misc/NEWS.d/3.15.0b2.rst index 24fef1907d51..afbdd4e072ed 100644 --- a/Misc/NEWS.d/3.15.0b2.rst +++ b/Misc/NEWS.d/3.15.0b2.rst @@ -132,7 +132,7 @@ function call. .. nonce: -RD3z5 .. section: Core and Builtins -``sys.lazy_modules`` is now a set instead of a dict as initially spelled out +:py:attr:`sys.lazy_modules` is now a set instead of a dict as initially spelled out in PEP 810. .. -- 2.47.3