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
At runtime, types.LazyImportType is an uninitialized static type (unless you e.g. access types.LazyImportType.resolve first).
This can lead to funky behaviors:
lazyimportwave, tracebacktry:
help(globals()['wave'].resolve) # However, a call ".resolve()" would workexceptAttributeErrorase:
print(e) # 'lazy_import' object has no attribute 'resolve'try:
help(globals()['wave'].resolve)
exceptAttributeError:
# traceback.format_exc() initializes types.LazyImportType as a side effect.# This prints "AttributeError: 'lazy_import' object has no attribute 'resolve'".print(traceback.format_exc().splitlines()[-1])
print(globals()['wave'].resolve) # Succeeds.
The solution I found is to add &PyLazyImport_Type to static_types[], the array of types initialized in _PyTypes_InitTypes during interpreter startup.
Activity
johnslavik commentedon Mar 3, 2026
cc @Yhg1s @DinoV @pablogsal @ZeroIntensity @vstinner @serhiy-storchaka
gh-145452: Initialize `PyLazyImport_Type` during interpreter startup (#…
pythongh-145452: Initialize `PyLazyImport_Type` during interpreter st…