summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--searx/preferences.py8
1 files changed, 6 insertions, 2 deletions
diff --git a/searx/preferences.py b/searx/preferences.py
index 8552305a7..aba712652 100644
--- a/searx/preferences.py
+++ b/searx/preferences.py
@@ -331,8 +331,12 @@ class ClientPref:
except (ValueError, babel.core.UnknownLocaleError):
continue
pairs.append((locale, qvalue))
- pairs.sort(reverse=True, key=lambda x: x[1])
- return cls(locale=pairs[0][0])
+
+ locale = None
+ if pairs:
+ pairs.sort(reverse=True, key=lambda x: x[1])
+ locale = pairs[0][0]
+ return cls(locale=locale)
class Preferences: