Skip to content

Commit

Permalink
Handle errors when _get_websocket_headers() in test environment
Browse files Browse the repository at this point in the history
  • Loading branch information
insolor committed Jul 21, 2024
1 parent 672fb42 commit 6ecde6a
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion package_build/i18n.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,11 @@


def get_preferred_languages() -> list[str]:
headers = _get_websocket_headers() or {}
try:
headers = _get_websocket_headers() or {}
except RuntimeError:
headers = {}

accept_language = headers.get("Accept-Language") or ""
return re.findall(r"([a-zA-Z-]{2,})", accept_language) or []

Expand Down

0 comments on commit 6ecde6a

Please sign in to comment.