Index: Misc/NEWS =================================================================== --- Misc/NEWS (revision 63516) +++ Misc/NEWS (working copy) @@ -1517,7 +1517,8 @@ for the debugged script, which means that imports from __main__ work correctly now. -- The nonobvious commands.getstatus() function is now deprecated. +- The nonobvious commands.getstatus() function has been deprecated for + removal in Python 3.0. - Patch #1393667: pdb now has a "run" command which restarts the debugged Python program, optionally with different arguments. Index: Doc/library/commands.rst =================================================================== --- Doc/library/commands.rst (revision 63516) +++ Doc/library/commands.rst (working copy) @@ -7,7 +7,10 @@ :synopsis: Utility functions for running external commands. .. sectionauthor:: Sue Williams +.. deprecated:: 2.6 + The :mod:`commands` module has been removed in Python 3.0. + The :mod:`commands` module contains wrapper functions for :func:`os.popen` which take a system command as a string and return any output generated by the command and, optionally, the exit status. @@ -27,12 +30,18 @@ stripped from the output. The exit status for the command can be interpreted according to the rules for the C function :cfunc:`wait`. + .. note:: + The :func:`getstatusoutput` function has been moved to the :mod:`subprocess` + module in Python 3.0. .. function:: getoutput(cmd) Like :func:`getstatusoutput`, except the exit status is ignored and the return value is a string containing the command's output. + .. note:: + The :func:`getoutput` function has been moved to the :mod:`subprocess` module + in Python 3.0. .. function:: getstatus(file) @@ -42,7 +51,8 @@ .. deprecated:: 2.6 This function is nonobvious and useless, also the name is misleading in the - presence of :func:`getstatusoutput`. + presence of :func:`getstatusoutput`. The :func:`getstatus` function has been + removed in Python 3.0. Example:: Index: Lib/commands.py =================================================================== --- Lib/commands.py (revision 63516) +++ Lib/commands.py (working copy) @@ -32,8 +32,10 @@ # def getstatus(file): """Return output of "ls -ld " in a string.""" - import warnings - warnings.warn("commands.getstatus() is deprecated", DeprecationWarning) + from warnings import warnpy3k + warnpy3k("commands.getstatus() has been removed in Python 3.0", + stacklevel=2) + del warnpy3k return getoutput('ls -ld' + mkarg(file)) Index: Lib/test/test_py3kwarn.py =================================================================== --- Lib/test/test_py3kwarn.py (revision 63516) +++ Lib/test/test_py3kwarn.py (working copy) @@ -212,7 +212,18 @@ mod.walk(".", dumbo, None) self.assertEquals(str(w.message), msg) + def test_commands_getstatus(self): + # Test the removal of commands.getstatus() on supported platforms + import os + if os.name != 'posix': + return + msg = "commands.getstatus() has been removed in Python 3.0" + with catch_warning() as w: + from commands import getstatus + getstatus('./') + self.assertEquals(str(w.message), msg) + class TestStdlibRenames(unittest.TestCase): renames = {'Queue': 'queue', Index: Lib/test/test_commands.py =================================================================== --- Lib/test/test_commands.py (revision 63516) +++ Lib/test/test_commands.py (working copy) @@ -6,11 +6,9 @@ import os, tempfile, re import warnings -warnings.filterwarnings('ignore', r".*commands.getstatus.. is deprecated", - DeprecationWarning) -from test.test_support import TestSkipped, run_unittest, reap_children -from commands import * +from test import test_support +commands = test_support.import_module('commands', deprecated=True) # The module says: # "NB This only works (and is only relevant) for UNIX." @@ -19,14 +17,14 @@ # I'll take the comment as given, and skip this suite. if os.name != 'posix': - raise TestSkipped('Not posix; skipping test_commands') + raise test_support.TestSkipped('Not posix; skipping test_commands') class CommandTests(unittest.TestCase): def test_getoutput(self): - self.assertEquals(getoutput('echo xyzzy'), 'xyzzy') - self.assertEquals(getstatusoutput('echo xyzzy'), (0, 'xyzzy')) + self.assertEquals(commands.getoutput('echo xyzzy'), 'xyzzy') + self.assertEquals(commands.getstatusoutput('echo xyzzy'), (0, 'xyzzy')) # we use mkdtemp in the next line to create an empty directory # under our exclusive control; from that, we can invent a pathname @@ -36,7 +34,7 @@ dir = tempfile.mkdtemp() name = os.path.join(dir, "foo") - status, output = getstatusoutput('cat ' + name) + status, output = commands.getstatusoutput('cat ' + name) self.assertNotEquals(status, 0) finally: if dir is not None: @@ -57,12 +55,12 @@ /\. # and end with the name of the file. ''' - self.assert_(re.match(pat, getstatus("/."), re.VERBOSE)) + self.assert_(re.match(pat, commands.getstatus("/."), re.VERBOSE)) def test_main(): - run_unittest(CommandTests) - reap_children() + test_support.run_unittest(CommandTests) + test_support.reap_children() if __name__ == "__main__":