diff options
Diffstat (limited to 'Lib')
-rw-r--r-- | Lib/test/test_xml_etree.py | 9 | ||||
-rw-r--r-- | Lib/xml/etree/ElementTree.py | 2 |
2 files changed, 10 insertions, 1 deletions
diff --git a/Lib/test/test_xml_etree.py b/Lib/test/test_xml_etree.py index 08f7988..22fafa9 100644 --- a/Lib/test/test_xml_etree.py +++ b/Lib/test/test_xml_etree.py @@ -1841,6 +1841,15 @@ def check_issue6565(): """ +def check_issue10777(): + """ + Registering a namespace twice caused a "dictionary changed size during + iteration" bug. + + >>> ET.register_namespace('test10777', 'http://myuri/') + >>> ET.register_namespace('test10777', 'http://myuri/') + """ + # -------------------------------------------------------------------- diff --git a/Lib/xml/etree/ElementTree.py b/Lib/xml/etree/ElementTree.py index 53aa9e7..ba33879 100644 --- a/Lib/xml/etree/ElementTree.py +++ b/Lib/xml/etree/ElementTree.py @@ -1068,7 +1068,7 @@ _serialize = { def register_namespace(prefix, uri): if re.match("ns\d+$", prefix): raise ValueError("Prefix format reserved for internal use") - for k, v in _namespace_map.items(): + for k, v in list(_namespace_map.items()): if k == uri or v == prefix: del _namespace_map[k] _namespace_map[uri] = prefix |