? popen-doc-patch Index: Doc/lib/libos.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/libos.tex,v retrieving revision 1.142 diff -u -r1.142 libos.tex --- Doc/lib/libos.tex 27 Sep 2004 19:54:32 -0000 1.142 +++ Doc/lib/libos.tex 8 Oct 2004 01:35:37 -0000 @@ -394,6 +394,11 @@ \var{child_stderr}} are named from the point of view of the child process, i.e. \var{child_stdin} is the child's standard input.) +On \UNIX, \var{cmd} may be a sequence, in which case arguments will +be passed directly to the program without shell intervention (as with +\function{os.spawnv()}. If \var{cmd} is a string it will be passed to the shell +(as with \function{os.system()}). + Availability: \UNIX, Windows. \versionadded{2.0} \end{funcdesc} Index: Doc/lib/libpopen2.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/libpopen2.tex,v retrieving revision 1.22 diff -u -r1.22 libpopen2.tex --- Doc/lib/libpopen2.tex 9 Aug 2004 14:12:05 -0000 1.22 +++ Doc/lib/libpopen2.tex 8 Oct 2004 01:35:37 -0000 @@ -75,6 +75,10 @@ \versionadded{2.0} \end{classdesc} +On \UNIX, \var{cmd} may be a sequence, in which case arguments will +be passed directly to the program without shell intervention (as with +\function{os.spawnv()}. If \var{cmd} is a string it will be passed to the shell +(as with \function{os.system()}). \subsection{Popen3 and Popen4 Objects \label{popen3-objects}} Index: Lib/os.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/os.py,v retrieving revision 1.82 diff -u -r1.82 os.py --- Lib/os.py 18 Sep 2004 16:07:58 -0000 1.82 +++ Lib/os.py 8 Oct 2004 01:35:40 -0000 @@ -611,6 +611,12 @@ if _exists("fork"): if not _exists("popen2"): def popen2(cmd, mode="t", bufsize=-1): + """Execute the shell command 'cmd' in a sub-process. On UNIX, 'cmd' + may be a sequence, in which case arguments will be passed directly to + the program without shell intervention (as with os.spawnv()). If 'cmd' + is a string it will be passed to the shell (as with os.system()). If + 'bufsize' is specified, it sets the buffer size for the I/O pipes. The + file objects (child_stdin, child_stdout) are returned.""" import popen2 stdout, stdin = popen2.popen2(cmd, bufsize) return stdin, stdout @@ -618,14 +624,26 @@ if not _exists("popen3"): def popen3(cmd, mode="t", bufsize=-1): - import popen2 + """Execute the shell command 'cmd' in a sub-process. On UNIX, 'cmd' + may be a sequence, in which case arguments will be passed directly to + the program without shell intervention (as with os.spawnv()). If 'cmd' + is a string it will be passed to the shell (as with os.system()). If + 'bufsize' is specified, it sets the buffer size for the I/O pipes. The + file objects (child_stdin, child_stdout, child_stderr) are returned.""" + import popen2 stdout, stdin, stderr = popen2.popen3(cmd, bufsize) return stdin, stdout, stderr __all__.append("popen3") if not _exists("popen4"): def popen4(cmd, mode="t", bufsize=-1): - import popen2 + """Execute the shell command 'cmd' in a sub-process. On UNIX, 'cmd' + may be a sequence, in which case arguments will be passed directly to + the program without shell intervention (as with os.spawnv()). If 'cmd' + is a string it will be passed to the shell (as with os.system()). If + 'bufsize' is specified, it sets the buffer size for the I/O pipes. The + file objects (child_stdin, child_stdout_stderr) are returned.""" + import popen2 stdout, stdin = popen2.popen4(cmd, bufsize) return stdin, stdout __all__.append("popen4") Index: Lib/popen2.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/popen2.py,v retrieving revision 1.29 diff -u -r1.29 popen2.py --- Lib/popen2.py 12 Feb 2004 17:35:06 -0000 1.29 +++ Lib/popen2.py 8 Oct 2004 01:35:41 -0000 @@ -30,10 +30,14 @@ def __init__(self, cmd, capturestderr=False, bufsize=-1): """The parameter 'cmd' is the shell command to execute in a - sub-process. The 'capturestderr' flag, if true, specifies that - the object should capture standard error output of the child process. - The default is false. If the 'bufsize' parameter is specified, it - specifies the size of the I/O buffers to/from the child process.""" + sub-process. On UNIX, 'cmd' may be a sequence, in which case arguments + will be passed directly to the program without shell intervention (as + with os.spawnv()). If 'cmd' is a string it will be passed to the shell + (as with os.system()). The 'capturestderr' flag, if true, specifies + that the object should capture standard error output of the child + process. The default is false. If the 'bufsize' parameter is + specified, it specifies the size of the I/O buffers to/from the child + process.""" _cleanup() p2cread, p2cwrite = os.pipe() c2pread, c2pwrite = os.pipe() @@ -120,23 +124,32 @@ del Popen3, Popen4 def popen2(cmd, bufsize=-1, mode='t'): - """Execute the shell command 'cmd' in a sub-process. If 'bufsize' is - specified, it sets the buffer size for the I/O pipes. The file objects - (child_stdout, child_stdin) are returned.""" + """Execute the shell command 'cmd' in a sub-process. On UNIX, 'cmd' + may be a sequence, in which case arguments will be passed directly to + the program without shell intervention (as with os.spawnv()). If 'cmd' + is a string it will be passed to the shell (as with os.system()). If + 'bufsize' is specified, it sets the buffer size for the I/O pipes. The + file objects (child_stdout, child_stdin) are returned.""" w, r = os.popen2(cmd, mode, bufsize) return r, w def popen3(cmd, bufsize=-1, mode='t'): - """Execute the shell command 'cmd' in a sub-process. If 'bufsize' is - specified, it sets the buffer size for the I/O pipes. The file objects - (child_stdout, child_stdin, child_stderr) are returned.""" + """Execute the shell command 'cmd' in a sub-process. On UNIX, 'cmd' + may be a sequence, in which case arguments will be passed directly to + the program without shell intervention (as with os.spawnv()). If 'cmd' + is a string it will be passed to the shell (as with os.system()). If + 'bufsize' is specified, it sets the buffer size for the I/O pipes. The + file objects (child_stdout, child_stdin, child_stderr) are returned.""" w, r, e = os.popen3(cmd, mode, bufsize) return r, w, e def popen4(cmd, bufsize=-1, mode='t'): - """Execute the shell command 'cmd' in a sub-process. If 'bufsize' is - specified, it sets the buffer size for the I/O pipes. The file objects - (child_stdout_stderr, child_stdin) are returned.""" + """Execute the shell command 'cmd' in a sub-process. On UNIX, 'cmd' + may be a sequence, in which case arguments will be passed directly to + the program without shell intervention (as with os.spawnv()). If 'cmd' + is a string it will be passed to the shell (as with os.system()). If + 'bufsize' is specified, it sets the buffer size for the I/O pipes. The + file objects (child_stdout_stderr, child_stdin) are returned.""" w, r = os.popen4(cmd, mode, bufsize) return r, w else: