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