Import of submodule shadowing parent module attribute fails under lazy_imports mode
未關閉
還沒有人認領這個 Issue。
interpreter-core
topic-lazy-imports
type-bug
- 主要語言
- Python
- 星號
- 77.2k
- 分支
- 36k
- PR 合併指標
- PR 指標待擷取
描述
Bug report
Bug description:
For this module structure:
└─ a/
├─ __init__.py # Contains a function foo()
└─ foo.py
This script passes on 3.14...
from a import foo
import a.foo
import types
assert isinstance(a.foo, types.ModuleType), type(a.foo)
And fails on 3.15 with lazy imports (python3.15 -X lazy_imports=all script.py):
Traceback (most recent call last):
File "/Users/jwalls/script.py", line 4, in <module>
assert isinstance(a.foo, types.ModuleType), type(a.foo)
~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^
AssertionError: <class 'function'>
CPython versions tested on:
3.15
Operating systems tested on:
macOS
貢獻指南
從這裡開始
- 先讀完整個 Issue,再讀專案的貢獻指南。
- 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
- Fork 儲存庫,在一個分支上完成修改。
- 送出 Pull Request,並在描述裡引用這個 Issue 編號。
研究方向
首先使用 Python 3.15 和 -X lazy_imports=all 執行提供的 module-layout 腳本,然後檢查解析一個遮蔽 parent 屬性的子模組時所涉及的延遲匯入處理。完成標準是 assertion 對 a.foo 看到一個 ModuleType,與 Python 3.14 中的行為一致。
由索引模型根據 Issue 內容生成。
評估
- 技術堆疊
- python
- 領域
- backend
- Issue 類型
- 缺陷
- 難度
- 4/5
- 預估耗時
- 3-5 天
- 活躍度
- 冷清
- 描述清晰度
- 基本清楚
- 新手友好度
- 55/100