]> granicus.if.org Git - python/commitdiff
fix the _namespace_map cleanup for cElementTree tests.
authorFlorent Xicluna <florent.xicluna@gmail.com>
Thu, 16 Feb 2012 22:28:35 +0000 (23:28 +0100)
committerFlorent Xicluna <florent.xicluna@gmail.com>
Thu, 16 Feb 2012 22:28:35 +0000 (23:28 +0100)
Lib/test/test_xml_etree.py
Lib/xml/etree/ElementTree.py

index 8713de5f59343bd47f50de7da7440e3390c52cf4..58fdcd4c5c60e87df2887459d2820bc564b4ef1a 100644 (file)
@@ -1881,12 +1881,7 @@ class CleanContext(object):
 
     def __enter__(self):
         from xml.etree import ElementPath
-        if hasattr(ET, '_namespace_map'):
-            self._nsmap = ET._namespace_map
-        else:
-            # when testing the cElementTree alias
-            from xml.etree.ElementTree import _namespace_map
-            self._nsmap = _namespace_map
+        self._nsmap = ET.register_namespace._namespace_map
         # Copy the default namespace mapping
         self._nsmap_copy = self._nsmap.copy()
         # Copy the path cache (should be empty)
index 93147ebc72a2d2c1315523fb4cf9ebf52f9ac1db..defef0d0ebca36dc35f85c1d22490763feffe736 100644 (file)
@@ -1086,6 +1086,8 @@ _namespace_map = {
     # dublin core
     "http://purl.org/dc/elements/1.1/": "dc",
 }
+# For tests and troubleshooting
+register_namespace._namespace_map = _namespace_map
 
 def _raise_serialization_error(text):
     raise TypeError(