@@ -1443,36 +1443,8 @@ Environment example::
1443
1443
1444
1444
1445
1445
1446
- Replacing :func: `os.popen `, :func: `os.popen2 `, :func: `os.popen3 `
1447
- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
1448
-
1449
- ::
1450
-
1451
- (child_stdin, child_stdout) = os.popen2(cmd, mode, bufsize)
1452
- ==>
1453
- p = Popen(cmd, shell=True, bufsize=bufsize,
1454
- stdin=PIPE, stdout=PIPE, close_fds=True)
1455
- (child_stdin, child_stdout) = (p.stdin, p.stdout)
1456
-
1457
- ::
1458
-
1459
- (child_stdin,
1460
- child_stdout,
1461
- child_stderr) = os.popen3(cmd, mode, bufsize)
1462
- ==>
1463
- p = Popen(cmd, shell=True, bufsize=bufsize,
1464
- stdin=PIPE, stdout=PIPE, stderr=PIPE, close_fds=True)
1465
- (child_stdin,
1466
- child_stdout,
1467
- child_stderr) = (p.stdin, p.stdout, p.stderr)
1468
-
1469
- ::
1470
-
1471
- (child_stdin, child_stdout_and_stderr) = os.popen4(cmd, mode, bufsize)
1472
- ==>
1473
- p = Popen(cmd, shell=True, bufsize=bufsize,
1474
- stdin=PIPE, stdout=PIPE, stderr=STDOUT, close_fds=True)
1475
- (child_stdin, child_stdout_and_stderr) = (p.stdin, p.stdout)
1446
+ Replacing :func: `os.popen `
1447
+ ^^^^^^^^^^^^^^^^^^^^^^^^^^
1476
1448
1477
1449
Return code handling translates as follows::
1478
1450
@@ -1489,44 +1461,6 @@ Return code handling translates as follows::
1489
1461
print("There were some errors")
1490
1462
1491
1463
1492
- Replacing functions from the :mod: `!popen2 ` module
1493
- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
1494
-
1495
- .. note ::
1496
-
1497
- If the cmd argument to popen2 functions is a string, the command is executed
1498
- through /bin/sh. If it is a list, the command is directly executed.
1499
-
1500
- ::
1501
-
1502
- (child_stdout, child_stdin) = popen2.popen2("somestring", bufsize, mode)
1503
- ==>
1504
- p = Popen("somestring", shell=True, bufsize=bufsize,
1505
- stdin=PIPE, stdout=PIPE, close_fds=True)
1506
- (child_stdout, child_stdin) = (p.stdout, p.stdin)
1507
-
1508
- ::
1509
-
1510
- (child_stdout, child_stdin) = popen2.popen2(["mycmd", "myarg"], bufsize, mode)
1511
- ==>
1512
- p = Popen(["mycmd", "myarg"], bufsize=bufsize,
1513
- stdin=PIPE, stdout=PIPE, close_fds=True)
1514
- (child_stdout, child_stdin) = (p.stdout, p.stdin)
1515
-
1516
- :class: `popen2.Popen3 ` and :class: `popen2.Popen4 ` basically work as
1517
- :class: `subprocess.Popen `, except that:
1518
-
1519
- * :class: `Popen ` raises an exception if the execution fails.
1520
-
1521
- * The *capturestderr * argument is replaced with the *stderr * argument.
1522
-
1523
- * ``stdin=PIPE `` and ``stdout=PIPE `` must be specified.
1524
-
1525
- * popen2 closes all file descriptors by default, but you have to specify
1526
- ``close_fds=True `` with :class: `Popen ` to guarantee this behavior on
1527
- all platforms or past Python versions.
1528
-
1529
-
1530
1464
Legacy Shell Invocation Functions
1531
1465
---------------------------------
1532
1466
0 commit comments