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

gh-149321: Fix stdlib imports with lazy imports disabled#149338

Merged
pablogsal merged 1 commit into
python:mainpython/cpython:mainfrom
pablogsal:gh-149321-lazy-imports-nonepablogsal/cpython:gh-149321-lazy-imports-noneCopy head branch name to clipboard
May 4, 2026
Merged

gh-149321: Fix stdlib imports with lazy imports disabled#149338
pablogsal merged 1 commit into
python:mainpython/cpython:mainfrom
pablogsal:gh-149321-lazy-imports-nonepablogsal/cpython:gh-149321-lazy-imports-noneCopy head branch name to clipboard

Conversation

@pablogsal
Copy link
Copy Markdown
Member

@pablogsal pablogsal commented May 3, 2026

Comment thread Lib/dataclasses.py
import abc
from reprlib import recursive_repr
lazy import copy
lazy import inspect
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am surprised that this is needed. Up until very recently, inspect was imported eagerly in dataclasses. Isn't the issue with importing dataclasses fixed by the ast change alone?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IIRC the ast change fixes one cycle, but not all of them. If I restore the top-level lazy import inspect in dataclasses, import dataclasses still fails under -X azy_imports=none via: dataclasses -> inspect -> tokenize -> _colorize -> dataclasses

So the inspect move is specifically about avoiding import-time resolution of the lazy inspect import when lazy imports are disabled. The failure is reproducible with a direct import dataclasses, and the stdlib import subprocess test catches it as well.

@pablogsal pablogsal merged commit 12a20da into python:main May 4, 2026
60 checks passed
@pablogsal pablogsal deleted the gh-149321-lazy-imports-none branch May 4, 2026 18:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants

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