sax barfs on unicode filenames: workaround

"Martin v. Löwis" martin at
Wed Oct 4 22:39:18 CEST 2006

Edward K. Ream schrieb:
> Happily, the workaround is easy.  Replace theFile with:
> # Use cStringIo to avoid a crash in sax when inputFileName has unicode 
> characters.
> s =
> theFile = cStringIO.StringIO(s)
> My first attempt at a workaround was to use:
> s =
> parser.parseString(s)
> but the expat parser does not support parseString...

Right - you would have to use xml.sax.parseString (which is a global
function, not a method).

Of course, parseString just does what you did: create a cStringIO
object and operate on that.


More information about the Python-list mailing list