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
1 changed files with 6 additions and 2 deletions

View File

@ -331,8 +331,12 @@ class ClientPref:
except (ValueError, babel.core.UnknownLocaleError): except (ValueError, babel.core.UnknownLocaleError):
continue continue
pairs.append((locale, qvalue)) pairs.append((locale, qvalue))
locale = None
if pairs:
pairs.sort(reverse=True, key=lambda x: x[1]) pairs.sort(reverse=True, key=lambda x: x[1])
return cls(locale=pairs[0][0]) locale = pairs[0][0]
return cls(locale=locale)
class Preferences: class Preferences: