]> granicus.if.org Git - python/commitdiff
bpo-30485: Re-allow empty strings in ElementPath namespace mappings since they might...
authorStefan Behnel <stefan_ml@behnel.de>
Sun, 14 Apr 2019 19:12:34 +0000 (21:12 +0200)
committerGitHub <noreply@github.com>
Sun, 14 Apr 2019 19:12:34 +0000 (21:12 +0200)
Lib/test/test_xml_etree.py
Lib/xml/etree/ElementPath.py

index 2f7a3b60b22dd7c516ca792b3e07f3f674ff2959..f5b118b079ee3b59c742c65cfc7655fce0a0c005 100644 (file)
@@ -2466,9 +2466,6 @@ class ElementFindTest(unittest.TestCase):
         nsmap = {'xx': 'X', None: 'Y'}
         self.assertEqual(len(root.findall(".//xx:b", namespaces=nsmap)), 2)
         self.assertEqual(len(root.findall(".//b", namespaces=nsmap)), 1)
-        nsmap = {'xx': 'X', '': 'Y'}
-        with self.assertRaisesRegex(ValueError, 'namespace prefix'):
-            root.findall(".//xx:b", namespaces=nsmap)
 
     def test_bad_find(self):
         e = ET.XML(SAMPLE_XML)
index 0e3854f9db22cc95a1d0f64fc30d0bbc07949da2..4d231a7df65677e503ccfdccae5bc1cf32f517f4 100644 (file)
@@ -275,8 +275,6 @@ def iterfind(elem, path, namespaces=None):
 
     cache_key = (path,)
     if namespaces:
-        if '' in namespaces:
-            raise ValueError("empty namespace prefix must be passed as None, not the empty string")
         if None in namespaces:
             cache_key += (namespaces[None],) + tuple(sorted(
                 item for item in namespaces.items() if item[0] is not None))