Deprecate os.popen* and popen2 module in favor of the subprocess module.
diff --git a/Lib/test/test___all__.py b/Lib/test/test___all__.py
index 5e7d34e..2b9f1de 100644
--- a/Lib/test/test___all__.py
+++ b/Lib/test/test___all__.py
@@ -9,6 +9,8 @@
"<string>")
warnings.filterwarnings("ignore", "the sets module is deprecated",
DeprecationWarning, "<string>")
+warnings.filterwarnings("ignore", ".*popen2 module is deprecated.*",
+ DeprecationWarning)
class AllTest(unittest.TestCase):
diff --git a/Lib/test/test_bz2.py b/Lib/test/test_bz2.py
index 709850d..b8b3c03 100644
--- a/Lib/test/test_bz2.py
+++ b/Lib/test/test_bz2.py
@@ -5,7 +5,7 @@
import unittest
from cStringIO import StringIO
import os
-import popen2
+import subprocess
import sys
import bz2
@@ -21,18 +21,20 @@
if has_cmdline_bunzip2:
def decompress(self, data):
- pop = popen2.Popen3("bunzip2", capturestderr=1)
- pop.tochild.write(data)
- pop.tochild.close()
- ret = pop.fromchild.read()
- pop.fromchild.close()
+ pop = subprocess.Popen("bunzip2", shell=True,
+ stdin=subprocess.PIPE,
+ stdout=subprocess.PIPE,
+ stderr=subprocess.STDOUT)
+ pop.stdin.write(data)
+ pop.stdin.close()
+ ret = pop.stdout.read()
+ pop.stdout.close()
if pop.wait() != 0:
ret = bz2.decompress(data)
return ret
else:
- # popen2.Popen3 doesn't exist on Windows, and even if it did, bunzip2
- # isn't available to run.
+ # bunzip2 isn't available to run on Windows.
def decompress(self, data):
return bz2.decompress(data)
diff --git a/Lib/test/test_cmd_line.py b/Lib/test/test_cmd_line.py
index cacae7a..d3f07c7 100644
--- a/Lib/test/test_cmd_line.py
+++ b/Lib/test/test_cmd_line.py
@@ -1,18 +1,19 @@
import test.test_support, unittest
import sys
-import popen2
import subprocess
class CmdLineTest(unittest.TestCase):
def start_python(self, cmd_line):
- outfp, infp = popen2.popen4('"%s" %s' % (sys.executable, cmd_line))
- infp.close()
- data = outfp.read()
- outfp.close()
+ cmd = '"%s" %s' % (sys.executable, cmd_line)
+ p = subprocess.Popen(cmd, shell=True, stdin=subprocess.PIPE,
+ stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
+ p.stdin.close()
+ data = p.stdout.read()
+ p.stdout.close()
# try to cleanup the child so we don't appear to leak when running
# with regrtest -R. This should be a no-op on Windows.
- popen2._cleanup()
+ subprocess._cleanup()
return data
def exit_code(self, *args):
diff --git a/Lib/test/test_popen2.py b/Lib/test/test_popen2.py
index 31f22d6..023871f 100644
--- a/Lib/test/test_popen2.py
+++ b/Lib/test/test_popen2.py
@@ -1,6 +1,12 @@
#! /usr/bin/env python
"""Test script for popen2.py"""
+import warnings
+warnings.filterwarnings("ignore", ".*popen2 module is deprecated.*",
+ DeprecationWarning)
+warnings.filterwarnings("ignore", "os\.popen. is deprecated.*",
+ DeprecationWarning)
+
import os
import sys
import unittest