From 4a4a3c42b163f761dfefec439f0d14b391676568 Mon Sep 17 00:00:00 2001 From: Brittany Reynoso Date: Wed, 21 Oct 2026 15:53:51 -0400 Subject: [PATCH] gh-142349: Update lazy imports C API and sys.flags documentation (GH-158966) Fix lazy imports C API and sys.flags documentation (cherry picked from commit 867d16eb02a55e57f895b6fd44913748c0619268) Co-authored-by: Brittany Reynoso --- Doc/c-api/import.rst | 3 +-- Doc/library/sys.rst | 8 ++++++++ 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/Doc/c-api/import.rst b/Doc/c-api/import.rst index 2eb8a45d299bc6c..11e795a8016a3c6 100644 --- a/Doc/c-api/import.rst +++ b/Doc/c-api/import.rst @@ -363,8 +363,7 @@ Importing Modules .. c:function:: int PyImport_SetLazyImportsMode(PyImport_LazyImportsMode mode) - Similar to :c:func:`PyImport_ImportModuleAttr`, but names are UTF-8 encoded - strings instead of Python :class:`str` objects. + Sets the current lazy imports mode. This function always returns ``0``. diff --git a/Doc/library/sys.rst b/Doc/library/sys.rst index 8a86d0f6f6c039d..2307968c0c511cb 100644 --- a/Doc/library/sys.rst +++ b/Doc/library/sys.rst @@ -652,6 +652,11 @@ always available. Unless explicitly noted otherwise, all variables are read-only - :option:`-X context_aware_warnings <-X>` and :envvar:`PYTHON_CONTEXT_AWARE_WARNINGS` + * - .. attribute:: flags.lazy_imports + - :option:`-X lazy_imports <-X>` and :envvar:`PYTHON_LAZY_IMPORTS` + (``1`` for ``all``, ``-1`` otherwise; not changed by + :func:`set_lazy_imports`) + .. versionchanged:: 3.2 Added ``quiet`` attribute for the new :option:`-q` flag. @@ -688,6 +693,9 @@ always available. Unless explicitly noted otherwise, all variables are read-only .. versionchanged:: 3.14 Added the ``context_aware_warnings`` attribute. + .. versionchanged:: 3.15 + Added the ``lazy_imports`` attribute. + .. data:: float_info