From bfa06cead10d975af27ba0a5dd5900324671270f Mon Sep 17 00:00:00 2001 From: thunderstruck47 Date: Sat, 13 May 2017 16:36:25 +0300 Subject: [PATCH 1/3] dont rely on platform specific encoding --- bumblebee/theme.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bumblebee/theme.py b/bumblebee/theme.py index eed2ea7..72a7c0e 100644 --- a/bumblebee/theme.py +++ b/bumblebee/theme.py @@ -109,7 +109,7 @@ class Theme(object): if os.path.isfile(themefile): try: - with open(themefile) as data: + with open(themefile, encoding="utf-8") as data: return json.load(data) except ValueError as exception: raise bumblebee.error.ThemeLoadError("JSON error: {}".format(exception)) From 8d4db0282f22eceaa85f880b1fd8c18bed6aa7ac Mon Sep 17 00:00:00 2001 From: thunderstruck47 Date: Sat, 13 May 2017 17:16:34 +0300 Subject: [PATCH 2/3] explicity encoding only for Python 3 --- bumblebee/theme.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/bumblebee/theme.py b/bumblebee/theme.py index 72a7c0e..2e11877 100644 --- a/bumblebee/theme.py +++ b/bumblebee/theme.py @@ -6,6 +6,7 @@ import os import glob import copy import json +import sys import bumblebee.error @@ -109,8 +110,12 @@ class Theme(object): if os.path.isfile(themefile): try: - with open(themefile, encoding="utf-8") as data: - return json.load(data) + if(sys.version_info > (3,0)): + with open(themefile,encoding="utf-8") as data: + return json.load(data) + else: + with open(themefile) as data: + return json.load(data) except ValueError as exception: raise bumblebee.error.ThemeLoadError("JSON error: {}".format(exception)) else: From 50330e38d1d3192a78ce4bef6f4d588a3241a480 Mon Sep 17 00:00:00 2001 From: thunderstruck47 Date: Sat, 13 May 2017 17:41:43 +0300 Subject: [PATCH 3/3] using io.open, instead of open (python 2.6/2.7) --- bumblebee/theme.py | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/bumblebee/theme.py b/bumblebee/theme.py index 2e11877..e16fbb6 100644 --- a/bumblebee/theme.py +++ b/bumblebee/theme.py @@ -6,7 +6,7 @@ import os import glob import copy import json -import sys +import io import bumblebee.error @@ -110,12 +110,8 @@ class Theme(object): if os.path.isfile(themefile): try: - if(sys.version_info > (3,0)): - with open(themefile,encoding="utf-8") as data: - return json.load(data) - else: - with open(themefile) as data: - return json.load(data) + with io.open(themefile,encoding="utf-8") as data: + return json.load(data) except ValueError as exception: raise bumblebee.error.ThemeLoadError("JSON error: {}".format(exception)) else: