From 2eec980c8eaf85ec5b58160e84ce347fbcccf089 Mon Sep 17 00:00:00 2001 From: Valentin Lorentz Date: Thu, 13 Jun 2013 04:22:20 +0000 Subject: [PATCH] utils/web.py: Python 3 should use decode() only if it is a bytes object. --- src/utils/web.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/utils/web.py b/src/utils/web.py index 87598fab8..4a0945727 100644 --- a/src/utils/web.py +++ b/src/utils/web.py @@ -192,7 +192,8 @@ def htmlToText(s, tagReplace=' '): try: import chardet.universaldetector except ImportError: - s = s.decode('utf8') + if sys.version_info[0] < 3 or isinstance(s, bytes): + s = s.decode('utf8') else: u = chardet.universaldetector.UniversalDetector() u.feed(s)