utils/web.py: Python 3 should use decode() only if it is a bytes object.

This commit is contained in:
Valentin Lorentz 2013-06-13 04:22:20 +00:00
parent a82ad9cb1a
commit 2eec980c8e

View File

@ -192,7 +192,8 @@ def htmlToText(s, tagReplace=' '):
try: try:
import chardet.universaldetector import chardet.universaldetector
except ImportError: except ImportError:
s = s.decode('utf8') if sys.version_info[0] < 3 or isinstance(s, bytes):
s = s.decode('utf8')
else: else:
u = chardet.universaldetector.UniversalDetector() u = chardet.universaldetector.UniversalDetector()
u.feed(s) u.feed(s)