This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author bersace
Recipients bersace
Date 2010-10-26.19:40:47
SpamBayes Score 0.0011794079
Marked as misclassified No
Message-id <1288122049.66.0.916624044666.issue10205@psf.upfronthosting.co.za>
In-reply-to
Content
Hi,

Here is the code to reproduce and the unexcpected behaviour :

21:37:41 bersace@st-francois-de-sales:~/Bureau/$ cat bug.py 
from xml.etree.ElementTree import QName, ElementTree, Element, SubElement
import sys

head = Element(QName('http://www.w3.org/1999/xhtml', 'html'))
SubElement(head, QName('http://www.w3.org/1999/xhtml', 'meta'))
SubElement(head, QName('http://www.w3.org/1999/xhtml', 'meta'))

tree = ElementTree(head)
tree.write(sys.stdout, encoding="utf-8", xml_declaration=True,
           default_namespace='http://www.w3.org/1999/xhtml')
21:38:00 bersace@st-francois-de-sales:~/Bureau/$ python2.7 bug.py 
<?xml version='1.0' encoding='utf-8'?>
Traceback (most recent call last):
  File "bug.py", line 10, in <module>
    default_namespace='http://www.w3.org/1999/xhtml')
  File "/usr/lib/python2.7/xml/etree/ElementTree.py", line 812, in write
    self._root, encoding, default_namespace
  File "/usr/lib/python2.7/xml/etree/ElementTree.py", line 880, in _namespaces
    _raise_serialization_error(tag)
  File "/usr/lib/python2.7/xml/etree/ElementTree.py", line 1046, in _raise_serialization_error
    "cannot serialize %r (type %s)" % (text, type(text).__name__)
TypeError: cannot serialize <xml.etree.ElementTree.QName object at 0xb76aa60c> (type QName)
21:38:01 bersace@st-francois-de-sales:~/Bureau/$ 

Patch is attached.

Regards,
Étienne
History
Date User Action Args
2010-10-26 19:40:49bersacesetrecipients: + bersace
2010-10-26 19:40:49bersacesetmessageid: <1288122049.66.0.916624044666.issue10205@psf.upfronthosting.co.za>
2010-10-26 19:40:48bersacelinkissue10205 messages
2010-10-26 19:40:47bersacecreate