Make utils compatible with Python 3.

This commit is contained in:
Umair Khan
2016-07-13 13:00:24 +05:00
parent 7901f5d1dc
commit 622a98d6d5
2 changed files with 19 additions and 17 deletions

View File

@@ -59,6 +59,7 @@ def detect_encoding(string):
Defaults to UTF-8.
"""
assert isinstance(string, bytes)
try:
detected = chardet.detect(string)
if detected:
@@ -74,6 +75,7 @@ def quick_detect_encoding(string):
Uses cchardet. Fallbacks to detect_encoding.
"""
assert isinstance(string, bytes)
try:
detected = cchardet.detect(string)
if detected: