python / python/cpython

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

Open
#155,944 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

pending tests type-feature
Dominant language
Python
Stars
77.2k
Forks
35.9k
PR merge metrics
PR metrics pending

Description

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

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start in Lib/xml/dom/domreg.py at lines 73-76 and review the fallback loop described in the issue. Verify that only the stated missing-implementation exceptions are skipped, while other failures remain visible; run the relevant XML DOM tests or the provided reproducer to confirm the behavior.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
backend
Issue type
Bug
Difficulty
1/5
Estimated time
Under an hour
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.