Browse Source

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 years ago
parent
commit
bdc803e185
No account linked to committer's email
3 changed files with 3 additions and 3 deletions
  1. 1
    1
      searx/__init__.py
  2. 1
    1
      searx/engines/__init__.py
  3. 1
    1
      searx/engines/currency_convert.py

+ 1
- 1
searx/__init__.py View File

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

+ 1
- 1
searx/engines/__init__.py View File

36
 
36
 
37
 categories = {'general': []}
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
 engine_shortcuts = {}
41
 engine_shortcuts = {}
42
 engine_default_args = {'paging': False,
42
 engine_default_args = {'paging': False,

+ 1
- 1
searx/engines/currency_convert.py View File

94
     global db
94
     global db
95
 
95
 
96
     current_dir = os.path.dirname(os.path.realpath(__file__))
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
     db = json.loads(json_data)
99
     db = json.loads(json_data)
100
 
100