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 2015年03月12日 17:32 by François-Michel L'Heureux, last changed 2022年04月11日 14:58 by admin. This issue is now closed.
| Files | ||||
|---|---|---|---|---|
| File name | Uploaded | Description | Edit | |
| python_xml_builder_bug.py | François-Michel L'Heureux, 2015年03月12日 19:07 | Issue example | ||
| Messages (5) | |||
|---|---|---|---|
| msg237965 - (view) | Author: François-Michel L'Heureux (François-Michel L'Heureux) | Date: 2015年03月12日 17:32 | |
Using TreeBuilder to put data into XML tree. Convert that tree to a string. Parse that string. XML parser error. I expect XML library to be able to parse its own output. Reference example: https://github.com/FinchPowers/python_xml_builder_bug/blob/d98b2422d9ecadbee37e2896a5098abf82b1d7a4/python_xml_builder_bug.py |
|||
| msg237966 - (view) | Author: François-Michel L'Heureux (François-Michel L'Heureux) | Date: 2015年03月12日 17:36 | |
Note that you cannot copy paste the code and expect to reproduce the issue because it contains special characters that cannot be copy pasted via a web browser. Here is the output when run. <?xml version='1.0' encoding='utf-8'?> <top><line>2015年03月12日 09:44:54.560 script runner plugin Hello, world</line></top> Traceback (most recent call last): File "python_xml_builder_bug.py", line 17, in <module> ElementTree.fromstring(io.getvalue()) File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/xml/etree/ElementTree.py", line 1300, in XML parser.feed(text) File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/xml/etree/ElementTree.py", line 1642, in feed self._raiseerror(v) File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/xml/etree/ElementTree.py", line 1506, in _raiseerror raise err xml.etree.ElementTree.ParseError: not well-formed (invalid token): line 2, column 35 |
|||
| msg237969 - (view) | Author: R. David Murray (r.david.murray) * (Python committer) | Date: 2015年03月12日 17:56 | |
Use \x escapes to construct your example, then. |
|||
| msg237977 - (view) | Author: François-Michel L'Heureux (François-Michel L'Heureux) | Date: 2015年03月12日 19:07 | |
Updated file where copy/pasting works. |
|||
| msg237979 - (view) | Author: Ned Deily (ned.deily) * (Python committer) | Date: 2015年03月12日 19:48 | |
This is a duplicate of Issue5166. Note that in your example, you are not serializing valid XML 1.0: \x1b (ESC) is not a valid XML character, it has to be escaped and, as the discussion in Issue5166 points out, etree does not automatically do that for you. |
|||
| History | |||
|---|---|---|---|
| Date | User | Action | Args |
| 2022年04月11日 14:58:13 | admin | set | github: 67838 |
| 2015年03月12日 19:48:58 | ned.deily | set | status: open -> closed superseder: ElementTree and minidom don't prevent creation of not well-formed XML nosy: + ned.deily messages: + msg237979 resolution: duplicate stage: resolved |
| 2015年03月12日 19:07:27 | François-Michel L'Heureux | set | files:
+ python_xml_builder_bug.py messages: + msg237977 |
| 2015年03月12日 19:06:46 | François-Michel L'Heureux | set | files: - python_xml_builder_bug.py |
| 2015年03月12日 17:56:22 | r.david.murray | set | nosy:
+ r.david.murray messages: + msg237969 |
| 2015年03月12日 17:36:59 | François-Michel L'Heureux | set | messages: + msg237966 |
| 2015年03月12日 17:32:38 | François-Michel L'Heureux | set | type: behavior |
| 2015年03月12日 17:32:05 | François-Michel L'Heureux | create | |