diff --git a/Lib/os.py b/Lib/os.py index c804c3ab869..70af0a9406c 100644 --- a/Lib/os.py +++ b/Lib/os.py @@ -454,16 +454,18 @@ def spawnlpe(mode, file, *args): 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 +# 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 + 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