]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
gh-123853: Cleanup Windows 95 locale fallback support (#144738)
author莯凛 <34085039+mokurin000@users.noreply.github.com>
Fri, 27 Feb 2026 10:06:46 +0000 (18:06 +0800)
committerGitHub <noreply@github.com>
Fri, 27 Feb 2026 10:06:46 +0000 (11:06 +0100)
Closes #123853

Lib/locale.py
Misc/NEWS.d/next/Library/2026-02-21-17-34-53.gh-issue-123853.6RUwWh.rst [new file with mode: 0644]
Modules/_localemodule.c

index dea3ee55cf4d24c24de082d55731f61327a729c0..e7382796905ebd491a9f5b94ab780fbfeb994a8e 100644 (file)
@@ -570,10 +570,6 @@ def _getdefaultlocale(envvars=('LC_ALL', 'LC_CTYPE', 'LANG', 'LANGUAGE')):
     except (ImportError, AttributeError):
         pass
     else:
-        # make sure the code/encoding values are valid
-        if sys.platform == "win32" and code and code[:2] == "0x":
-            # map windows language identifier to language name
-            code = windows_locale.get(int(code, 0))
         # ...add other platform-specific processing here, if
         # necessary...
         return code, encoding
diff --git a/Misc/NEWS.d/next/Library/2026-02-21-17-34-53.gh-issue-123853.6RUwWh.rst b/Misc/NEWS.d/next/Library/2026-02-21-17-34-53.gh-issue-123853.6RUwWh.rst
new file mode 100644 (file)
index 0000000..1babcbf
--- /dev/null
@@ -0,0 +1 @@
+Removed Windows 95 compatibility for :func:`locale.getdefaultlocale`.\r
index f0a418ee5024e3fd6986e033183c7bc076e9715f..86a390e52a554bc16336f881cbbdd4cfec5fa226 100644 (file)
@@ -555,17 +555,6 @@ _locale__getdefaultlocale_impl(PyObject *module)
             return Py_BuildValue("ss", locale, encoding);
     }
 
-    /* If we end up here, this windows version didn't know about
-       ISO639/ISO3166 names (it's probably Windows 95).  Return the
-       Windows language identifier instead (a hexadecimal number) */
-
-    locale[0] = '0';
-    locale[1] = 'x';
-    if (GetLocaleInfoA(LOCALE_USER_DEFAULT, LOCALE_IDEFAULTLANGUAGE,
-                      locale+2, sizeof(locale)-2)) {
-        return Py_BuildValue("ss", locale, encoding);
-    }
-
     /* cannot determine the language code (very unlikely) */
     return Py_BuildValue("Os", Py_None, encoding);
 }