summaryrefslogtreecommitdiff
path: root/defusedxml
diff options
context:
space:
mode:
authorChristian Heimes <christian@python.org>2019-04-14 11:37:42 +0200
committerChristian Heimes <christian@python.org>2019-04-14 11:45:26 +0200
commit0c5f8700f1bb775f14415150b2ccd4633e199183 (patch)
treebac0918274ab974ae4686fe2f43d109c600e36d6 /defusedxml
parent454e17f51b905574ce9fa1a9c112a5f5850d83fe (diff)
downloaddefusedxml-git-0c5f8700f1bb775f14415150b2ccd4633e199183.tar.gz
Fail early when pyexpat is missing
Fixes: https://github.com/tiran/defusedxml/issues/10 Signed-off-by: Christian Heimes <christian@python.org>
Diffstat (limited to 'defusedxml')
-rw-r--r--defusedxml/common.py5
1 files changed, 5 insertions, 0 deletions
diff --git a/defusedxml/common.py b/defusedxml/common.py
index be23e97..1995d61 100644
--- a/defusedxml/common.py
+++ b/defusedxml/common.py
@@ -6,9 +6,14 @@
"""Common constants, exceptions and helpe functions
"""
import sys
+import xml.parsers.expat
PY3 = sys.version_info[0] == 3
+# Fail early when pyexpat is not installed correctly
+if not hasattr(xml.parsers.expat, "ParserCreate"):
+ raise ImportError('pyexpat')
+
class DefusedXmlException(ValueError):
"""Base exception