Kaynağa Gözat

Make Python 3 able to read settings files with Unicode characters

SearX currently doesn't start up when run with Python 3 as it tries to parse the
settings.yml file with ASCII codecs.
There are similar problems with engines_languages.json and currencies.json
Python 3 requires that files with Unicode characters be read with a 'b' flag.
This also works with Python 2 and hence can be integrated into the main source
code.

Tested with the latest Python 3.6.4rc1 on Debian unstable.

Signed-off-by: Joseph Nuthalapati <njoseph@thoughtworks.com>
Joseph Nuthalapati 7 yıl önce
ebeveyn
işleme
bdc803e185
No account linked to committer's email

+ 1
- 1
searx/__init__.py Dosyayı Görüntüle

@@ -50,7 +50,7 @@ if not settings_path:
50 50
     raise Exception('settings.yml not found')
51 51
 
52 52
 # load settings
53
-with open(settings_path) as settings_yaml:
53
+with open(settings_path, 'rb') as settings_yaml:
54 54
     settings = load(settings_yaml)
55 55
 
56 56
 '''

+ 1
- 1
searx/engines/__init__.py Dosyayı Görüntüle

@@ -36,7 +36,7 @@ engines = {}
36 36
 
37 37
 categories = {'general': []}
38 38
 
39
-languages = loads(open(engine_dir + '/../data/engines_languages.json').read())
39
+languages = loads(open(engine_dir + '/../data/engines_languages.json', 'rb').read())
40 40
 
41 41
 engine_shortcuts = {}
42 42
 engine_default_args = {'paging': False,

+ 1
- 1
searx/engines/currency_convert.py Dosyayı Görüntüle

@@ -94,7 +94,7 @@ def load():
94 94
     global db
95 95
 
96 96
     current_dir = os.path.dirname(os.path.realpath(__file__))
97
-    json_data = open(current_dir + "/../data/currencies.json").read()
97
+    json_data = open(current_dir + "/../data/currencies.json", 'rb').read()
98 98
 
99 99
     db = json.loads(json_data)
100 100