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
This commit is contained in:
Alexandre Flament 2020-09-08 16:08:37 +02:00
parent c225db45c8
commit bdac99d4f0

View file

@ -284,8 +284,10 @@ def int_or_zero(num):
def is_valid_lang(lang): def is_valid_lang(lang):
if isinstance(lang, bytes):
lang = lang.decode()
is_abbr = (len(lang) == 2) is_abbr = (len(lang) == 2)
lang = lang.lower().decode() lang = lang.lower()
if is_abbr: if is_abbr:
for l in language_codes: for l in language_codes:
if l[0][:2] == lang: if l[0][:2] == lang: