GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — gh-155944: narrow xml.dom fallback discovery to ImportError and AttributeError by shaneraphel · Pull Request #157980 · python/cpython

Conversation

@shaneraphel

@shaneraphel shaneraphel commented Sep 23, 2026 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown

Summary

  • xml.dom.domreg.getDOMImplementation() tried each well-known implementation under a bare except Exception, so a genuine bug in a candidate getDOMImplementation() factory was silently skipped exactly like a missing module.
  • The loop now catches (ImportError, AttributeError) only: a missing module or a missing factory still means "try the next one", while any other exception propagates.
  • Adds Lib/test/test_xml_domreg.py (missing module skipped, missing factory skipped, RuntimeError from a broken factory propagates, default discovery still works) and a NEWS entry.

Fixes #155944.

Test plan

  • New tests pass against the patched module (4/4), loaded directly from this tree
  • Against the unpatched module, the genuine-bug test fails with ImportError: no suitable DOM implementation found, reproducing the reported masking
  • Full test_xml_dom / CI run

Prepared with an AI assistant. I verified the 4/4 pass and the before/after difference by running the new tests against the patched and original module before opening this pull request. The author of the commit is shanyu.

  • Issue: xml.dom.domreg.getDOMImplementation: fallback discovery masks genuine bugs, not just "not installed" #155944

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@shaneraphel
pythongh-155944: narrow xml.dom fallback discovery to ImportError and…
878d243
… AttributeError.

The well-known-implementation loop caught bare Exception, so a genuine bug in a candidate factory was skipped exactly like a missing module. Only a missing module (ImportError) or a missing factory (AttributeError) now means "not available"; anything else propagates. Adds Lib/test/test_xml_domreg.py and a NEWS entry.
@python-cla-bot

python-cla-bot Bot commented Sep 23, 2026 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown

All commit authors signed the Contributor License Agreement.

CLA signed

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@bedevere-app bedevere-app Bot mentioned this pull request Sep 23, 2026
xml.dom.domreg.getDOMImplementation: fallback discovery masks genuine bugs, not just "not installed" #155944
Open
@bedevere-app bedevere-app Bot added the awaiting review label Sep 23, 2026
@StanFromIreland

StanFromIreland commented Sep 23, 2026

Copy link
Copy Markdown
Member

You need to sign the CLA before we can review.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@StanFromIreland
StanFromIreland marked this pull request as draft September 23, 2026 08:32
@bedevere-app bedevere-app Bot removed the awaiting review label Sep 23, 2026
@shaneraphel

shaneraphel commented Sep 23, 2026

Copy link
Copy Markdown
Author

Thanks for flagging this. The python-cla-bot comment above shows all commit authors have signed the CLA, so I believe that gate is green now. Let me know if anything else is needed on my side.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@picnixz

picnixz commented Sep 24, 2026

Copy link
Copy Markdown
Member

I said on the issue that a buggy implementation should rather be skipped because it may be in a state that it is actually not a good enough implementation. Now any bad implementation blocks the discovery of other good ones. This is not what I would expect.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@shaneraphel
pythongh-155944: skip a failing DOM candidate without hiding a later …
a2a7795
…one.

A factory that raises is not a good enough implementation, but it must
not stop discovery. Import and attribute failures stay "unavailable".
If nothing usable remains, the first factory failure is re-raised.
@shaneraphel

shaneraphel commented Sep 24, 2026

Copy link
Copy Markdown
Author

A failing factory is not a good enough implementation, and it should not stop the search. The loop now treats two cases differently:

  • ImportError and AttributeError still mean the candidate is not available, and the search continues.
  • Any other exception from that candidate is remembered and the search continues, so a later well-known implementation can still be returned.
  • If nothing usable is left, the first factory failure is re-raised. A lone broken candidate does not turn into a generic ImportError.

test_buggy_candidate_does_not_block_a_later_one puts a factory that raises RuntimeError ahead of minidom and checks that minidom is still returned. The five tests in test_xml_domreg passed locally.

Prepared with an AI assistant. I reviewed the change and ran the tests.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

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

Reviewers

No reviews

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

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

Uh oh!

There was an error while loading. Please reload this page.

3 participants

@shaneraphel @StanFromIreland @picnixz
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.