diff options
Diffstat (limited to 'Lib')
-rw-r--r-- | Lib/test/test_xml_etree.py | 2 | ||||
-rw-r--r-- | Lib/xml/etree/ElementPath.py | 8 |
2 files changed, 3 insertions, 7 deletions
diff --git a/Lib/test/test_xml_etree.py b/Lib/test/test_xml_etree.py index f5b118b..14ce32a 100644 --- a/Lib/test/test_xml_etree.py +++ b/Lib/test/test_xml_etree.py @@ -2463,7 +2463,7 @@ class ElementFindTest(unittest.TestCase): nsmap = {'xx': 'Y'} self.assertEqual(len(root.findall(".//xx:b", namespaces=nsmap)), 1) self.assertEqual(len(root.findall(".//b", namespaces=nsmap)), 2) - nsmap = {'xx': 'X', None: 'Y'} + nsmap = {'xx': 'X', '': 'Y'} self.assertEqual(len(root.findall(".//xx:b", namespaces=nsmap)), 2) self.assertEqual(len(root.findall(".//b", namespaces=nsmap)), 1) diff --git a/Lib/xml/etree/ElementPath.py b/Lib/xml/etree/ElementPath.py index 4d231a7..b670d58 100644 --- a/Lib/xml/etree/ElementPath.py +++ b/Lib/xml/etree/ElementPath.py @@ -71,7 +71,7 @@ xpath_tokenizer_re = re.compile( ) def xpath_tokenizer(pattern, namespaces=None): - default_namespace = namespaces.get(None) if namespaces else None + default_namespace = namespaces.get('') if namespaces else None for token in xpath_tokenizer_re.findall(pattern): tag = token[1] if tag and tag[0] != "{": @@ -275,11 +275,7 @@ def iterfind(elem, path, namespaces=None): cache_key = (path,) if namespaces: - if None in namespaces: - cache_key += (namespaces[None],) + tuple(sorted( - item for item in namespaces.items() if item[0] is not None)) - else: - cache_key += tuple(sorted(namespaces.items())) + cache_key += tuple(sorted(namespaces.items())) try: selector = _cache[cache_key] |