]> granicus.if.org Git - python/commitdiff
Only supply popen2, popen3 when fork exists.
authorGuido van Rossum <guido@python.org>
Tue, 19 Sep 2000 03:04:52 +0000 (03:04 +0000)
committerGuido van Rossum <guido@python.org>
Tue, 19 Sep 2000 03:04:52 +0000 (03:04 +0000)
(This avoids defining non-working versions of these on the Mac.)

Lib/os.py

index c804c3ab8695aad1b2e9935f2ce91dd55da12a29..70af0a9406cc31cca0f3951b7e4d8558a28ad5a1 100644 (file)
--- a/Lib/os.py
+++ b/Lib/os.py
@@ -454,16 +454,18 @@ otherwise return -SIG, where SIG is the signal that killed it. """
         return spawnvpe(mode, file, args[:-1], env)
 
 
-if not _exists("popen2"):
-    def popen2(cmd, mode="t", bufsize=-1):
-        assert mode[:1] in ("b", "t")
-        import popen2
-        stdout, stdin = popen2.popen2(cmd, bufsize)
-        return stdin, stdout
-
-if not _exists("popen3"):
-    def popen3(cmd, mode="t", bufsize=-1):
-        assert mode[:1] in ("b", "t")
-        import popen2
-        stdout, stdin, stderr = popen2.popen3(cmd, bufsize)
-        return stdin, stdout, stderr
+# Supply popen2 etc. (for Unix)
+if _exists("fork"):
+    if not _exists("popen2"):
+        def popen2(cmd, mode="t", bufsize=-1):
+            assert mode[:1] in ("b", "t")
+            import popen2
+            stdout, stdin = popen2.popen2(cmd, bufsize)
+            return stdin, stdout
+
+    if not _exists("popen3"):
+        def popen3(cmd, mode="t", bufsize=-1):
+            assert mode[:1] in ("b", "t")
+            import popen2
+            stdout, stdin, stderr = popen2.popen3(cmd, bufsize)
+            return stdin, stdout, stderr