From 916a28cd9a229db708542ec878a2e924bc351f14 Mon Sep 17 00:00:00 2001 From: Victor Stinner Date: Wed, 19 Jun 2024 15:37:42 +0200 Subject: [PATCH 1/2] gh-120743: Soft deprecate os.popen() function Soft deprecate os.popen(), os.spawn*() and os.system() functions. --- Doc/library/os.rst | 14 +++++++++++++- Doc/whatsnew/3.14.rst | 6 ++++++ .../2024-06-19-15-43-04.gh-issue-120743.CMMl2P.rst | 4 ++++ 3 files changed, 23 insertions(+), 1 deletion(-) create mode 100644 Misc/NEWS.d/next/Library/2024-06-19-15-43-04.gh-issue-120743.CMMl2P.rst diff --git a/Doc/library/os.rst b/Doc/library/os.rst index 360d71e70960c7..7104a5db3eb351 100644 --- a/Doc/library/os.rst +++ b/Doc/library/os.rst @@ -4642,6 +4642,10 @@ written in Python, such as a mail server's external command delivery program. Use :class:`subprocess.Popen` or :func:`subprocess.run` to control options like encodings. + .. deprecated:: 3.14 + The function is :term:`soft deprecated` and should no longer be used to + write new code. The :mod:`subprocess` module is recommended instead. + .. function:: posix_spawn(path, argv, env, *, file_actions=None, \ setpgroup=None, resetids=False, setsid=False, setsigmask=(), \ @@ -4868,6 +4872,10 @@ written in Python, such as a mail server's external command delivery program. .. versionchanged:: 3.6 Accepts a :term:`path-like object`. + .. deprecated:: 3.14 + These functions are :term:`soft deprecated` and should no longer be used + to write new code. The :mod:`subprocess` module is recommended instead. + .. data:: P_NOWAIT P_NOWAITO @@ -4972,7 +4980,7 @@ written in Python, such as a mail server's external command delivery program. shell documentation. The :mod:`subprocess` module provides more powerful facilities for spawning - new processes and retrieving their results; using that module is preferable + new processes and retrieving their results; using that module is recommended to using this function. See the :ref:`subprocess-replacements` section in the :mod:`subprocess` documentation for some helpful recipes. @@ -4984,6 +4992,10 @@ written in Python, such as a mail server's external command delivery program. .. availability:: Unix, Windows, not WASI, not iOS. + .. deprecated:: 3.14 + The function is :term:`soft deprecated` and should no longer be used to + write new code. The :mod:`subprocess` module is recommended instead. + .. function:: times() diff --git a/Doc/whatsnew/3.14.rst b/Doc/whatsnew/3.14.rst index 804d39ab64646d..7cfbe7c8ee97bf 100644 --- a/Doc/whatsnew/3.14.rst +++ b/Doc/whatsnew/3.14.rst @@ -133,6 +133,12 @@ Deprecated as a single positional argument. (Contributed by Serhiy Storchaka in :gh:`109218`.) +* :term:`Soft deprecate ` :func:`os.popen`, + :func:`os.spawn* ` and :func:`os.system` functions. They should no + longer be used to write new code. The :mod:`subprocess` module is + recommended instead. + (Contributed by Victor Stinner in :gh:`120743`.) + Removed ======= diff --git a/Misc/NEWS.d/next/Library/2024-06-19-15-43-04.gh-issue-120743.CMMl2P.rst b/Misc/NEWS.d/next/Library/2024-06-19-15-43-04.gh-issue-120743.CMMl2P.rst new file mode 100644 index 00000000000000..8ef9629b7baeef --- /dev/null +++ b/Misc/NEWS.d/next/Library/2024-06-19-15-43-04.gh-issue-120743.CMMl2P.rst @@ -0,0 +1,4 @@ +:term:`Soft deprecate ` :func:`os.popen`, :func:`os.spawn* +` and :func:`os.system` functions. They should no longer be used to +write new code. The :mod:`subprocess` module is recommended instead. Patch by +Victor Stinner. From 98eab4eb3b4e36b7f4b7a642800b4b5d7d075766 Mon Sep 17 00:00:00 2001 From: Victor Stinner Date: Mon, 1 Jul 2024 17:54:31 +0200 Subject: [PATCH 2/2] Don't deprecate os.system() --- Doc/library/os.rst | 4 ---- Doc/whatsnew/3.14.rst | 7 +++---- .../Library/2024-06-19-15-43-04.gh-issue-120743.CMMl2P.rst | 7 +++---- 3 files changed, 6 insertions(+), 12 deletions(-) diff --git a/Doc/library/os.rst b/Doc/library/os.rst index 7104a5db3eb351..8d95d01fe55ed9 100644 --- a/Doc/library/os.rst +++ b/Doc/library/os.rst @@ -4992,10 +4992,6 @@ written in Python, such as a mail server's external command delivery program. .. availability:: Unix, Windows, not WASI, not iOS. - .. deprecated:: 3.14 - The function is :term:`soft deprecated` and should no longer be used to - write new code. The :mod:`subprocess` module is recommended instead. - .. function:: times() diff --git a/Doc/whatsnew/3.14.rst b/Doc/whatsnew/3.14.rst index 7cfbe7c8ee97bf..80bf3567859b58 100644 --- a/Doc/whatsnew/3.14.rst +++ b/Doc/whatsnew/3.14.rst @@ -133,10 +133,9 @@ Deprecated as a single positional argument. (Contributed by Serhiy Storchaka in :gh:`109218`.) -* :term:`Soft deprecate ` :func:`os.popen`, - :func:`os.spawn* ` and :func:`os.system` functions. They should no - longer be used to write new code. The :mod:`subprocess` module is - recommended instead. +* :term:`Soft deprecate ` :func:`os.popen` and + :func:`os.spawn* ` functions. They should no longer be used to + write new code. The :mod:`subprocess` module is recommended instead. (Contributed by Victor Stinner in :gh:`120743`.) diff --git a/Misc/NEWS.d/next/Library/2024-06-19-15-43-04.gh-issue-120743.CMMl2P.rst b/Misc/NEWS.d/next/Library/2024-06-19-15-43-04.gh-issue-120743.CMMl2P.rst index 8ef9629b7baeef..e06dcf8af26a60 100644 --- a/Misc/NEWS.d/next/Library/2024-06-19-15-43-04.gh-issue-120743.CMMl2P.rst +++ b/Misc/NEWS.d/next/Library/2024-06-19-15-43-04.gh-issue-120743.CMMl2P.rst @@ -1,4 +1,3 @@ -:term:`Soft deprecate ` :func:`os.popen`, :func:`os.spawn* -` and :func:`os.system` functions. They should no longer be used to -write new code. The :mod:`subprocess` module is recommended instead. Patch by -Victor Stinner. +:term:`Soft deprecate ` :func:`os.popen` and :func:`os.spawn* +` functions. They should no longer be used to write new code. The +:mod:`subprocess` module is recommended instead. Patch by Victor Stinner.