Comment 9 for bug 81890

Revision history for this message
Matthias Klose (doko) wrote : Re: [Bug 81890] Re: python-elementree doesn't seem to support python2.5?

Jc schrieb:
> Thanks for this guys, I guess I should have looked into it a bit harder.
> Any opinions on the cleanest way to support 2.4 (+python-elementtree)
> and 2.5?

please have a look at the bzr package:

try:
    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)
    import util.elementtree as elementtree