element generator factory fails with accents and other valid utf-8 characters

Bug #1463711 reported by belitre
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
lxml
Invalid
Undecided
Unassigned

Bug Description

If I add text to the builder including accents or other special characters it fails.

Samples

E("tag","garçon")
E("tag","fantástico")

Error

C:\Python27\lib\site-packages\lxml-3.4.4-py2.7-win32.egg\lxml\builder.pyc in __call__(self, tag, *children, **attrib)
    234 raise TypeError("bad argument type: %s(%r)" %
    235 (type(item).__name__, item))
--> 236 v = t(elem, item)
    237 if v:
    238 get(type(v))(elem, v)

C:\Python27\lib\site-packages\lxml-3.4.4-py2.7-win32.egg\lxml\builder.pyc in add_text(elem, item)
    183 elem[-1].tail = (elem[-1].tail or "") + item
    184 except IndexError:
--> 185 elem.text = (elem.text or "") + item
    186
    187 def add_cdata(elem, cdata):

C:\Python27\lib\site-packages\lxml-3.4.4-py2.7-win32.egg\lxml\etree.pyd in lxml.etree._Element.text.__set__ (src\lxml\lxml.etree.c:46353)()

C:\Python27\lib\site-packages\lxml-3.4.4-py2.7-win32.egg\lxml\etree.pyd in lxml.etree._setNodeText (src\lxml\lxml.etree.c:20953)()

C:\Python27\lib\site-packages\lxml-3.4.4-py2.7-win32.egg\lxml\etree.pyd in lxml.etree._createTextNode (src\lxml\lxml.etree.c:20829)()

C:\Python27\lib\site-packages\lxml-3.4.4-py2.7-win32.egg\lxml\etree.pyd in lxml.etree._utf8 (src\lxml\lxml.etree.c:27125)()

Version Info:

Python : sys.version_info(major=2, minor=7, micro=4, releaselevel='final', serial=0)
lxml.etree : (3, 4, 4, 0)
libxml used : (2, 9, 0)
libxml compiled : (2, 9, 0)
libxslt used : (1, 1, 28)
libxslt compiled : (1, 1, 28)

Revision history for this message
scoder (scoder) wrote :

Pass Unicode strings instead or switch to Python 3.

Changed in lxml:
status: New → Invalid
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.