Skip to content

gh-155944: Catch only expected errors in getDOMImplementation fallback - #155948

Closed
tobiaspal wants to merge 1 commit into
python:mainfrom
tobiaspal:gh-155944-domreg-fallback
Closed

gh-155944: Catch only expected errors in getDOMImplementation fallback#155948
tobiaspal wants to merge 1 commit into
python:mainfrom
tobiaspal:gh-155944-domreg-fallback

Conversation

@tobiaspal

@tobiaspal tobiaspal commented Aug 17, 2026

Copy link
Copy Markdown

Don't catch all exceptions from the well_known_implementations candidates, because only the expected ImportError and AttributeError mean the implementation is unavailable.

Found via @devdanzin's AI-assisted audit of Lib/; working on it at the PyCon Korea 2026 sprint.

In well_known_implementations the xml.dom.DOMImplementation seems to be a leftover from PyXML, so only xml.dom.minidom is used (comes from Lib/xml/dom/minidom.py):

well_known_implementations = {
'minidom':'xml.dom.minidom',
'4DOM': 'xml.dom.DOMImplementation',
}

Claude Code helped write the tests and the fix.

…allback

Don't catch all exceptions from the `well_known_implementations` candidates, because only the expected `ImportError` and `AttributeError` mean the implementation is unavailable.
@picnixz

picnixz commented Aug 17, 2026

Copy link
Copy Markdown
Member

See #155944 (comment) for rationale of closing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants