[XML-SIG] xmlproc bug ?

Alexandre Fayolle Alexandre.Fayolle@logilab.fr
Thu, 6 Sep 2001 12:16:02 +0200 (CEST)


On Wed, 5 Sep 2001, Juergen Hermann wrote:

> On Wed, 5 Sep 2001 18:53:10 +0200 (CEST), Alexandre Fayolle wrote:
> 
> >Is the following behaviour a well known feature or a bug (or me deeply
> >misunderstanding SAX)? It looks like xmlproc's Sax2 driver won't produce
> >UTF-8 encoded text when parsing a iso-8859-1 encoded file.
> >
> >The attached file demonstrates this. I tested it on python 1.5.2 and
> >2.1.1, using PyXML 0.6.6.
> >
> >I'll register this in the bugtracker if it turns out to be a bug.
> 
> It's not related to xmlproc at all, but to "print" which uses "str" which in turn
> uses the default encoding "USASCII". BTW, you also need to set the namesapce
> feature.

The code you posted causes an exception because the string I get is not
ASCII, but iso-latin-1 :

  File
"/usr/lib/python2.1/site-packages/_xmlplus/sax/drivers2/drv_xmlproc.py",
line 336, in handle_start_tag
    AttributesNSImpl(attrs, rawnames))
  File "xmlproctest.py", line 15, in startElementNS
    write(qname)
  File "xmlproctest.py", line 9, in write
    sys.stdout.write((x or "").encode("ISO-8859-1") + "\n")
UnicodeError: ASCII decoding error: ordinal not in range(128)



Alexandre Fayolle
-- 
LOGILAB, Paris (France).
http://www.logilab.com   http://www.logilab.fr  http://www.logilab.org
Narval, the first software agent available as free software (GPL).