File tree Expand file tree Collapse file tree 1 file changed +9
-1
lines changed
Expand file tree Collapse file tree 1 file changed +9
-1
lines changed Original file line number Diff line number Diff line change 2626from __future__ import unicode_literals
2727
2828# Standard library imports
29- from xml .etree import ElementTree as Etree
3029from codecs import open as _open
3130import warnings
3231import sys
3332import re
3433
3534# Check python version to set the object that can detect non unicode strings
3635if sys .version_info >= (3 , 0 ):
36+ import xml .etree .ElementTree as Etree
3737 # noinspection PyUnresolvedReferences,PyCompatibility
3838 from html .parser import HTMLParser
3939 # noinspection PyUnresolvedReferences, PyCompatibility
4848 # noinspection PyUnresolvedReferences
4949 _chr = unichr
5050
51+ try :
52+ # This attemps to import the C version of ElementTree
53+ import xml .etree .cElementTree as Etree
54+ # This will fail if the implementation is broken
55+ Etree .Comment ("Test for broken cElementTree" )
56+ except (ImportError , TypeError ):
57+ import xml .etree .ElementTree as Etree
58+
5159__all__ = ["HTMLement" , "fromstring" , "fromstringlist" , "parse" ]
5260__repo__ = "https://github.com/willforde/python-htmlement"
5361__copyright__ = "Copyright (C) 2016 William Forde"
You can’t perform that action at this time.
0 commit comments