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)
|