gh-149595: Remove the sys._enablelegacywindowsfsencoding() function (#149596)

Co-authored-by: Hugo van Kemenade <1324225+hugovk@users.noreply.github.com>
This commit is contained in:
Stan Ulbrych 2026-05-12 17:11:34 +01:00 committed by GitHub
parent 058c12528d
commit 6a0be131c3
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
14 changed files with 18 additions and 145 deletions

View file

@ -1790,36 +1790,6 @@ sys_getwindowsversion_impl(PyObject *module)
}
#pragma warning(pop)
/*[clinic input]
sys._enablelegacywindowsfsencoding
Changes the default filesystem encoding to mbcs:replace.
This is done for consistency with earlier versions of Python. See PEP
529 for more information.
This is equivalent to defining the PYTHONLEGACYWINDOWSFSENCODING
environment variable before launching Python.
[clinic start generated code]*/
static PyObject *
sys__enablelegacywindowsfsencoding_impl(PyObject *module)
/*[clinic end generated code: output=f5c3855b45e24fe9 input=2bfa931a20704492]*/
{
if (PyErr_WarnEx(PyExc_DeprecationWarning,
"sys._enablelegacywindowsfsencoding() is deprecated and will be "
"removed in Python 3.16. Use PYTHONLEGACYWINDOWSFSENCODING "
"instead.", 1))
{
return NULL;
}
if (_PyUnicode_EnableLegacyWindowsFSEncoding() < 0) {
return NULL;
}
Py_RETURN_NONE;
}
#endif /* MS_WINDOWS */
#ifdef HAVE_DLOPEN
@ -2941,7 +2911,6 @@ static PyMethodDef sys_methods[] = {
SYS__GETFRAME_METHODDEF
SYS__GETFRAMEMODULENAME_METHODDEF
SYS_GETWINDOWSVERSION_METHODDEF
SYS__ENABLELEGACYWINDOWSFSENCODING_METHODDEF
SYS__IS_IMMORTAL_METHODDEF
SYS_INTERN_METHODDEF
SYS__IS_INTERNED_METHODDEF
@ -3436,13 +3405,6 @@ winver -- [Windows only] version number of the Python DLL\n\
"
)
#endif /* MS_COREDLL */
#ifdef MS_WINDOWS
/* concatenating string here */
PyDoc_STR(
"_enablelegacywindowsfsencoding -- [Windows only]\n\
"
)
#endif
PyDoc_STR(
"__stdin__ -- the original stdin; don't touch!\n\
__stdout__ -- the original stdout; don't touch!\n\