Skip to content

__lazy_import__ crashes with user-defined filters #144851

Description

@johnslavik

Crash report

Bug description:

This crashes from an assertion error, only when __lazy_import__ is called directly:

import sys

def li_filter(importing_module: str, imported_module: str, fromlist: tuple[str, ...]) -> bool:
    return False

sys.set_lazy_imports_filter(li_filter)

__lazy_import__('wave')

Moved from LazyImportsCabal#45 (couldn't have transferred it).

The compiler would always put a LOAD_CONST (None) before any IMPORT_NAME for imports without from, which is why this crash never happens in a regular lazy import.

CPython versions tested on:

CPython main branch

Operating systems tested on:

No response

Linked PRs

Activity

  1. added
    interpreter-core(Objects, Python, Grammar, and Parser dirs)
    type-crashA hard crash of the interpreter, possibly with a core dump
    on Feb 15, 2026
  2. self-assigned this
    on Feb 15, 2026
  3. johnslavik commented on Mar 1, 2026

    @johnslavik
    MemberAuthor

    This hard crashes (segfaults) in the release build, so I'm marking this as a release blocker.

  4. johnslavik commented on Mar 1, 2026

    @johnslavik
    MemberAuthor
  5. added a commit that references this issue on Mar 2, 2026
  6. johnslavik commented on Mar 2, 2026

    @johnslavik
    MemberAuthor

    Thanks @Yhg1s for the quick review!

  7. added a commit that references this issue on Apr 25, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

3.15bugs and security fixesinterpreter-core(Objects, Python, Grammar, and Parser dirs)release-blockertype-crashA hard crash of the interpreter, possibly with a core dump

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions