Skip to content

Commit 676fd91

Browse files
committed
Ignore falsy values in default_locale args
1 parent c8f2145 commit 676fd91

File tree

2 files changed

+4
-1
lines changed

2 files changed

+4
-1
lines changed

babel/core.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1130,6 +1130,8 @@ def default_locale(
11301130
raise TypeError(f"Invalid type for category: {category!r}")
11311131

11321132
for name in varnames:
1133+
if not name:
1134+
continue
11331135
locale = os.getenv(name)
11341136
if locale:
11351137
if name == 'LANGUAGE' and ':' in locale:

tests/test_core.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -278,8 +278,9 @@ def test_default_locale(monkeypatch):
278278

279279

280280
def test_default_locale_multiple_args(monkeypatch):
281-
for name in ['LANGUAGE', 'LC_ALL', 'LC_CTYPE', 'LC_MESSAGES', 'LC_MONETARY', 'LC_NUMERIC']:
281+
for name in ['LANGUAGE', 'LANG', 'LC_ALL', 'LC_CTYPE', 'LC_MESSAGES', 'LC_MONETARY', 'LC_NUMERIC']:
282282
monkeypatch.setenv(name, '')
283+
assert default_locale(["", 0, None]) is None
283284
monkeypatch.setenv('LANG', 'en_US')
284285
assert default_locale(('LC_MONETARY', 'LC_NUMERIC')) == 'en_US' # No LC_MONETARY or LC_NUMERIC set
285286
monkeypatch.setenv('LC_NUMERIC', 'fr_FR.UTF-8')

0 commit comments

Comments
 (0)