From 7e52b16e50bd0e6683096177e6d1fb668d65c522 Mon Sep 17 00:00:00 2001 From: Christian Heimes Date: Thu, 21 May 2020 00:17:55 +0200 Subject: [PATCH] Don't use cElementTree on Python 3 It's been deprecated and will be removed in 3.9 or 3.10. 3.9.0b1 doesn't have cElementTree. I'd like to bring it back with a deprecation warning to drop in 3.10. See: https://github.com/python/cpython/pull/19921 Signed-off-by: Christian Heimes Signed-off-by: Sam Sneddon --- html5lib/_utils.py | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/html5lib/_utils.py b/html5lib/_utils.py index 179d7015..9ea57942 100644 --- a/html5lib/_utils.py +++ b/html5lib/_utils.py @@ -7,12 +7,15 @@ except ImportError: from collections import Mapping -from six import text_type +from six import text_type, PY3 -try: - import xml.etree.cElementTree as default_etree -except ImportError: +if PY3: import xml.etree.ElementTree as default_etree +else: + try: + import xml.etree.cElementTree as default_etree + except ImportError: + import xml.etree.ElementTree as default_etree __all__ = ["default_etree", "MethodDispatcher", "isSurrogatePair",