Merge pull request #2452 from return42/fix-2434

[fix] ClientPref - don't raise exception if Accept-Language is invalid
This commit is contained in:
Markus Heiser 2023-05-22 12:46:26 +02:00 committed by GitHub
commit cea277ce52
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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: