2022-07-15 13:29:12 |
Pekka Klärck |
description |
We have code that operates with various collections and when working with dictionaries it checks is the object a dictionary with `isinstance(obj, Mapping)`. That works fine in general, including with the standard ElementTree, but fails with `lxml.etree._Attrib`. To reproduce:
>>> from xml.etree.ElementTree import XML
>>> isinstance(XML('<x/>').attrib, Mapping)
True
>>> from collections.abc import Mapping
>>> from xml.etree.ElementTree import XML
>>> isinstance(XML('<x/>').attrib, Mapping)
True
>>> from lxml.etree import XML
>>> isinstance(XML('<x/>').attrib, Mapping)
False
Required version info:
Python : sys.version_info(major=3, minor=8, micro=10, releaselevel='final', serial=0)
lxml.etree : (4, 9, 1, 0)
libxml used : (2, 9, 14)
libxml compiled : (2, 9, 14)
libxslt used : (1, 1, 35)
libxslt compiled : (1, 1, 35) |
We have code that operates with various collections and when working with dictionaries it checks is the object a dictionary with `isinstance(obj, Mapping)`. That works fine in general, including with the standard ElementTree, but fails with `lxml.etree._Attrib`. To reproduce:
>>> from collections.abc import Mapping
>>> from xml.etree.ElementTree import XML
>>> isinstance(XML('<x/>').attrib, Mapping)
True
>>> from lxml.etree import XML
>>> isinstance(XML('<x/>').attrib, Mapping)
False
Required version info:
Python : sys.version_info(major=3, minor=8, micro=10, releaselevel='final', serial=0)
lxml.etree : (4, 9, 1, 0)
libxml used : (2, 9, 14)
libxml compiled : (2, 9, 14)
libxslt used : (1, 1, 35)
libxslt compiled : (1, 1, 35) |
|