[Python-checkins] cpython: fix the _namespace_map cleanup for cElementTree tests.

florent.xicluna python-checkins at python.org
Thu Feb 16 23:28:53 CET 2012


http://hg.python.org/cpython/rev/cdc9e0238b1d
changeset:   74991:cdc9e0238b1d
user:        Florent Xicluna <florent.xicluna at gmail.com>
date:        Thu Feb 16 23:28:35 2012 +0100
summary:
  fix the _namespace_map cleanup for cElementTree tests.

files:
  Lib/test/test_xml_etree.py   |  7 +------
  Lib/xml/etree/ElementTree.py |  2 ++
  2 files changed, 3 insertions(+), 6 deletions(-)


diff --git a/Lib/test/test_xml_etree.py b/Lib/test/test_xml_etree.py
--- a/Lib/test/test_xml_etree.py
+++ b/Lib/test/test_xml_etree.py
@@ -1881,12 +1881,7 @@
 
     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)
diff --git a/Lib/xml/etree/ElementTree.py b/Lib/xml/etree/ElementTree.py
--- a/Lib/xml/etree/ElementTree.py
+++ b/Lib/xml/etree/ElementTree.py
@@ -1086,6 +1086,8 @@
     # 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(

-- 
Repository URL: http://hg.python.org/cpython


More information about the Python-checkins mailing list