Skip to content

Commit ba4f218

Browse files
miss-islingtonpablogsal
authored andcommitted
bpo-32815: Improve docs on the subprocess API *text* parameter (GH-5622) (GH-5631)
Describe *text* as an alias for *universal_newlines* in more places that people are likely to be referred to. (cherry picked from commit e14c010) Co-authored-by: Pablo Galindo <[email protected]>
1 parent 09df4b7 commit ba4f218

File tree

1 file changed

+15
-8
lines changed

1 file changed

+15
-8
lines changed

Doc/library/subprocess.rst

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ compatibility with older versions, see the :ref:`call-function-trio` section.
3939

4040
.. function:: run(args, *, stdin=None, input=None, stdout=None, stderr=None,\
4141
shell=False, cwd=None, timeout=None, check=False, \
42-
encoding=None, errors=None)
42+
encoding=None, errors=None, text=None)
4343

4444
Run the command described by *args*. Wait for command to complete, then
4545
return a :class:`CompletedProcess` instance.
@@ -267,7 +267,8 @@ default values. The arguments that are most commonly needed are:
267267
.. index::
268268
single: universal newlines; subprocess module
269269

270-
If *encoding* or *errors* are specified, or *universal_newlines* is true,
270+
If *encoding* or *errors* are specified, or *text* (also known as
271+
*universal_newlines*) is true,
271272
the file objects *stdin*, *stdout* and *stderr* will be opened in text
272273
mode using the *encoding* and *errors* specified in the call or the
273274
defaults for :class:`io.TextIOWrapper`.
@@ -284,6 +285,9 @@ default values. The arguments that are most commonly needed are:
284285
.. versionadded:: 3.6
285286
Added *encoding* and *errors* parameters.
286287

288+
.. versionadded:: 3.7
289+
Added the *text* parameter as an alias for *universal_newlines*.
290+
287291
.. note::
288292

289293
The newlines attribute of the file objects :attr:`Popen.stdin`,
@@ -328,7 +332,7 @@ functions.
328332
cwd=None, env=None, universal_newlines=False, \
329333
startupinfo=None, creationflags=0, restore_signals=True, \
330334
start_new_session=False, pass_fds=(), *, \
331-
encoding=None, errors=None)
335+
encoding=None, errors=None, text=None)
332336
333337
Execute a child program in a new process. On POSIX, the class uses
334338
:meth:`os.execvp`-like behavior to execute the child program. On Windows,
@@ -511,15 +515,18 @@ functions.
511515

512516
.. _side-by-side assembly: https://en.wikipedia.org/wiki/Side-by-Side_Assembly
513517

514-
If *encoding* or *errors* are specified, the file objects *stdin*, *stdout*
515-
and *stderr* are opened in text mode with the specified encoding and
516-
*errors*, as described above in :ref:`frequently-used-arguments`. If
517-
*universal_newlines* is ``True``, they are opened in text mode with default
518-
encoding. Otherwise, they are opened as binary streams.
518+
If *encoding* or *errors* are specified, or *text* is true, the file objects
519+
*stdin*, *stdout* and *stderr* are opened in text mode with the specified
520+
encoding and *errors*, as described above in :ref:`frequently-used-arguments`.
521+
The *universal_newlines* argument is equivalent to *text* and is provided
522+
for backwards compatibility. By default, file objects are opened in binary mode.
519523

520524
.. versionadded:: 3.6
521525
*encoding* and *errors* were added.
522526

527+
.. versionadded:: 3.7
528+
*text* was added as a more readable alias for *universal_newlines*.
529+
523530
If given, *startupinfo* will be a :class:`STARTUPINFO` object, which is
524531
passed to the underlying ``CreateProcess`` function.
525532
*creationflags*, if given, can be one or more of the following flags:

0 commit comments

Comments
 (0)