From bdac99d4f0349a71d7ecb9a4c61687356afedd6b Mon Sep 17 00:00:00 2001 From: Alexandre Flament Date: Tue, 8 Sep 2020 16:08:37 +0200 Subject: [PATCH] Drop Python 2 (5/n): searx.utils.is_valid_lang, input parameter is a str instead of bytes Fix bug in translated.py and dictzone.py --- searx/utils.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/searx/utils.py b/searx/utils.py index de5b68ca3..d8842c65f 100644 --- a/searx/utils.py +++ b/searx/utils.py @@ -284,8 +284,10 @@ def int_or_zero(num): def is_valid_lang(lang): + if isinstance(lang, bytes): + lang = lang.decode() is_abbr = (len(lang) == 2) - lang = lang.lower().decode() + lang = lang.lower() if is_abbr: for l in language_codes: if l[0][:2] == lang: