`ast.parse` with lower `feature_version` is still allowed to parse `lazy import os`
Đang mở
@sobolevn đang làm issue này rồi.
Từ ngày 29/6/2026.
interpreter-core
topic-lazy-imports
topic-parser
type-bug
- Ngôn ngữ chính
- Python
- Star
- 77.2k
- Fork
- 35.9k
- Chỉ số merge pull request
- Chỉ số pull request đang chờ
Mô tả
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
Hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Đánh giá
Issue này chưa được đánh giá.