From 72aac53b5d04a6d8194fc53d2c5112f805298237 Mon Sep 17 00:00:00 2001 From: Zhiming Wang Date: Sun, 20 Sep 2015 16:43:40 -0700 Subject: Python 3.5 compatibility: add placeholder for HTMLParseError HTMLParseError was removed in Python 3.5. Since it could never be thrown in Python 3.5+, we simply define a placeholder when HTMLParseError cannot be imported. --- test/normalize.py | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/test/normalize.py b/test/normalize.py index 70bee46..9025bfa 100644 --- a/test/normalize.py +++ b/test/normalize.py @@ -1,5 +1,14 @@ # -*- coding: utf-8 -*- -from html.parser import HTMLParser, HTMLParseError +from html.parser import HTMLParser + +try: + from html.parser import HTMLParseError +except ImportError: + # HTMLParseError was removed in Python 3.5. It could never be + # thrown, so we define a placeholder instead. + class HTMLParseError(Exception): + pass + from html.entities import name2codepoint import sys import re -- cgit v1.2.3