From 10cec5bbea358f8abc13de54d106f1cee7e9180e Mon Sep 17 00:00:00 2001 From: Thorsten Date: Wed, 6 Sep 2017 21:51:01 +0200 Subject: [PATCH] python3.4 bug see also https://github.com/mozilla/http-observatory/pull/86/files --- plugins/searx.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/plugins/searx.py b/plugins/searx.py index 058e318..4196e17 100644 --- a/plugins/searx.py +++ b/plugins/searx.py @@ -1,14 +1,15 @@ import logging import time from functools import wraps -from json import JSONDecodeError - +import json import requests from lxml import etree, html from requests import HTTPError search_list = [] +if not hasattr(json, 'JSONDecodeError'): + json.JSONDecodeError = ValueError class RateLimitingError(HTTPError): pass @@ -69,7 +70,7 @@ def fetch_all_searx_engines(): return searxes -@retry(ExceptionToCheck=(RateLimitingError, JSONDecodeError)) +@retry(ExceptionToCheck=(RateLimitingError, json.JSONDecodeError)) def searx(text): global search_list if not search_list: @@ -88,7 +89,7 @@ def searx(text): raise RateLimitingError(response=response, request=response.request) try: response = response.json() - except JSONDecodeError as e: + except json.JSONDecodeError: # "maintenance" they say... search_list.pop() raise