Browse Source

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
Alexandre Flament 4 years ago
parent
commit
bdac99d4f0
1 changed files with 3 additions and 1 deletions
  1. 3 1
      searx/utils.py

+ 3 - 1
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: