diff options
-rw-r--r-- | CHANGES.txt | 2 | ||||
-rw-r--r-- | defusedxml/common.py | 5 |
2 files changed, 7 insertions, 0 deletions
diff --git a/CHANGES.txt b/CHANGES.txt index 3edecb3..e7ee54d 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -12,6 +12,8 @@ defusedxml 0.6.0.dev1 ignored for a long time. The DefusedXMLParser still takes a html argument. A deprecation warning is issued when the argument is False and a TypeError when it's True. +- defusedxml now fails early when pyexpat stdlib module is not available or + broken. defusedxml 0.5.0 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 |