Skip to content

Commit 9b24f76

Browse files
committed
Add default impl for etree treebuilder.
1 parent 1cb700c commit 9b24f76

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

src/html5lib/treebuilders/__init__.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,19 @@ def getTreeBuilder(treeType, implementation=None, **kwargs):
7373
import etree_lxml
7474
treeBuilderCache[treeType] = etree_lxml.TreeBuilder
7575
elif treeType == "etree":
76+
# Come up with a sane default
77+
if implementation == None:
78+
try:
79+
import xml.etree.cElementTree as ET
80+
except ImportError:
81+
try:
82+
import xml.etree.ElementTree as ET
83+
except ImportError:
84+
try:
85+
import cElementTree as ET
86+
except ImportError:
87+
import elementtree.ElementTree as ET
88+
implementation = ET
7689
import etree
7790
# XXX: NEVER cache here, caching is done in the etree submodule
7891
return etree.getETreeModule(implementation, **kwargs).TreeBuilder

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy