summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAdam Tauber <asciimoo@gmail.com>2018-01-17 22:05:08 +0100
committerGitHub <noreply@github.com>2018-01-17 22:05:08 +0100
commit4ad5e6ad4f1e5ce89eb7d1135ada712fdd9ce6b6 (patch)
tree38b9bbabbdfc6a343be30ccdc519643ee6fccdc3
parent8511e64f350b4b31db314a5d74ef77dd5b97b5f3 (diff)
parent829032f306cec8f6d109bfb037a01dc50ff87442 (diff)
downloadsearxng-4ad5e6ad4f1e5ce89eb7d1135ada712fdd9ce6b6.tar.gz
searxng-4ad5e6ad4f1e5ce89eb7d1135ada712fdd9ce6b6.zip
Merge pull request #1148 from MarcAbonce/python3.5-fix
[fix] Read utf-8 files (settings, languages, currency) with Python3.5
-rw-r--r--.travis.yml1
-rw-r--r--searx/__init__.py3
-rw-r--r--searx/engines/__init__.py3
-rw-r--r--searx/engines/currency_convert.py3
4 files changed, 7 insertions, 3 deletions
diff --git a/.travis.yml b/.travis.yml
index 0dde8317d..08bcfaadd 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -9,6 +9,7 @@ addons:
language: python
python:
- "2.7"
+ - "3.5"
- "3.6"
before_install:
- "export DISPLAY=:99.0"
diff --git a/searx/__init__.py b/searx/__init__.py
index d277570bb..b1010f25f 100644
--- a/searx/__init__.py
+++ b/searx/__init__.py
@@ -19,6 +19,7 @@ import certifi
import logging
from os import environ
from os.path import realpath, dirname, join, abspath, isfile
+from io import open
from ssl import OPENSSL_VERSION_INFO, OPENSSL_VERSION
try:
from yaml import load
@@ -50,7 +51,7 @@ if not settings_path:
raise Exception('settings.yml not found')
# load settings
-with open(settings_path, 'rb') as settings_yaml:
+with open(settings_path, 'r', encoding='utf-8') as settings_yaml:
settings = load(settings_yaml)
'''
diff --git a/searx/engines/__init__.py b/searx/engines/__init__.py
index bec8de3a8..b4479157b 100644
--- a/searx/engines/__init__.py
+++ b/searx/engines/__init__.py
@@ -19,6 +19,7 @@ along with searx. If not, see < http://www.gnu.org/licenses/ >.
import sys
import threading
from os.path import realpath, dirname
+from io import open
from flask_babel import gettext
from operator import itemgetter
from json import loads
@@ -36,7 +37,7 @@ engines = {}
categories = {'general': []}
-languages = loads(open(engine_dir + '/../data/engines_languages.json', 'rb').read())
+languages = loads(open(engine_dir + '/../data/engines_languages.json', 'r', encoding='utf-8').read())
engine_shortcuts = {}
engine_default_args = {'paging': False,
diff --git a/searx/engines/currency_convert.py b/searx/engines/currency_convert.py
index 34a9af678..9c1c2f7b3 100644
--- a/searx/engines/currency_convert.py
+++ b/searx/engines/currency_convert.py
@@ -4,6 +4,7 @@ import os
import sys
import unicodedata
+from io import open
from datetime import datetime
if sys.version_info[0] == 3:
@@ -94,7 +95,7 @@ def load():
global db
current_dir = os.path.dirname(os.path.realpath(__file__))
- json_data = open(current_dir + "/../data/currencies.json", 'rb').read()
+ json_data = open(current_dir + "/../data/currencies.json", 'r', encoding='utf-8').read()
db = json.loads(json_data)