From a3260467331ff188a63d033d27bc587eb566f8f6 Mon Sep 17 00:00:00 2001 From: Alan Hamlett Date: Thu, 22 Sep 2016 10:24:20 +0200 Subject: [PATCH] handle UnicodeDecodeError when looking for python to fix #68 --- WakaTime.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/WakaTime.py b/WakaTime.py index 9ef326f..04eec74 100644 --- a/WakaTime.py +++ b/WakaTime.py @@ -54,7 +54,7 @@ if is_py2: try: return unicode(text) except: - return text + return text.decode('utf-8', 'replace') elif is_py3: def u(text): @@ -71,7 +71,7 @@ elif is_py3: try: return str(text) except: - return text + return text.decode('utf-8', 'replace') else: raise Exception('Unsupported Python version: {0}.{1}.{2}'.format( @@ -314,7 +314,7 @@ def find_python_in_folder(folder, headless=True): path = os.path.realpath(os.path.join(folder, 'python')) if headless: path = u(path) + u('w') - log(DEBUG, u('Looking for Python at: {0}').format(path)) + log(DEBUG, u('Looking for Python at: {0}').format(u(path))) try: process = Popen([path, '--version'], stdout=PIPE, stderr=STDOUT) output, err = process.communicate()