From: Bartosz Sławecki Date: Tue, 3 Mar 2026 16:14:12 +0000 (+0100) Subject: gh-145452: Initialize `PyLazyImport_Type` during interpreter startup (#145453) X-Git-Tag: v3.15.0a7~83 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=e6c3c04fab43057baf70b4f24b57a4679d646d84;p=thirdparty%2FPython%2Fcpython.git gh-145452: Initialize `PyLazyImport_Type` during interpreter startup (#145453) Co-authored-by: Victor Stinner --- diff --git a/Lib/test/test_lazy_import/__init__.py b/Lib/test/test_lazy_import/__init__.py index 5d30ec229978..a4180f05dbba 100644 --- a/Lib/test/test_lazy_import/__init__.py +++ b/Lib/test/test_lazy_import/__init__.py @@ -12,6 +12,7 @@ import tempfile import os from test import support +from test.support.script_helper import assert_python_ok try: import _testcapi @@ -219,6 +220,16 @@ class LazyImportTypeTests(unittest.TestCase): """LazyImportType should not be directly constructible.""" self.assertRaises(TypeError, types.LazyImportType, {}, "module") + @support.requires_subprocess() + def test_lazy_import_type_attributes_accessible(self): + """Check that static PyLazyImport_Type is initialized at startup.""" + code = textwrap.dedent(""" + lazy import json + print(globals()["json"].resolve) + """) + proc = assert_python_ok("-c", code) + self.assertIn(b"