Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit d9a8e96

Browse files
committed
Only supply popen2, popen3 when fork exists.
(This avoids defining non-working versions of these on the Mac.)
1 parent 9e8181b commit d9a8e96

1 file changed

Lines changed: 15 additions & 13 deletions

File tree

Lib/os.py

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -454,16 +454,18 @@ def spawnlpe(mode, file, *args):
454454
return spawnvpe(mode, file, args[:-1], env)
455455

456456

457-
if not _exists("popen2"):
458-
def popen2(cmd, mode="t", bufsize=-1):
459-
assert mode[:1] in ("b", "t")
460-
import popen2
461-
stdout, stdin = popen2.popen2(cmd, bufsize)
462-
return stdin, stdout
463-
464-
if not _exists("popen3"):
465-
def popen3(cmd, mode="t", bufsize=-1):
466-
assert mode[:1] in ("b", "t")
467-
import popen2
468-
stdout, stdin, stderr = popen2.popen3(cmd, bufsize)
469-
return stdin, stdout, stderr
457+
# Supply popen2 etc. (for Unix)
458+
if _exists("fork"):
459+
if not _exists("popen2"):
460+
def popen2(cmd, mode="t", bufsize=-1):
461+
assert mode[:1] in ("b", "t")
462+
import popen2
463+
stdout, stdin = popen2.popen2(cmd, bufsize)
464+
return stdin, stdout
465+
466+
if not _exists("popen3"):
467+
def popen3(cmd, mode="t", bufsize=-1):
468+
assert mode[:1] in ("b", "t")
469+
import popen2
470+
stdout, stdin, stderr = popen2.popen3(cmd, bufsize)
471+
return stdin, stdout, stderr

0 commit comments

Comments
 (0)