summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorUli Schlachter <psychon@znc.in>2020-07-17 15:31:58 +0200
committerUli Schlachter <psychon@znc.in>2021-09-30 17:15:34 +0000
commit65169c1af7893882c21d1e2a544903212b8d6fb0 (patch)
treee22a9b489b80d2c711a5a288f5edbe23adda478c
parent6d72110e1eddf4e802aff3442b7b58f471175ceb (diff)
downloadxcb-proto-65169c1af7893882c21d1e2a544903212b8d6fb0.tar.gz
Use xml.etree.cElementTree where appropriate
This makes the code added in the previous commit consistent with the rest of the code base. From Björn's suggestion: This should import xml.etree.{,c}ElementTree conditionally on the version of the Python interpreter used to import this module. xml.etree.ElementTree is preferred for Python >= 3.3, as it uses the fastest possible implementation automatically. Earlier versions of Python need xml.etree.cElementTree as they may not have an implementation that can be used in a platform generic way. Suggested-by: Björn Esser <besser82@fedoraproject.org>
-rw-r--r--xcbgen/xtypes.py7
1 files changed, 6 insertions, 1 deletions
diff --git a/xcbgen/xtypes.py b/xcbgen/xtypes.py
index 0d92f2e..c8c4e01 100644
--- a/xcbgen/xtypes.py
+++ b/xcbgen/xtypes.py
@@ -3,7 +3,12 @@ This module contains the classes which represent XCB data types.
'''
from xcbgen.expr import Field, Expression
from xcbgen.align import Alignment, AlignmentLog
-from xml.etree.ElementTree import SubElement
+
+if version_info[:2] >= (3, 3):
+ from xml.etree.ElementTree import SubElement
+else:
+ from xml.etree.cElementTree import SubElement
+
import __main__
verbose_align_log = False