[MERGE] properly import elementtree.ElementTree the module

John Arbash Meinel john at arbash-meinel.com
Thu Jun 12 17:00:01 BST 2008


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

ricardokirkner just ran into some weird racing import stuff.

our current code is doing:

from cElementTree import (ElementTree, SubElement, Element,
~                          XMLTreeBuilder, fromstring, tostring)
import elementtree

and then later on it modifies:

elementtree.ElementTree._escape_attrib

Now, elementtree is a bit weird in how it is laid out. Specifically you have:

~ elementtree/
~  ElementTree.py

So to get the *class* you have to do:
elementtree.ElementTree.ElementTree

but the cElementTree has the class directly as cElementTree.ElementTree.

The *big* confusion here is that cElementTree isn't laid out like 'elementtree'.

Anyway, I guess cElementtree for python2.4 has changed. At one point it used to
import elementtree.ElementTree for us, but that seems to no longer be the case.
So the attached patch just makes sure everything is in the local namespace.

It probably also means that our monkey-patching no longer is actually being used
(time to get rid of it?), as I'm guessing everything is being done in
cElementTree rather than any calls into the python classes.

But mostly, this patch makes things stop failing with bad attribute errors, etc.

It is fairly trivial, and will never be the wrong thing to do. So I'm going to
just merge it.

John
=:->
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (Cygwin)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iEYEARECAAYFAkhRSAEACgkQJdeBCYSNAAO2NACfcEMyRKcHw3mky42gctL0HCmY
61IAnR5bhZ55Pjlt2u1RrSBDW6tAYkiE
=IMcP
-----END PGP SIGNATURE-----
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: xml_import.patch
Url: https://lists.ubuntu.com/archives/bazaar/attachments/20080612/98157529/attachment-0001.diff 


More information about the bazaar mailing list