[patch] fix up elementtree imports

John Arbash Meinel john at arbash-meinel.com
Mon Jun 12 15:53:03 BST 2006


Martin Pool wrote:
> Robert's recent change to monkey-patch elementtree breaks on systems
> that use the shipped copy.  I think this fixes it.
> 
> 
> 
> ------------------------------------------------------------------------
> 
> === modified file 'bzrlib/xml_serializer.py'
> --- bzrlib/xml_serializer.py	2006-05-23 00:03:45 +0000
> +++ bzrlib/xml_serializer.py	2006-06-11 03:20:42 +0000
> @@ -27,12 +27,14 @@
>  try:
>      from cElementTree import (ElementTree, SubElement, Element,
>                                XMLTreeBuilder, fromstring, tostring)
> +    import elementtree
>  except ImportError:
>      mutter('WARNING: using slower ElementTree; consider installing cElementTree'
>             " and make sure it's on your PYTHONPATH")
>      from util.elementtree.ElementTree import (ElementTree, SubElement,
>                                                Element, XMLTreeBuilder,
>                                                fromstring, tostring)
> +    import util.elementtree as elementtree
>  

+1 on these changes, though I think you should change the first one to:
import elementtree.ElementTree

a plain import of 'elementtree' does not import elementtree.ElementTree,
so we wouldn't have access to the class elementtree.ElementTree.ElementTree.

I realize that cElementTree does import it, so it should be available as
a module object. I just think we should be more explicit about it.

John
=:->


>  from bzrlib.errors import BzrError
>  
> @@ -76,7 +78,6 @@
>  # performance tuning for elementree's serialiser. THis should be
>  # sent upstream - RBC 20060523.
>  # the functions here are patched into elementree at runtime.
> -import elementtree.ElementTree
>  import re
>  escape_re = re.compile("[&'\"<>]")
>  escape_map = {
> 

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 254 bytes
Desc: OpenPGP digital signature
Url : https://lists.ubuntu.com/archives/bazaar/attachments/20060612/315f3e9e/attachment.pgp 


More information about the bazaar mailing list