`ast.parse` with lower `feature_version` is still allowed to parse `lazy import os`
Aperta
@sobolevn ci sta già lavorando.
Dal 29/6/2026.
interpreter-core
topic-lazy-imports
topic-parser
type-bug
- Lingua principale
- Python
- Stelle
- 77.2k
- Fork
- 35.9k
- Metriche di merge delle PR
- Metriche PR in attesa
Descrizione
Bug report
Code:
>>> import ast
>>> ast.parse('lazy import os', feature_version=(3, 12))
Works and parses lazy import on older python versions :(
It should produce something like:
>>> import ast
>>> ast.parse('lazy import os', feature_version=(3, 12))
Traceback (most recent call last):
File "<python-input-1>", line 1, in <module>
ast.parse('lazy import os', feature_version=(3, 12))
~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/sobolev/Desktop/cpython/Lib/ast.py", line 46, in parse
return compile(source, filename, mode, flags,
_feature_version=feature_version, optimize=optimize,
module=module)
File "<unknown>", line 1
lazy import os
^
SyntaxError: Lazy imports are only supported in Python 3.15 and greater
I have a PR ready.
Linked PRs
- gh-152632
Guida per i contributori
Apri la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Valutazione
Questa issue non è ancora stata valutata.