Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

__lazy_import__ crashes with user-defined filters #144851

Copy link
Copy link
@johnslavik

Description

@johnslavik
Issue body actions

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

Reactions are currently unavailable

Metadata

Metadata

Assignees

Labels

3.15pre-release feature fixes, bugs and security fixespre-release feature fixes, bugs and security fixesinterpreter-core(Objects, Python, Grammar, and Parser dirs)(Objects, Python, Grammar, and Parser dirs)release-blockertype-crashA hard crash of the interpreter, possibly with a core dumpA hard crash of the interpreter, possibly with a core dump
No fields configured for issues without a type.

Projects

Status
Done
Show more project fields

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions

    Morty Proxy This is a proxified and sanitized view of the page, visit original site.