python / python/cpython

`xml.dom.domreg.getDOMImplementation`: fallback discovery masks genuine bugs, not just "not installed"

Đang mở
#155,944 2 bình luận 0 reaction 0 người được giao Xem trên GitHub

Chưa có ai nhận issue này.

pending tests type-feature
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ả

Bug report

Bug description:
  • Location: Lib/xml/dom/domreg.py:73-76

https://github.com/python/cpython/blob/cbe3a7f06a38c7fdda2d53183294499e533a3a0c/Lib/xml/dom/domreg.py#L72-L78

  • Problem: When called with no explicit implementation name, tries each well-known implementation (minidom, 4DOM) in turn under except Exception: continue (comment: "typically ImportError, or AttributeError"). A genuine bug in a candidate's getDOMImplementation() factory (e.g. a real AttributeError from a typo) is caught identically to "this implementation isn't available" and silently skipped.
  • Reproducer (verified): registered a fake well-known implementation whose getDOMImplementation() deliberately raises AttributeError to simulate a real bug (not a missing-module ImportError); the fallback loop silently moved on to minidom with no trace of the failure.
  • Suggested fix: Catch (ImportError, AttributeError) specifically, matching what the comment already says is "typical."
  • Difficulty: Trivial. Note: low real-world impact since well_known_implementations is a tiny, fixed, mostly-dead-code dict — good for a first-time contributor precisely because it's low-stakes.
CPython versions tested on:

CPython main branch

Operating systems tested on:

Linux

Linked PRs
  • gh-155948

Hướng dẫn đóng góp

Mở hướng dẫn đóng góp

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. 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.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Hướng nghiên cứu

Bắt đầu tại Lib/xml/dom/domreg.py, ở các dòng 73-76, và xem xét vòng lặp fallback được mô tả trong issue. Xác minh rằng chỉ các exception thiếu triển khai đã nêu mới bị bỏ qua, trong khi các lỗi khác vẫn hiển thị; chạy các bài kiểm thử XML DOM liên quan hoặc reproducer được cung cấp để xác nhận hành vi.

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
backend
Loại issue
Lỗi
Độ khó
1/5
Thời gian dự kiến
Dưới một giờ
Mức độ hoạt động
Đình trệ
Độ rõ ràng
Đặc tả rõ ràng
Mức phù hợp với người mới
25/100

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.