From 911efd1db4caedd7762896ddffa15492bfdbbdd1 Mon Sep 17 00:00:00 2001 From: Umair Khan Date: Tue, 19 Jul 2016 09:44:40 +0500 Subject: [PATCH] Move encoding detection inside if condition. --- talon/utils.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/talon/utils.py b/talon/utils.py index ebabdf1..02a7a92 100644 --- a/talon/utils.py +++ b/talon/utils.py @@ -47,8 +47,8 @@ def to_unicode(str_or_unicode, precise=False): u'привет' If `precise` flag is True, tries to guess the correct encoding first. """ - encoding = quick_detect_encoding(str_or_unicode) if precise else 'utf-8' if not isinstance(str_or_unicode, six.text_type): + encoding = quick_detect_encoding(str_or_unicode) if precise else 'utf-8' return six.text_type(str_or_unicode, encoding, 'replace') return str_or_unicode