You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
-X lazy_imports=all should not apply to exec() inside functions #149642
$ PYTHON_LAZY_IMPORTS=all ./python.exe
Python 3.16.0a0 (heads/main:fb0e0b7f898, May 10 2026, 07:19:46) [Clang 15.0.0 (clang-1500.3.9.4)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> deffunc(): import os
...
>>> func()
>>> deffunc(): exec("import os")
...
>>> func()
Traceback (most recent call last):
File "<python-input-3>", line 1, in <module>
func()
~~~~^^
File "<python-input-2>", line 1, in func
def func(): exec("import os")
~~~~^^^^^^^^^^^^^
File "<string>", line 1, in <module>
SyntaxError: 'lazy import' is only allowed at module level
>>>
Split out from #149640; this affects some tests in the test suite. PR incoming.
Activity
gh-149642: Fix interaction between exec and lazy_imports=all (#149643)
[3.15] gh-149642: Fix interaction between exec and lazy_imports=all (G…