From: Zac Medico Date: Fri, 2 Sep 2011 15:45:43 +0000 (-0700) Subject: xml/metadata: handle py 2.6 cElementTree incompat X-Git-Tag: v2.2.0_alpha52~1 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=cfe7af2b1da9357d5bfaa531f288ef0ac074184c;p=portage.git xml/metadata: handle py 2.6 cElementTree incompat --- diff --git a/pym/portage/xml/metadata.py b/pym/portage/xml/metadata.py index 9e1886927..3513fff6d 100644 --- a/pym/portage/xml/metadata.py +++ b/pym/portage/xml/metadata.py @@ -30,10 +30,19 @@ __all__ = ('MetaDataXML',) -try: - import xml.etree.cElementTree as etree -except ImportError: +import sys + +if sys.hexversion < 0x2070000: + # Our _MetadataTreeBuilder usage is incompatible with + # cElementTree in Python 2.6: + # File "/usr/lib/python2.6/xml/etree/ElementTree.py", line 644, in findall + # assert self._root is not None import xml.etree.ElementTree as etree +else: + try: + import xml.etree.cElementTree as etree + except ImportError: + import xml.etree.ElementTree as etree import re import xml.etree.ElementTree