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

class Entry doesn't work when etree = xml.etree : __str__ #1

Open
richard-jones opened this issue Apr 24, 2012 · 1 comment
Open

class Entry doesn't work when etree = xml.etree : __str__ #1

richard-jones opened this issue Apr 24, 2012 · 1 comment

Comments

@richard-jones
Copy link
Contributor

[Migrated from bitbucket https://bitbucket.org/richardjones/python-sword2/issue/2/class-entry-doesnt-work-when-etree]

Entry.str fails when trying to serialise the namespace map (self.nsmap):

File "sword2/atom_objects.py", line 250, in str xml_str = etree.tostring(self.entry) File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/xml/etree/ElementTree.py", line 1121, in tostring ElementTree(element).write(file, encoding, method=method) File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/xml/etree/ElementTree.py", line 815, in write serialize(write, self._root, encoding, qnames, namespaces) File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/xml/etree/ElementTree.py", line 934, in _serialize_xml _serialize_xml(write, e, encoding, qnames, None) File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/xml/etree/ElementTree.py", line 927, in _serialize_xml v = _escape_attrib(v, encoding) File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/xml/etree/ElementTree.py", line 1087, in _escape_attrib _raise_serialization_error(text) File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/xml/etree/ElementTree.py", line 1047, in _raise_serialization_error "cannot serialize %r (type %s)" % (text, type(text).name) TypeError: cannot serialize {'dcterms': 'http://purl.org/dc/terms/', 'atom': 'http://www.w3.org/2005/Atom'} (type dict)

@gmh04
Copy link

gmh04 commented Jun 5, 2013

For anyone coming across this issue, simply install lxml.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants