bzr-0.7 and cElementTree

Marien Zwart marienz at gentoo.org
Wed Jan 25 17:02:24 GMT 2006


On Wed, Jan 25, 2006 at 05:23:21PM +0100, Adis Nezirovic wrote:
<snip>
> It seems to me that there is a problem in bzrlib/xml.py
> Please note that documentation at
> http://effbot.org/zone/celementtree.htm explicitly states that we need
> *both* cElementTree and standard ElementTree. (e.g. 'fromstring' is not
> defined in cElementTree, I double checked 'cElementTree.so' with nm)
> 
> Attached patch resolves issue for me. Did I get it right, or I am
> horribly wrong :-)

> --- bzrlib/xml.py.orig	2006-01-25 16:58:14.000000000 +0100
> +++ bzrlib/xml.py	2006-01-25 17:15:51.000000000 +0100
> @@ -25,8 +25,8 @@
>  from bzrlib.trace import mutter, warning
>  
>  try:
> -    from cElementTree import (ElementTree, SubElement, Element,
> -                              XMLTreeBuilder, fromstring, tostring)
> +    from cElementTree import (SubElement, Element, XMLTreeBuilder)
> +    from util.elementtree.ElementTree import (ElementTree, fromstring, tostring)
>  except ImportError:
>      mutter('WARNING: using slower ElementTree; consider installing cElementTree'
>             " and make sure it's on your PYTHONPATH")

The documentation means you need both cElementTree and ElementTree
installed in the same place (probably site-packages), and cElementTree
should be a transparent replacement for ElementTree. On my system:

>>> import cElementTree
>>> cElementTree.__version__
'1.0.5'
>>> cElementTree.tostring
<function tostring at 0xb7bbb64c>
>>> from elementtree import ElementTree
>>> cElementTree.tostring is ElementTree.tostring
True

cElementTree grabs those functions from ElementTree.

So this is imho not a bzr bug, you should have installed ElementTree
as a dependency of cElementTree.

-- 
Marien.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: not available
Url : https://lists.ubuntu.com/archives/bazaar/attachments/20060125/6b67b79f/attachment.pgp 


More information about the bazaar mailing list