From 83f36dd80f20c1290b765574acbebec682ca42c8 Mon Sep 17 00:00:00 2001 From: Elad Alfassa Date: Thu, 1 May 2014 01:23:44 +0300 Subject: [PATCH] [translate] Fix unicode in translate.py web returns a bytestring, we needed a unicodestring --- translate.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/translate.py b/translate.py index 3d42b0474d..9dbe2f77dd 100644 --- a/translate.py +++ b/translate.py @@ -58,8 +58,10 @@ def translate(text, in_lang='auto', out_lang='en'): ) url = "http://translate.google.com/translate_a/t?{query}".format(query=query_string) result = web.get(url, timeout=40, headers=headers) - if sys.version_info.major>=3: + if sys.version_info.major >= 3: result = result.decode() + elif isinstance(result, str): + result = result.decode('utf-8') while ',,' in result: result = result.replace(',,', ',null,')