[ python-Bugs-1281032 ] xml.sax.expatreader doesn't pass encoding to ParserCreate

SourceForge.net noreply at sourceforge.net
Sun Dec 4 20:54:39 CET 2005


Bugs item #1281032, was opened at 2005-09-02 18:14
Message generated for change (Comment added) made by akuchling
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1281032&group_id=5470

Please note that this message will contain a full copy of the comment thread,
including the initial issue submission, for this request,
not just the latest update.
Category: XML
Group: None
>Status: Closed
>Resolution: Accepted
Priority: 5
Submitted By: Samuel Bayer (sambayer)
>Assigned to: A.M. Kuchling (akuchling)
Summary: xml.sax.expatreader doesn't pass encoding to ParserCreate

Initial Comment:
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)

----------------------------------------------------------------------

>Comment By: A.M. Kuchling (akuchling)
Date: 2005-12-04 14:54

Message:
Logged In: YES 
user_id=11375

Suggested change applied to rev41597; thanks!

----------------------------------------------------------------------

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1281032&group_id=5470


More information about the Python-bugs-list mailing list