Merged revisions 73026,73313,73511,73554 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r73026 | r.david.murray | 2009-05-29 15:30:27 -0400 (Fri, 29 May 2009) | 3 lines
Issue 6141: document that the first item of args is still the
command name even when executable is specified.
........
r73313 | r.david.murray | 2009-06-08 20:44:22 -0400 (Mon, 08 Jun 2009) | 4 lines
Issue 2947: document how return code handling translates from
os.popen to subprocess. Also fixes reference link in the
os.spawn documentation.
........
r73511 | r.david.murray | 2009-06-22 18:11:04 -0400 (Mon, 22 Jun 2009) | 2 lines
Improve English phrasing.
........
r73554 | r.david.murray | 2009-06-25 10:21:06 -0400 (Thu, 25 Jun 2009) | 2 lines
Add a couple of missing function alias declarations to the turtle docs.
........
diff --git a/Doc/library/subprocess.rst b/Doc/library/subprocess.rst
index efac7e6..2bc8f74 100644
--- a/Doc/library/subprocess.rst
+++ b/Doc/library/subprocess.rst
@@ -39,9 +39,12 @@
Arguments are:
*args* should be a string, or a sequence of program arguments. The program
- to execute is normally the first item in the args sequence or the string if a
- string is given, but can be explicitly set by using the *executable*
- argument.
+ to execute is normally the first item in the args sequence or the string if
+ a string is given, but can be explicitly set by using the *executable*
+ argument. When *executable* is given, the first item in the args sequence
+ is still treated by most programs as the command name, which can then be
+ different from the actual executable name. On Unix, it becomes the display
+ name for the executing program in utilities such as :program:`ps`.
On Unix, with *shell=False* (default): In this case, the Popen class uses
:meth:`os.execvp` to execute the child program. *args* should normally be a
@@ -354,8 +357,8 @@
output = p2.communicate()[0]
-Replacing os.system()
-^^^^^^^^^^^^^^^^^^^^^
+Replacing :func:`os.system`
+^^^^^^^^^^^^^^^^^^^^^^^^^^^
::
@@ -382,8 +385,8 @@
print >>sys.stderr, "Execution failed:", e
-Replacing the os.spawn family
-^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+Replacing the :func:`os.spawn <os.spawnl>` family
+^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
P_NOWAIT example::
@@ -410,8 +413,8 @@
Popen(["/bin/mycmd", "myarg"], env={"PATH": "/usr/bin"})
-Replacing os.popen, os.popen2, os.popen3
-^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+Replacing :func:`os.popen`, :func:`os.popen2`, :func:`os.popen3`
+^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
::
@@ -453,9 +456,23 @@
stdin=PIPE, stdout=PIPE, stderr=STDOUT, close_fds=True)
(child_stdin, child_stdout_and_stderr) = (p.stdin, p.stdout)
+Return code handling translates as follows::
-Replacing functions from the popen2 module
-^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+ pipe = os.popen(cmd, 'w')
+ ...
+ rc = pipe.close()
+ if rc != None and rc % 256:
+ print "There were some errors"
+ ==>
+ process = Popen(cmd, 'w', stdin=PIPE)
+ ...
+ process.stdin.close()
+ if process.wait() != 0:
+ print "There were some errors"
+
+
+Replacing functions from the :mod:`popen2` module
+^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
.. note::