Attribute names ignore namespaces

Bug #438128 reported by Marcello Perathoner
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
lxml
Fix Released
Medium
scoder

Bug Description

I want to delete the lang attribute from an html element that has both
lang and xml:lang attributes. I found I cannot do that consistently.

lxml deletes either lang or xml:lang at random. The results depend on
the order the two attributes are specified in the html source.

--- lxmlbug.py --------------------------------------

from lxml import etree

html = etree.XML ("<html lang='en' xml:lang='en' />")
del html.attrib['lang']
print etree.tostring (html)

# prints expected: <html xml:lang="en"/>

html = etree.XML ("<html xml:lang='en' lang='en' />")
del html.attrib['lang']
print etree.tostring (html)

# prints unexpected: <html lang="en"/>

print
print "lxml.etree: ", etree.LXML_VERSION
print "libxml used: ", etree.LIBXML_VERSION
print "libxml compiled: ", etree.LIBXML_COMPILED_VERSION
print "libxslt used: ", etree.LIBXSLT_VERSION
print "libxslt compiled: ", etree.LIBXSLT_COMPILED_VERSION

-----------------------------------------------------------

$ python lxmlbug.py
<html xml:lang="en"/>
<html lang="en"/>

lxml.etree: (2, 2, 2, 0)
libxml used: (2, 7, 5)
libxml compiled: (2, 7, 3)
libxslt used: (1, 1, 26)
libxslt compiled: (1, 1, 24)

$

scoder (scoder)
Changed in lxml:
assignee: nobody → Stefan Behnel (scoder)
importance: Undecided → Medium
milestone: none → 2.3
status: New → Confirmed
Revision history for this message
scoder (scoder) wrote :

This and a couple of similar bugs have been fixed in trunk rev. 68065:

https://codespeak.net/viewvc/?view=rev&revision=68065

Changed in lxml:
milestone: 2.3 → 2.2
status: Confirmed → Fix Committed
Revision history for this message
scoder (scoder) wrote :

released in 2.2.3

Changed in lxml:
status: Fix Committed → Fix Released
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.