ElementTree.iselement() returns true for the Element type
未关闭
还没有人认领这个 Issue。
stdlib
topic-XML
type-bug
- 主要语言
- Python
- 星标
- 77.2k
- 派生
- 35.9k
- PR 合并指标
- PR 指标待抓取
描述
According to documentation, ElementTree.iselement() check if the argument is an element object.
But it returns true also for the Element type which has all attributes of an Element instance. The way how the Element class is defined in Python suggests that this may be intentional, but the intention was lost in the documentation.
There is also an example of dataclasses.is_dataclass() which returns true both for a dataclass type and for a dataclass instance.
So, there are two ways:
- Fix the documentation to match the current behavior. All uses of
iselement()(see #135640) should also check if the argument is a type is they need an element object. - Fix the implementation to check if the argument is a type. This may break the user code that uses it to check for the Element type (I don't know if it exists) but may fix bugs in the user code which expects that
iselement()works as documented.
cc @scoder
Linked PRs
- gh-136482
- gh-136484
贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
调研方向
从 ElementTree.iselement() 的文档和实现开始,然后检查相关的 PR gh-136482 和 gh-136484,以及 #135640 中引用的使用处。完成的标准是确定应当修改文档所述的行为还是实现,并一致地更新相关行为或文档。
由索引模型根据 Issue 内容生成。
评估
- 技术栈
- python
- 领域
- api
- Issue 类型
- 缺陷
- 难度
- 5/5
- 预计耗时
- 一周以上
- 活跃度
- 停滞
- 描述清晰度
- 需要澄清
- 新手友好度
- 20/100