[XML-SIG] Re: [bug] Encoding troubles with attributes' CDATA, py1.5.2 + pyxml
0.6.6
Alexandre Fayolle
Alexandre.Fayolle@logilab.fr
Thu, 30 Aug 2001 18:26:32 +0200 (CEST)
On Thu, 30 Aug 2001, Nicolas Chauvat wrote:
> Hi List,
>
> With python 1.5.2 and PyXml 0.6.6, I get problems when executing the
> following piece of code :
>
> >>> s = '<?xml version="1.0" encoding="ISO-8859-1"?><d nom="Détails de la
> specialité" />'
> >>> d = Sax2.FromXml(s)
> >>> PrettyPrint(d,encoding='iso-8859-1')
<snip>
Well actually this code will break with python 2.1 and pyxml 0.6.6 too.
The problem is that the Printer class will convert the data from utf-8 to
latin-1 twice for attributes : if you give a look at the visitAttr method,
it first calls TranslateCdata (which does the first conversion), and then
_write which attempts to convert the code again, resulting in the
exception being raised.
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).