summaryrefslogtreecommitdiffstats
path: root/Lib/os.py
diff options
context:
space:
mode:
authorNeal Norwitz <nnorwitz@gmail.com>2007-05-11 06:57:33 (GMT)
committerNeal Norwitz <nnorwitz@gmail.com>2007-05-11 06:57:33 (GMT)
commit42dd86b8e2773c342ca7fa0ffcc9d1cbb8589bd3 (patch)
tree27d7ad013999378e92e4a94742831cd2081f5359 /Lib/os.py
parent82be218e971725657af9b3231a0c467e99ade26f (diff)
downloadcpython-42dd86b8e2773c342ca7fa0ffcc9d1cbb8589bd3.zip
cpython-42dd86b8e2773c342ca7fa0ffcc9d1cbb8589bd3.tar.gz
cpython-42dd86b8e2773c342ca7fa0ffcc9d1cbb8589bd3.tar.bz2
Deprecate os.popen* and popen2 module in favor of the subprocess module.
Diffstat (limited to 'Lib/os.py')
-rw-r--r--Lib/os.py38
1 files changed, 29 insertions, 9 deletions
diff --git a/Lib/os.py b/Lib/os.py
index 991716e..206aa37 100644
--- a/Lib/os.py
+++ b/Lib/os.py
@@ -666,9 +666,15 @@ if _exists("fork"):
is a string it will be passed to the shell (as with os.system()). If
'bufsize' is specified, it sets the buffer size for the I/O pipes. The
file objects (child_stdin, child_stdout) are returned."""
- import popen2
- stdout, stdin = popen2.popen2(cmd, bufsize)
- return stdin, stdout
+ import warnings
+ msg = "os.popen2 is deprecated. Use the subprocess module."
+ warnings.warn(msg, DeprecationWarning, stacklevel=2)
+
+ import subprocess
+ PIPE = subprocess.PIPE
+ p = subprocess.Popen(cmd, shell=True, bufsize=bufsize,
+ stdin=PIPE, stdout=PIPE, close_fds=True)
+ return p.stdin, p.stdout
__all__.append("popen2")
if not _exists("popen3"):
@@ -679,9 +685,16 @@ if _exists("fork"):
is a string it will be passed to the shell (as with os.system()). If
'bufsize' is specified, it sets the buffer size for the I/O pipes. The
file objects (child_stdin, child_stdout, child_stderr) are returned."""
- import popen2
- stdout, stdin, stderr = popen2.popen3(cmd, bufsize)
- return stdin, stdout, stderr
+ import warnings
+ msg = "os.popen3 is deprecated. Use the subprocess module."
+ warnings.warn(msg, DeprecationWarning, stacklevel=2)
+
+ import subprocess
+ PIPE = subprocess.PIPE
+ p = subprocess.Popen(cmd, shell=True, bufsize=bufsize,
+ stdin=PIPE, stdout=PIPE, stderr=PIPE,
+ close_fds=True)
+ return p.stdin, p.stdout, p.stderr
__all__.append("popen3")
if not _exists("popen4"):
@@ -692,9 +705,16 @@ if _exists("fork"):
is a string it will be passed to the shell (as with os.system()). If
'bufsize' is specified, it sets the buffer size for the I/O pipes. The
file objects (child_stdin, child_stdout_stderr) are returned."""
- import popen2
- stdout, stdin = popen2.popen4(cmd, bufsize)
- return stdin, stdout
+ import warnings
+ msg = "os.popen4 is deprecated. Use the subprocess module."
+ warnings.warn(msg, DeprecationWarning, stacklevel=2)
+
+ import subprocess
+ PIPE = subprocess.PIPE
+ p = subprocess.Popen(cmd, shell=True, bufsize=bufsize,
+ stdin=PIPE, stdout=PIPE,
+ stderr=subprocess.STDOUT, close_fds=True)
+ return p.stdin, p.stdout
__all__.append("popen4")
import copy_reg as _copy_reg