importlib.resources.simple ResourceContainer/ResourceHandle cannot be instantiated
未關閉
還沒有人認領這個 Issue。
stdlib
topic-importlib
type-bug
- 主要語言
- Python
- 星號
- 77.2k
- 分支
- 35.9k
- PR 合併指標
- PR 指標待擷取
描述
Bug report
Bug description:
Issue
ResourceContainer and ResourceHandle cannot be instantiated because Traversable now declares name as an abstract property. Additionally, ResourceContainer.iterdir() accesses self.reader.resources without calling it, and ResourceHandle.joinpath has a signature mismatch with the base class.
Reproducer
from importlib.resources.simple import ResourceContainer, SimpleReader
import io
class R(SimpleReader):
@property
def package(self): return 'x'
def children(self): return []
def resources(self): return []
def open_binary(self, r): return io.BytesIO(b'')
ResourceContainer(R()) # TypeError: Can't instantiate abstract class ResourceContainer
CPython versions tested on:
CPython main branch
Operating systems tested on:
No response
Linked PRs
- gh-145263
貢獻指南
從這裡開始
- 先讀完整個 Issue,再讀專案的貢獻指南。
- 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
- Fork 儲存庫,在一個分支上完成修改。
- 送出 Pull Request,並在描述裡引用這個 Issue 編號。
研究方向
從 importlib.resources.simple 開始,檢查 ResourceContainer、ResourceHandle、SimpleReader 及其與 Traversable 的關係。重現 ResourceContainer(R()) 失敗,然後確認抽象屬性、resources 存取和 joinpath 問題已修正,並由相關測試涵蓋。
由索引模型根據 Issue 內容生成。
評估
- 技術堆疊
- python
- 領域
- backend
- Issue 類型
- 缺陷
- 難度
- 3/5
- 預估耗時
- 1-2 天
- 活躍度
- 停滯
- 描述清晰度
- 基本清楚
- 新手友好度
- 20/100