ElementTree.iselement() returns true for the Element type
Chưa có ai nhận issue này.
- 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ả
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
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.
Hướng nghiên cứu
Bắt đầu với tài liệu và phần triển khai của ElementTree.iselement(), sau đó kiểm tra các PR được liên kết gh-136482 và gh-136484 cũng như các chỗ sử dụng được tham chiếu trong #135640. Được xem là hoàn tất khi xác định được nên thay đổi hành vi được tài liệu hóa hay phần triển khai, đồng thời cập nhật nhất quán hành vi hoặc tài liệu liên quan.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Đánh giá
- Công nghệ
- python
- Lĩnh vực
- api
- Loại issue
- Lỗi
- Độ khó
- 5/5
- Thời gian dự kiến
- Hơn một tuần
- Mức độ hoạt động
- Đình trệ
- Độ rõ ràng
- Cần làm rõ
- Mức phù hợp với người mới
- 20/100