entities as attribute values

Bug #1171002 reported by scoder
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
lxml
Confirmed
Wishlist
Unassigned

Bug Description

I'm trying to write an xml file that has entities as values for attributes. If I try to write the entity as text, the & is xml-escaped to &. If I try to call set() with an Entity, I get an error:

    >>> import lxml.etree
    >>> tree= lxml.etree.fromstring ('<a foo="bar"/>')
    >>> tree.set ('foo', '&bar;')
    >>> print lxml.etree.tostring (tree)
    <a foo="&amp;bar;"/>
    >>> tree.set ('foo', lxml.etree.Entity ('bar'))
    Traceback (most recent call last):
      File "<stdin>", line 1, in <module>
      File "lxml.etree.pyx", line 695, in lxml.etree._Element.set (src/lxml/lxml.etree.c:35527)
      File "apihelpers.pxi", line 563, in lxml.etree._setAttributeValue (src/lxml/lxml.etree.c:15481)
      File "apihelpers.pxi", line 1367, in lxml.etree._utf8 (src/lxml/lxml.etree.c:22126)
    TypeError: Argument must be bytes or unicode, got '_Entity'

Originally reported by Marcos Dione.

scoder (scoder)
Changed in lxml:
importance: Undecided → Wishlist
status: New → Confirmed
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.