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.

classification
Title: xml.sax.expatreader doesn't pass encoding to ParserCreate
Type: Stage:
Components: XML Versions:
process
Status: closed Resolution: accepted
Dependencies: Superseder:
Assigned To: akuchling Nosy List: akuchling, sambayer
Priority: normal Keywords:

Created on 2005-09-02 22:14 by sambayer, last changed 2022-04-11 14:56 by admin. This issue is now closed.

Messages (2)
msg26185 - (view) Author: Samuel Bayer (sambayer) Date: 2005-09-02 22:14
The ParserCreate function in the expat module accepts an encoding 
argument, presumably for use when the encoding is not provided in 
the XML document. This function is invoked by the reset() method of 
the ExpatParser class in xml.sax.expatreader. The encoding, if 
provided, is available from the InputSource object stored in the 
self._source variable, but the value is not passed along to 
ParserCreate. This bug is present in Python 2.4.1.

I believe the correct fix is to change lines 246 and 247 in Lib/xml/
sax/expatreader.py from

            self._parser = expat.ParserCreate(None, " ",
                                              intern=self._interning)

to

            self._parser = expat.ParserCreate(self._source.getEncoding
(),  " ",
                                              intern=self._interning)

and line 252 from 

            self._parser = expat.ParserCreate(intern = self._interning)

to

            self._parser = expat.ParserCreate(self._source.getEncoding
(), intern = self._interning)
msg26186 - (view) Author: A.M. Kuchling (akuchling) * (Python committer) Date: 2005-12-04 19:54
Logged In: YES 
user_id=11375

Suggested change applied to rev41597; thanks!
History
Date User Action Args
2022-04-11 14:56:12adminsetgithub: 42334
2005-09-02 22:14:52sambayercreate