Skip to content

Commit 3e132b8

Browse files
committed
fix: don't expose implementation detail
1 parent 9df1c84 commit 3e132b8

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

Lib/locale.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -557,8 +557,7 @@ def getdefaultlocale(envvars=('LC_ALL', 'LC_CTYPE', 'LANG', 'LANGUAGE')):
557557
1766. code and encoding can be None in case the values cannot
558558
be determined.
559559
560-
Raises OSError on Windows if failed to get locale info (unlikely
561-
to happen on modern Windows).
560+
Returns `None` on Windows if failed to get locale info.
562561
563562
"""
564563

@@ -572,6 +571,8 @@ def _getdefaultlocale(envvars=('LC_ALL', 'LC_CTYPE', 'LANG', 'LANGUAGE')):
572571
code, encoding = _locale._getdefaultlocale()
573572
except (ImportError, AttributeError):
574573
pass
574+
except OSError:
575+
return None
575576
else:
576577
# add other platform-specific processing here, if
577578
# necessary...
Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1 @@
1-
Removed Windows 95 compatibility code from :func:`locale.getdefaultlocale`.
2-
Instead, if ``LOCALE_SISO639LANGNAME`` or ``LOCALE_SISO3166CTRYNAME`` cannot be retrieved, an :class:`OSError` is raised.
1+
Removed Windows 95 compatibility for :func:`locale.getdefaultlocale`.

0 commit comments

Comments
 (0)