summaryrefslogtreecommitdiffstats
path: root/Lib/popen2.py
diff options
context:
space:
mode:
authorFredrik Lundh <fredrik@pythonware.com>2000-07-09 23:35:24 (GMT)
committerFredrik Lundh <fredrik@pythonware.com>2000-07-09 23:35:24 (GMT)
commit9ac81f69b2de4364455ddd532ac4b20c4528f677 (patch)
tree05ffcb150068daeaf400f2078b7b21bb1f7de25f /Lib/popen2.py
parent0466132ee4c0a96ef6dd936f0b6415991d20e570 (diff)
downloadcpython-9ac81f69b2de4364455ddd532ac4b20c4528f677.zip
cpython-9ac81f69b2de4364455ddd532ac4b20c4528f677.tar.gz
cpython-9ac81f69b2de4364455ddd532ac4b20c4528f677.tar.bz2
- changed the nt.popen2 return values back to
(write, read, ...), based on feedback from GvR. - added tuple-swapping code to popen2.py - fixed some runaway indentation in posixmodule.c
Diffstat (limited to 'Lib/popen2.py')
-rw-r--r--Lib/popen2.py35
1 files changed, 25 insertions, 10 deletions
diff --git a/Lib/popen2.py b/Lib/popen2.py
index 73ff77c..c4d3e4c 100644
--- a/Lib/popen2.py
+++ b/Lib/popen2.py
@@ -89,9 +89,14 @@ class Popen3:
_active.remove(self)
return self.sts
-try:
- from os import popen2
-except NameError:
+if hasattr(os, "popen2"):
+ def popen2(cmd, mode='t', bufsize=-1):
+ """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."""
+ w, r = os.popen2(cmd, mode, bufsize)
+ return r, w
+else:
def popen2(cmd, mode='t', bufsize=-1):
"""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
@@ -104,9 +109,14 @@ except NameError:
inst = Popen3(cmd, 0, bufsize)
return inst.fromchild, inst.tochild
-try:
- from os import popen3
-except NameError:
+if hasattr(os, "popen3"):
+ def popen3(cmd, mode='t', bufsize=-1):
+ """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."""
+ w, r, e = os.popen3(cmd, mode, bufsize)
+ return r, w, e
+else:
def popen3(cmd, mode='t', bufsize=-1):
"""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
@@ -119,10 +129,15 @@ except NameError:
inst = Popen3(cmd, 1, bufsize)
return inst.fromchild, inst.tochild, inst.childerr
-try:
- from os import popen4
-except NameError:
- pass # not on unix
+if hasattr(os, "popen4"):
+ def popen4(cmd, mode='t', bufsize=-1):
+ """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."""
+ w, r = os.popen4(cmd, mode, bufsize)
+ return r, w
+else:
+ pass # not yet on unix
def _test():
teststr = "abc\n"