Skip to content

Commit d211231

Browse files
committed
merge from 3.1
2 parents 56f1e2d + 046a764 commit d211231

1 file changed

Lines changed: 38 additions & 6 deletions

File tree

Doc/library/subprocess.rst

Lines changed: 38 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -94,12 +94,10 @@ This module defines one class called :class:`Popen`:
9494
*shell=False* does not suffer from this vulnerability; the above Note may be
9595
helpful in getting code using *shell=False* to work.
9696

97-
On Windows: the :class:`Popen` class uses CreateProcess() to execute the child
98-
program, which operates on strings. If *args* is a sequence, it will be
99-
converted to a string using the :meth:`list2cmdline` method. Please note that
100-
not all MS Windows applications interpret the command line the same way:
101-
:meth:`list2cmdline` is designed for applications using the same rules as the MS
102-
C runtime.
97+
On Windows: the :class:`Popen` class uses CreateProcess() to execute the
98+
child program, which operates on strings. If *args* is a sequence, it will
99+
be converted to a string in a manner described in
100+
:ref:`converting-argument-sequence`.
103101

104102
*bufsize*, if given, has the same meaning as the corresponding argument to the
105103
built-in open() function: :const:`0` means unbuffered, :const:`1` means line
@@ -664,3 +662,37 @@ Replacing functions from the :mod:`popen2` module
664662
* popen2 closes all file descriptors by default, but you have to specify
665663
``close_fds=True`` with :class:`Popen` to guarantee this behavior on
666664
all platforms or past Python versions.
665+
666+
Notes
667+
-----
668+
669+
.. _converting-argument-sequence:
670+
671+
Converting an argument sequence to a string on Windows
672+
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
673+
674+
On Windows, an *args* sequence is converted to a string that can be parsed
675+
using the following rules (which correspond to the rules used by the MS C
676+
runtime):
677+
678+
1. Arguments are delimited by white space, which is either a
679+
space or a tab.
680+
681+
2. A string surrounded by double quotation marks is
682+
interpreted as a single argument, regardless of white space
683+
contained within. A quoted string can be embedded in an
684+
argument.
685+
686+
3. A double quotation mark preceded by a backslash is
687+
interpreted as a literal double quotation mark.
688+
689+
4. Backslashes are interpreted literally, unless they
690+
immediately precede a double quotation mark.
691+
692+
5. If backslashes immediately precede a double quotation mark,
693+
every pair of backslashes is interpreted as a literal
694+
backslash. If the number of backslashes is odd, the last
695+
backslash escapes the next double quotation mark as
696+
described in rule 3.
697+
698+

0 commit comments

Comments
 (0)