[merge] python 2.5 fixes

Martin Pool mbp at canonical.com
Thu Sep 28 06:43:12 BST 2006


On 27 Sep 2006, John Arbash Meinel <john at arbash-meinel.com> wrote:
> You have my +1 to changing the import code.

OK, here's what I'm going to put in:


=== modified file 'bzrlib/xml_serializer.py'
--- bzrlib/xml_serializer.py	2006-09-22 00:51:36 +0000
+++ bzrlib/xml_serializer.py	2006-09-28 05:36:24 +0000
@@ -25,13 +25,20 @@
 from bzrlib.trace import mutter, warning
 
 try:
-    from cElementTree import (ElementTree, SubElement, Element,
-                              XMLTreeBuilder, fromstring, tostring)
-    import elementtree
+    try:
+        # it's in this package in python2.5
+        from xml.etree.cElementTree import (ElementTree, SubElement, Element,
+            XMLTreeBuilder, fromstring, tostring)
+        import xml.etree as elementtree
+    except ImportError:
+        from cElementTree import (ElementTree, SubElement, Element,
+                                  XMLTreeBuilder, fromstring, tostring)
+        import elementtree
     ParseError = SyntaxError
 except ImportError:
     mutter('WARNING: using slower ElementTree; consider installing cElementTree'
            " and make sure it's on your PYTHONPATH")
+    # this copy is shipped with bzr
     from util.elementtree.ElementTree import (ElementTree, SubElement,
                                               Element, XMLTreeBuilder,
                                               fromstring, tostring)



-- 
Martin




More information about the bazaar mailing list