3 Jan 2008 16:29
Help with an error message
Konstantin Ryabitsev <icon <at> fedoraproject.org>
2008-01-03 15:29:48 GMT
2008-01-03 15:29:48 GMT
Hi, everyone:
I'm having trouble with the following case. One of my automatic import
scripts takes data from one source and submits it to another as an XML
feed. Recently, it started failing because one of the entries contains
a null. The testcase is such:
from lxml.etree import Element
sourcestr = 'Contains a null: \x00'
unistr = unicode(sourcestr, 'utf-8')
elt = Element('foo').text = unistr
Running it will cause the following error:
Traceback (most recent call last):
File "foo.py", line 6, in <module>
elt = Element('foo').text = unistr
File "etree.pyx", line 741, in etree._Element.text.__set__
File "apihelpers.pxi", line 344, in etree._setNodeText
File "apihelpers.pxi", line 648, in etree._utf8
AssertionError: All strings must be XML compatible, either Unicode or ASCII
Can someone suggest the best way to deal with this?
Kind regards,
--
--
Konstantin Ryabitsev
Montréal, Québec
_______________________________________________
lxml-dev mailing list
(Continue reading)
RSS Feed