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
Imports in a finally or else clause are lazy under __lazy_modules__ #162573
The docs say "Imports inside functions, class bodies, or try/except/finally blocks are always eager, regardless of __lazy_modules__" (Compatibility via __lazy_modules__), and lazy import in a finally or else clause is a SyntaxError ("lazy import not allowed inside try/except blocks"). Imports in the try and except bodies are eager, but one in the finally clause, on the normal path, or in the else clause of a try without finally is lazy:
I expected module module. The normal-path copy of the finally body (codegen_try_finally in Python/codegen.c) and the else body are compiled outside the fblocks that _PyCompile_InExceptionHandler checks. I found it while writing a Lean spec of Python.
Activity