Issue 16082: xml.etree.ElementTree.tostringlist does not conform to its documentation (original) (raw)
Issue16082
Created on 2012-09-28 10:51 by einarfd, last changed 2022-04-11 14:57 by admin. This issue is now closed.
Messages (5) | ||
---|---|---|
msg171434 - (view) | Author: Einar Fløystad Dørum (einarfd) | Date: 2012-09-28 10:51 |
The tostringlist documentation says "Returns a list of (optionally) encoded strings containing the XML data. It does not guarantee any specific sequence, except that "".join(tostringlist(element)) == tostring(element).". But in reality it is possible to get tostringlist to return a string and not a list. The following code will demonstrates problem, by failing with a TypeError: from xml.etree.ElementTree import Element, tostringlist, tostring element = Element("foo") print ("".join(tostringlist(element)) == tostring(element)) | ||
msg171445 - (view) | Author: Serhiy Storchaka (serhiy.storchaka) * ![]() |
Date: 2012-09-28 12:06 |
Bug in the documentation, but not in the implementation. See also and (changeset 63845:57e631f088d7). | ||
msg172299 - (view) | Author: Eli Bendersky (eli.bendersky) * ![]() |
Date: 2012-10-07 13:22 |
Thanks for the report. I'll take a look. Patches always welcome :) | ||
msg172482 - (view) | Author: Eli Bendersky (eli.bendersky) * ![]() |
Date: 2012-10-09 14:06 |
Einar, TypeError is raised because tostring/tostringlist return bytes with the default encoding, and you can't join bytes on "" (which is unicode). | ||
msg172483 - (view) | Author: Roundup Robot (python-dev) ![]() |
Date: 2012-10-09 14:19 |
New changeset ff925e135e60 by Eli Bendersky in branch '3.3': Issue #16082: clarify the documentation of tostring[list] saying that it may generate a bytestring, depending on the given encoding. http://hg.python.org/cpython/rev/ff925e135e60 New changeset 6e407fcf7380 by Eli Bendersky in branch 'default': Merge 3.3 http://hg.python.org/cpython/rev/6e407fcf7380 |
History | |||
---|---|---|---|
Date | User | Action | Args |
2022-04-11 14:57:36 | admin | set | github: 60286 |
2012-10-09 14:19:21 | python-dev | set | status: open -> closednosy: + python-devmessages: + resolution: fixedstage: patch review -> resolved |
2012-10-09 14:06:27 | eli.bendersky | set | messages: + |
2012-10-07 13:22:56 | eli.bendersky | set | title: xml.etree.ElementTree.tostringlist does conform to it's documentation -> xml.etree.ElementTree.tostringlist does not conform to its documentationmessages: + stage: patch review |
2012-09-30 16:46:13 | ezio.melotti | set | nosy: + ezio.melotti |
2012-09-28 12:06:27 | serhiy.storchaka | set | versions: + Python 3.2nosy: + eli.bendersky, docs@python, serhiy.storchakamessages: + assignee: docs@pythoncomponents: + Documentation |
2012-09-28 10:51:26 | einarfd | create |