Skip to content

Commit 5b3e6bc

Browse files
committed
chore: remove Windows 95 locale fall back code path
detect exception for Windows getdefaultlocale, once any of required constant was unavaliable, fall back to POSIX behaviour.
1 parent 7258dbc commit 5b3e6bc

File tree

2 files changed

+7
-17
lines changed

2 files changed

+7
-17
lines changed

Lib/locale.py

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -570,13 +570,14 @@ def _getdefaultlocale(envvars=('LC_ALL', 'LC_CTYPE', 'LANG', 'LANGUAGE')):
570570
except (ImportError, AttributeError):
571571
pass
572572
else:
573-
# make sure the code/encoding values are valid
574-
if sys.platform == "win32" and code and code[:2] == "0x":
575-
# map windows language identifier to language name
576-
code = windows_locale.get(int(code, 0))
577-
# ...add other platform-specific processing here, if
573+
# add other platform-specific processing here, if
578574
# necessary...
579-
return code, encoding
575+
# for Windows, for any reason if the code was
576+
# not avaliable, fall back to POSIX behaviour
577+
if sys.platform == "win32" and code is None:
578+
pass
579+
else:
580+
return code, encoding
580581

581582
# fall back on POSIX behaviour
582583
import os

Modules/_localemodule.c

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -555,17 +555,6 @@ _locale__getdefaultlocale_impl(PyObject *module)
555555
return Py_BuildValue("ss", locale, encoding);
556556
}
557557

558-
/* If we end up here, this windows version didn't know about
559-
ISO639/ISO3166 names (it's probably Windows 95). Return the
560-
Windows language identifier instead (a hexadecimal number) */
561-
562-
locale[0] = '0';
563-
locale[1] = 'x';
564-
if (GetLocaleInfoA(LOCALE_USER_DEFAULT, LOCALE_IDEFAULTLANGUAGE,
565-
locale+2, sizeof(locale)-2)) {
566-
return Py_BuildValue("ss", locale, encoding);
567-
}
568-
569558
/* cannot determine the language code (very unlikely) */
570559
Py_INCREF(Py_None);
571560
return Py_BuildValue("Os", Py_None, encoding);

0 commit comments

Comments
 (0)