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.
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) * (Python committer) | Date: 2012年09月28日 12:06 | |
Bug in the documentation, but not in the implementation. See also issue8047 and issue1767933 (changeset 63845:57e631f088d7). |
|||
| msg172299 - (view) | Author: Eli Bendersky (eli.bendersky) * (Python committer) | 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) * (Python committer) | 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) (Python triager) | 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 -> closed nosy: + python-dev messages: + msg172483 resolution: fixed stage: patch review -> resolved |
| 2012年10月09日 14:06:27 | eli.bendersky | set | messages: + msg172482 |
| 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 documentation messages: + msg172299 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.2 nosy: + eli.bendersky, docs@python, serhiy.storchaka messages: + msg171445 assignee: docs@python components: + Documentation |
| 2012年09月28日 10:51:26 | einarfd | create | |