gh-149321: Fix stdlib imports with lazy imports disabled#149338
gh-149321: Fix stdlib imports with lazy imports disabled#149338pablogsal merged 1 commit intopython:mainfrom
Conversation
| import abc | ||
| from reprlib import recursive_repr | ||
| lazy import copy | ||
| lazy import inspect |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
-X lazy_imports=none? #149321