[lxml-dev] test failures, lxml-2.2

Alexander Shigin shigin at rambler-co.ru
Thu Mar 26 18:38:32 CET 2009


В Чтв, 26/03/2009 в 09:45 -0700, Jorge Barrios пишет:
> I am hoping that there's an easy fix. I couldn't find anything about  
> it in the mailing list. Anyone know what the problem might be?

> PYTHONPATH=src: python selftest.py
> **********************************************************************
> File "/var/data3/lxml-2.2/selftest.py", line 575, in selftest.encoding
> Failed example:
>      serialize(elem)
> Expected:
>      '<tag key="&#229;&#246;&#246;&lt;&gt;"/>'
> Got:
>      '<tag key="&#xE5;&#xF6;&#xF6;&lt;&gt;"/>'
> **********************************************************************

It doesn't look like a problem. It seems libxml serializes using hex
representation of entities. The deserialized value would be the same. 

I don't know if libxml2 has a switch to turn old behaviour back, sorry.


In [7]: etree.fromstring('<tag key="&#229;&#246;&#246;&lt;&gt;"/>').attrib['key']
Out[7]: u'\xe5\xf6\xf6<>'

In [8]: etree.fromstring('<tag key="&#xE5;&#xF6;&#xF6;&lt;&gt;"/>').attrib['key']
Out[8]: u'\xe5\xf6\xf6<>'

In [9]: k1 = etree.fromstring('<tag key="&#229;&#246;&#246;&lt;&gt;"/>').attrib['key']

In [10]: k2 = etree.fromstring('<tag key="&#xE5;&#xF6;&#xF6;&lt;&gt;"/>').attrib['key']

In [11]: k1 == k2
Out[11]: True




More information about the lxml-dev mailing list