Commit 3c5a858e authored by Stefan Behnel's avatar Stefan Behnel Committed by GitHub

bpo-30485: Re-allow empty strings in ElementPath namespace mappings since they...

bpo-30485: Re-allow empty strings in ElementPath namespace mappings since they might actually be harmless and unused (and thus went undetected previously). (#12830)
parent cd466559
......@@ -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)
......
......@@ -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))
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment