Skip to content

Commit 7c9b9fe

Browse files
committed
chore: remove exception raising for backword compatibility
1 parent 32c7bef commit 7c9b9fe

File tree

2 files changed

+2
-7
lines changed

2 files changed

+2
-7
lines changed

Lib/locale.py

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -557,8 +557,6 @@ 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-
On Windows, raise a `WindowsError` if retrieving the locale fails.
561-
562560
"""
563561

564562
return _getdefaultlocale(envvars)
@@ -571,9 +569,6 @@ def _getdefaultlocale(envvars=('LC_ALL', 'LC_CTYPE', 'LANG', 'LANGUAGE')):
571569
code, encoding = _locale._getdefaultlocale()
572570
except (ImportError, AttributeError):
573571
pass
574-
except OSError as e:
575-
if sys.platform == "win32" and isinstance(e, WindowsError):
576-
raise
577572
else:
578573
# add other platform-specific processing here, if
579574
# necessary...

Modules/_localemodule.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -556,8 +556,8 @@ _locale__getdefaultlocale_impl(PyObject *module)
556556
}
557557

558558
/* cannot determine the language code (very unlikely) */
559-
/* if any of GetLocaleInfoA above failed */
560-
return PyErr_SetFromWindowsErr(0);
559+
Py_INCREF(Py_None);
560+
return Py_BuildValue("Os", Py_None, encoding);
561561
}
562562
#endif
563563

0 commit comments

Comments
 (0)