Skip to content

Commit

Permalink
Enhance code and commend of lxml.etree._Attrib handling.
Browse files Browse the repository at this point in the history
  • Loading branch information
pekkaklarck committed Jul 18, 2022
1 parent 12f937c commit 4e22658
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions src/robot/libraries/XML.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,14 @@
except ImportError:
lxml_etree = None
else:
# `_Attrib` doesn't inherit `Mapping` and thus our `is_dict_like` doesn't
# recognize it. Registering explicitly avoids that problem.
from collections.abc import Mapping
Mapping.register(lxml_etree._Attrib)
# `lxml.etree._Attrib` doesn't extend `Mapping` and thus our `is_dict_like`
# doesn't recognize it unless we register it ourselves. Fixed in lxml 4.9.2:
# https://bugs.launchpad.net/lxml/+bug/1981760
from collections.abc import MutableMapping
Attrib = getattr(lxml_etree, '_Attrib', None)
if Attrib and not isinstance(Attrib, MutableMapping):
MutableMapping.register(Attrib)
del Attrib, MutableMapping

from robot.api import logger
from robot.api.deco import keyword
Expand Down

0 comments on commit 4e22658

Please sign in to comment.