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 2013年01月31日 10:01 by serhiy.storchaka, last changed 2022年04月11日 14:57 by admin. This issue is now closed.
| Files | ||||
|---|---|---|---|---|
| File name | Uploaded | Description | Edit | |
| pyexpat_parse_str.patch | serhiy.storchaka, 2013年01月31日 10:01 | review | ||
| Messages (2) | |||
|---|---|---|---|
| msg181014 - (view) | Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) | Date: 2013年01月31日 10:01 | |
xmlparser.Parse() works with string data only if XML encoding is utf-8 (or ascii). Examples:
>>> import xml.parsers.expat
>>> parser = xml.parsers.expat.ParserCreate()
>>> content = []
>>> parser.CharacterDataHandler = content.append
>>> parser.Parse("<?xml version='1.0' encoding='utf-8'?><tag>\xb5</tag>")
1
>>> content
['μ']
>>> parser = xml.parsers.expat.ParserCreate()
>>> content = []
>>> parser.CharacterDataHandler = content.append
>>> parser.Parse("<?xml version='1.0' encoding='iso8859'?><tag>\xb5</tag>")
1
>>> content
['Âμ']
>>> parser = xml.parsers.expat.ParserCreate()
>>> content = []
>>> parser.CharacterDataHandler = content.append
>>> parser.Parse("<?xml version='1.0' encoding='utf-16'?><tag>\xb5</tag>")
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
xml.parsers.expat.ExpatError: encoding specified in XML declaration is incorrect: line 1, column 30
This affects all other modules which works with XML: xml.sax, xml.dom.minidom, xml.dom.pulldom, xml.etree.ElementTree.
Here is a patch which fixes parsing string data with non-UTF-8 XML.
|
|||
| msg181347 - (view) | Author: Roundup Robot (python-dev) (Python triager) | Date: 2013年02月04日 16:32 | |
New changeset 3cc2a2de36e3 by Serhiy Storchaka in branch '3.2': Issue #17089: Expat parser now correctly works with string input not only when http://hg.python.org/cpython/rev/3cc2a2de36e3 New changeset 6c27b0e09c43 by Serhiy Storchaka in branch '3.3': Issue #17089: Expat parser now correctly works with string input not only when http://hg.python.org/cpython/rev/6c27b0e09c43 New changeset c4e6e560e6f5 by Serhiy Storchaka in branch 'default': Issue #17089: Expat parser now correctly works with string input not only when http://hg.python.org/cpython/rev/c4e6e560e6f5 |
|||
| History | |||
|---|---|---|---|
| Date | User | Action | Args |
| 2022年04月11日 14:57:41 | admin | set | github: 61291 |
| 2013年05月22日 18:17:25 | serhiy.storchaka | set | versions: - Python 2.7 |
| 2013年02月25日 15:41:05 | serhiy.storchaka | link | issue16986 dependencies |
| 2013年02月13日 13:46:43 | serhiy.storchaka | set | status: open -> closed resolution: fixed stage: patch review -> resolved |
| 2013年02月04日 16:32:53 | python-dev | set | nosy:
+ python-dev messages: + msg181347 |
| 2013年01月31日 10:05:47 | serhiy.storchaka | link | issue10590 dependencies |
| 2013年01月31日 10:03:46 | serhiy.storchaka | link | issue1483 dependencies |
| 2013年01月31日 10:02:57 | serhiy.storchaka | link | issue2174 dependencies |
| 2013年01月31日 10:02:24 | serhiy.storchaka | link | issue2175 dependencies |
| 2013年01月31日 10:01:19 | serhiy.storchaka | create | |