From 8b299098c95004bbe8079bea95ab4bb05cf53e2b Mon Sep 17 00:00:00 2001 From: derwinlu Date: Mon, 19 Oct 2015 18:33:14 +0200 Subject: [PATCH] Make HTMLParser Python 3.5 ready --- pelican/utils.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/pelican/utils.py b/pelican/utils.py index cc9eb405..92e819f9 100644 --- a/pelican/utils.py +++ b/pelican/utils.py @@ -424,7 +424,11 @@ class _HTMLWordTruncator(HTMLParser): def __init__(self, max_words): # In Python 2, HTMLParser is not a new-style class, # hence super() cannot be used. - HTMLParser.__init__(self) + try: + HTMLParser.__init__(self, convert_charrefs=False) + except TypeError: + # pre Python 3.3 + HTMLParser.__init__(self) self.max_words = max_words self.words_found = 0