Skip to content

Commit 7e25c56

Browse files
Remove deprecated sys._enablelegacywindowsfsencoding function
1 parent 46a2c11 commit 7e25c56

13 files changed

Lines changed: 16 additions & 144 deletions

File tree

Doc/deprecations/pending-removal-in-3.16.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ Pending removal in Python 3.16
8989

9090
* :mod:`sys`:
9191

92-
* The :func:`~sys._enablelegacywindowsfsencoding` function
92+
* The :func:`!sys._enablelegacywindowsfsencoding` function
9393
has been deprecated since Python 3.13.
9494
Use the :envvar:`PYTHONLEGACYWINDOWSFSENCODING` environment variable instead.
9595

Doc/library/sys.rst

Lines changed: 1 addition & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -879,7 +879,7 @@ always available. Unless explicitly noted otherwise, all variables are read-only
879879

880880
.. versionchanged:: 3.6
881881
Windows is no longer guaranteed to return ``'mbcs'``. See :pep:`529`
882-
and :func:`_enablelegacywindowsfsencoding` for more information.
882+
for more information.
883883

884884
.. versionchanged:: 3.7
885885
Return ``'utf-8'`` if the :ref:`Python UTF-8 Mode <utf8-mode>` is
@@ -2107,31 +2107,6 @@ always available. Unless explicitly noted otherwise, all variables are read-only
21072107
See :pep:`768` for more details.
21082108

21092109

2110-
.. function:: _enablelegacywindowsfsencoding()
2111-
2112-
Changes the :term:`filesystem encoding and error handler` to 'mbcs' and
2113-
'replace' respectively, for consistency with versions of Python prior to
2114-
3.6.
2115-
2116-
This is equivalent to defining the :envvar:`PYTHONLEGACYWINDOWSFSENCODING`
2117-
environment variable before launching Python.
2118-
2119-
See also :func:`sys.getfilesystemencoding` and
2120-
:func:`sys.getfilesystemencodeerrors`.
2121-
2122-
.. availability:: Windows.
2123-
2124-
.. note::
2125-
Changing the filesystem encoding after Python startup is risky because
2126-
the old fsencoding or paths encoded by the old fsencoding may be cached
2127-
somewhere. Use :envvar:`PYTHONLEGACYWINDOWSFSENCODING` instead.
2128-
2129-
.. versionadded:: 3.6
2130-
See :pep:`529` for more details.
2131-
2132-
.. deprecated-removed:: 3.13 3.16
2133-
Use :envvar:`PYTHONLEGACYWINDOWSFSENCODING` instead.
2134-
21352110
.. data:: stdin
21362111
stdout
21372112
stderr

Doc/using/cmdline.rst

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1154,9 +1154,6 @@ conflict.
11541154
'replace', respectively. Otherwise, the new defaults 'utf-8' and
11551155
'surrogatepass' are used.
11561156

1157-
This may also be enabled at runtime with
1158-
:func:`sys._enablelegacywindowsfsencoding`.
1159-
11601157
.. availability:: Windows.
11611158

11621159
.. versionadded:: 3.6

Doc/whatsnew/3.13.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1958,7 +1958,7 @@ New Deprecations
19581958

19591959
* :mod:`sys`:
19601960

1961-
* Deprecate the :func:`~sys._enablelegacywindowsfsencoding` function,
1961+
* Deprecate the :func:`!sys._enablelegacywindowsfsencoding` function,
19621962
to be removed in Python 3.16.
19631963
Use the :envvar:`PYTHONLEGACYWINDOWSFSENCODING` environment variable instead.
19641964
(Contributed by Inada Naoki in :gh:`73427`.)

Doc/whatsnew/3.16.rst

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,14 @@ symtable
126126
* The :meth:`!symtable.Class.get_methods` method
127127
which has been deprecated since Python 3.14.
128128

129+
sys
130+
---
131+
132+
* The :func:`!sys._enablelegacywindowsfsencoding` function
133+
which has been deprecated since Python 3.13.
134+
Use the :envvar:`PYTHONLEGACYWINDOWSFSENCODING` environment variable instead.
135+
(Contributed by Stan Ulbrych in :gh:`149595`.)
136+
129137
sysconfig
130138
---------
131139

Doc/whatsnew/3.6.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -517,7 +517,7 @@ Applications that do not use str to represent paths should use
517517
:func:`os.fsencode` and :func:`os.fsdecode` to ensure their bytes are
518518
correctly encoded. To revert to the previous behaviour, set
519519
:envvar:`PYTHONLEGACYWINDOWSFSENCODING` or call
520-
:func:`sys._enablelegacywindowsfsencoding`.
520+
:func:`!sys._enablelegacywindowsfsencoding`.
521521

522522
See :pep:`529` for more information and discussion of code modifications that
523523
may be required.

Include/internal/pycore_pylifecycle.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,6 @@ extern int _Py_SetFileSystemEncoding(
1818
const char *errors);
1919
extern void _Py_ClearFileSystemEncoding(void);
2020
extern PyStatus _PyUnicode_InitEncodings(PyThreadState *tstate);
21-
#ifdef MS_WINDOWS
22-
extern int _PyUnicode_EnableLegacyWindowsFSEncoding(void);
23-
#endif
2421

2522
extern int _Py_IsLocaleCoercionTarget(const char *ctype_loc);
2623

Lib/test/test_sys.py

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1283,16 +1283,6 @@ def check(tracebacklimit, expected):
12831283
def test_no_duplicates_in_meta_path(self):
12841284
self.assertEqual(len(sys.meta_path), len(set(sys.meta_path)))
12851285

1286-
@unittest.skipUnless(hasattr(sys, "_enablelegacywindowsfsencoding"),
1287-
'needs sys._enablelegacywindowsfsencoding()')
1288-
def test__enablelegacywindowsfsencoding(self):
1289-
code = ('import sys',
1290-
'sys._enablelegacywindowsfsencoding()',
1291-
'print(sys.getfilesystemencoding(), sys.getfilesystemencodeerrors())')
1292-
rc, out, err = assert_python_ok('-c', '; '.join(code))
1293-
out = out.decode('ascii', 'replace').rstrip()
1294-
self.assertEqual(out, 'mbcs replace')
1295-
12961286
@support.requires_subprocess()
12971287
def test_orig_argv(self):
12981288
code = textwrap.dedent('''

Misc/NEWS.d/3.13.0a3.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2166,7 +2166,7 @@ current user has no permission to the WMI.
21662166
.. nonce: WOpiNt
21672167
.. section: Windows
21682168
2169-
Deprecate :func:`sys._enablelegacywindowsfsencoding`. Use
2169+
Deprecate :func:`!sys._enablelegacywindowsfsencoding`. Use
21702170
:envvar:`PYTHONLEGACYWINDOWSFSENCODING` instead. Patch by Inada Naoki.
21712171

21722172
..
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
Remove the :func:`!sys._enablelegacywindowsfsencoding` function which has
2+
been deprecated since Python 3.13.

0 commit comments

Comments
 (0)