[issue15290] setAttribute() can fail

2012-07-07 Thread Antoine Pitrou

New submission from Antoine Pitrou :

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

--
components: Library (Lib)
messages: 164954
nosy: loewis, pitrou
priority: high
severity: normal
status: open
title: setAttribute() can fail
type: behavior
versions: Python 3.3

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue15290] setAttribute() can fail

2012-07-08 Thread Antoine Pitrou

Antoine Pitrou  added the comment:

Trivial reproducer:

>>> e = minidom.Element("span")
>>> e.setAttribute("class", "version")
Traceback (most recent call last):
  File "", line 1, in 
  File "/home/antoine/cpython/default/Lib/xml/dom/minidom.py", line 743, in 
setAttribute
attr.ownerDocument = self.ownerDocument
AttributeError: ownerDocument

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue15290] setAttribute() can fail

2012-07-08 Thread Antoine Pitrou

Antoine Pitrou  added the comment:

Here is a patch.

--
keywords: +patch
stage:  -> patch review
Added file: http://bugs.python.org/file26317/minidom_setattribute.patch

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue15290] setAttribute() can fail

2012-07-08 Thread Martin v . Löwis

Martin v. Löwis  added the comment:

That's invalid usage. You are supposed to create new element nodes through the 
document's createElement method. "unattached" nodes are not supported.

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue15290] setAttribute() can fail

2012-07-08 Thread Antoine Pitrou

Antoine Pitrou  added the comment:

> 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
Twisted does it.

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue15290] setAttribute() can fail

2012-07-08 Thread Martin v . Löwis

Martin v. Löwis  added the comment:

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.

--
resolution:  -> invalid
status: open -> closed

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com