Skip to content

Commit

Permalink
pythongh-73427: deprecate _enablelegacywindowsfsencoding (python#10…
Browse files Browse the repository at this point in the history
  • Loading branch information
methane authored Dec 28, 2023
1 parent 7ab9efd commit bfee2f7
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 0 deletions.
8 changes: 8 additions & 0 deletions Doc/library/sys.rst
Original file line number Diff line number Diff line change
Expand Up @@ -1744,9 +1744,17 @@ always available.

.. availability:: Windows.

.. note::
Changing the filesystem encoding after Python startup is risky because
the old fsencoding or paths encoded by the old fsencoding may be cached
somewhere. Use :envvar:`PYTHONLEGACYWINDOWSFSENCODING` instead.

.. versionadded:: 3.6
See :pep:`529` for more details.

.. deprecated-removed:: 3.13 3.16
Use :envvar:`PYTHONLEGACYWINDOWSFSENCODING` instead.

.. data:: stdin
stdout
stderr
Expand Down
4 changes: 4 additions & 0 deletions Doc/whatsnew/3.13.rst
Original file line number Diff line number Diff line change
Expand Up @@ -474,6 +474,10 @@ Deprecated
security and functionality bugs. This includes removal of the ``--cgi``
flag to the ``python -m http.server`` command line in 3.15.

* :mod:`sys`: :func:`sys._enablelegacywindowsfsencoding` function.
Replace it with :envvar:`PYTHONLEGACYWINDOWSFSENCODING` environment variable.
(Contributed by Inada Naoki in :gh:`73427`.)

* :mod:`traceback`:

* The field *exc_type* of :class:`traceback.TracebackException` is
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Deprecate :func:`sys._enablelegacywindowsfsencoding`. Use
:envvar:`PYTHONLEGACYWINDOWSFSENCODING` instead. Patch by Inada Naoki.
7 changes: 7 additions & 0 deletions Python/sysmodule.c
Original file line number Diff line number Diff line change
Expand Up @@ -1715,6 +1715,13 @@ 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;
}
Expand Down

0 comments on commit bfee2f7

Please sign in to comment.