attrib.pop for comments/PI broken
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
lxml |
Fix Released
|
Low
|
scoder |
Bug Description
attrib.pop('xxx', None) raises AttributeError: 'dictproxy' object has no attribute 'pop' for comments/PIs/ This used to work in older lxml versions, and it breaks commonly used code like
[x.attrib.
to remove an attrib from all elements.
I strongly suggest implementing a dummy pop method for comments/PIs or updating lxml will break a *lot* of code.
Test case:
python -c 'from lxml.etree import fromstring; r = fromstring(
Version info:
>>> import sys
>>> from lxml import etree
>>>
>>> print("%-20s: %s" % ('Python', sys.version_info))
Python : sys.version_
>>> print("%-20s: %s" % ('lxml.etree', etree.LXML_
lxml.etree : (3, 3, 0, 0)
>>> print("%-20s: %s" % ('libxml used', etree.LIBXML_
libxml used : (2, 9, 1)
>>> print("%-20s: %s" % ('libxml compiled', etree.LIBXML_
libxml compiled : (2, 9, 1)
>>> print("%-20s: %s" % ('libxslt used', etree.LIBXSLT_
libxslt used : (1, 1, 28)
>>> print("%-20s: %s" % ('libxslt compiled', etree.LIBXSLT_
libxslt compiled : (1, 1, 28)
> ... or updating lxml will break a *lot* of code.
Well, it's certainly the first time I see this use case, so I may raise my doubts that it's all that common. But yes, it's a regression, so it should be fixed.