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
setAttribute() can fail #59495
Comments
This is a regression from 3.2: Traceback (most recent call last):
File "/home/antoine/3sted/twisted/lore/test/test_lore.py", line 542, in test_setTitle
secondTitle.setAttribute('class', 'title')
File "/home/antoine/opt/lib/python3.3/xml/dom/minidom.py", line 743, in setAttribute
attr.ownerDocument = self.ownerDocument
builtins.AttributeError: ownerDocument |
Trivial reproducer: >>> e = minidom.Element("span")
>>> e.setAttribute("class", "version")
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/home/antoine/cpython/default/Lib/xml/dom/minidom.py", line 743, in setAttribute
attr.ownerDocument = self.ownerDocument
AttributeError: ownerDocument |
Here is a patch. |
That's invalid usage. You are supposed to create new element nodes through the document's createElement method. "unattached" nodes are not supported. |
Well, I don't know how many third-party application rely on this, but |
Then Twisted will have to change. From http://docs.python.org/library/xml.dom.minidom.html "Applications should not instantiate the classes themselves; they should use the creator functions available on the Document object." If they insist on not using createElement, they use internal API, and need to adjust that to new Python versions. Closing as invalid. |
Same issue was brought up in http://bugs.python.org/issue4851 |
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
bugs.python.org fields:
The text was updated successfully, but these errors were encountered: