Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

gh-128302: fix apparent bug in xml.dom.xmlbuilder.DOMBuilder.parse() #128284

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

tungol
Copy link
Contributor

@tungol tungol commented Dec 27, 2024

This looks like a bug. The Options class has no systemId attribute, but the input parameter, which seems to be an instance of DOMInputSource, does.

I don't really know how this is meant to be used, but given this code:

from xml.dom.xmlbuilder import DOMBuilder, DOMInputSource

db = DOMBuilder()
source = DOMInputSource()
source.systemId = "http://www.w3.org/2000/svg"
print(db.parse(source))

As-is this raises an error:

  File "test.py", line 6, in <module>
    print(db.parse(source))
          ~~~~~~~~^^^^^^^^
  File "/Library/Frameworks/Python.framework/Versions/3.13/lib/python3.13/xml/dom/xmlbuilder.py", line 192, in parse
    if fp is None and options.systemId:
                      ^^^^^^^^^^^^^^^^
AttributeError: 'Options' object has no attribute 'systemId'

With this change:

<xml.dom.minidom.Document object at 0x105438f50>

I'd consider adding a test, but there's no tests right now for any of this.

@picnixz
Copy link
Contributor

picnixz commented Dec 27, 2024

Considering the fact that we use input.systemId just after, I don't know if the options class is meant to indicate "hey, you can use systemId", I think we need an issue as well and a NEWS entry.

@tungol tungol marked this pull request as draft December 27, 2024 18:55
@tungol
Copy link
Contributor Author

tungol commented Dec 27, 2024

I'll put together a more thorough analysis.

@tungol tungol changed the title fix apparent bug in xml.dom.xmlbuilder.DOMBuilder.parse() gh-128302: fix apparent bug in xml.dom.xmlbuilder.DOMBuilder.parse() Dec 28, 2024
@tungol tungol marked this pull request as ready for review December 28, 2024 00:35
@tungol
Copy link
Contributor Author

tungol commented Dec 28, 2024

Please see issue #128302 for a full write-up and analysis of what's going on here.

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