classification
Title: xml.sax.xmlreader.XMLReader.getProperty (xml.sax.handler.property_xml_string) returns bytes
Type: behavior Stage: test needed
Components: XML Versions: Python 3.1
process
Status: open Resolution:
Dependencies: Superseder:
Assigned To: Nosy List: amaury.forgeotdarc, cms103, loewis
Priority: normal Keywords: patch

Created on 2009-08-11 19:19 by cms103, last changed 2010-07-20 07:11 by amaury.forgeotdarc.

Files
File name Uploaded Description Edit
expatreader.py.patch cms103, 2009-08-12 21:06 Patch to return xml.sax.handler.property_xml_string as a string rather than bytes.
expatreader.py.patch2 cms103, 2009-08-12 21:07 Patch to return xml.sax.handler.property_xml_string as a string and to provide the Locator2 interface.
Messages (5)
msg91482 - (view) Author: Colin Stewart (cms103) Date: 2009-08-11 19:19
The documentation for the xml.sax.handler.property_xml_string SAX
property states that it should be "data type: String".  However when
retrieving this value in Python 3.1 it returns a bytes object instead.

This makes handling the returned value very difficult because there is
no method for retrieving the character set encoding that the XML was
originally encoded with.

This is currently blocking the port of SimpleTAL to Python 3 achieving
feature parity with Python 2.
msg91503 - (view) Author: Martin v. Löwis (loewis) * (Python committer) Date: 2009-08-12 19:19
Would you like to contribute a patch?
msg91504 - (view) Author: Colin Stewart (cms103) Date: 2009-08-12 21:06
I'm not familiar with the inner workings of the expat integration with
Python, so the attached patches need careful review.

The first patch (expatreader.py.patch) is the minimum to resolve this
issue.  The second patch (expatreader.py.patch2) also exposes the
version and encoding parameters via the Locator2 interface
(http://www.saxproject.org/apidoc/org/xml/sax/ext/Locator2.html), which
I'd recommend including.
msg91505 - (view) Author: Colin Stewart (cms103) Date: 2009-08-12 21:07
Adding second patch.
msg110871 - (view) Author: Amaury Forgeot d'Arc (amaury.forgeotdarc) * (Python committer) Date: 2010-07-20 07:11
A unit test (or even a sample script) showing the desired feature is needed.
History
Date User Action Args
2010-07-20 07:11:34amaury.forgeotdarcsetnosy: + amaury.forgeotdarc

messages: + msg110871
stage: test needed
2009-08-12 21:07:27cms103setfiles: + expatreader.py.patch2

messages: + msg91505
2009-08-12 21:06:32cms103setfiles: + expatreader.py.patch
keywords: + patch
messages: + msg91504
2009-08-12 19:19:57loewissetnosy: + loewis
messages: + msg91503
2009-08-11 19:19:52cms103create