Dear maintainer,

Please find the attached patch for the bug.

Submitted the same patch to the upstream.
Added appropriate headers to the patch for tracking the upstream bug.

-- 
Regards
Joseph Nuthalapati

From bdc803e185e1a7bb14892405a2c0c840ba6e0fe1 Mon Sep 17 00:00:00 2001
From: Joseph Nuthalapati <njos...@thoughtworks.com>
Date: Tue, 19 Dec 2017 13:04:18 +0530
Bug-debian: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=886093
Forwarded: https://github.com/asciimoo/searx/pull/1124
Reviewed-by: Sunil Mohan Adapa <su...@medhas.org>
Subject: [PATCH] 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 <njos...@thoughtworks.com>
---
 searx/__init__.py                 | 2 +-
 searx/engines/__init__.py         | 2 +-
 searx/engines/currency_convert.py | 2 +-
 3 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/searx/__init__.py b/searx/__init__.py
index a57588c..84a377d 100644
--- a/searx/__init__.py
+++ b/searx/__init__.py
@@ -50,7 +50,7 @@ if not settings_path:
     raise Exception('settings.yml not found')
 
 # load settings
-with open(settings_path) as settings_yaml:
+with open(settings_path, 'rb') as settings_yaml:
     settings = load(settings_yaml)
 
 '''
diff --git a/searx/engines/__init__.py b/searx/engines/__init__.py
index 7a9cc56..bec8de3 100644
--- a/searx/engines/__init__.py
+++ b/searx/engines/__init__.py
@@ -36,7 +36,7 @@ engines = {}
 
 categories = {'general': []}
 
-languages = loads(open(engine_dir + '/../data/engines_languages.json').read())
+languages = loads(open(engine_dir + '/../data/engines_languages.json', 'rb').read())
 
 engine_shortcuts = {}
 engine_default_args = {'paging': False,
diff --git a/searx/engines/currency_convert.py b/searx/engines/currency_convert.py
index 1bb4e60..34a9af6 100644
--- a/searx/engines/currency_convert.py
+++ b/searx/engines/currency_convert.py
@@ -94,7 +94,7 @@ def load():
     global db
 
     current_dir = os.path.dirname(os.path.realpath(__file__))
-    json_data = open(current_dir + "/../data/currencies.json").read()
+    json_data = open(current_dir + "/../data/currencies.json", 'rb').read()
 
     db = json.loads(json_data)
 
-- 
2.15.1

Attachment: signature.asc
Description: OpenPGP digital signature

Reply via email to