From: R. David Murray Date: Wed, 27 May 2009 20:07:21 +0000 (+0000) Subject: fix issue #6121 by stripping spaces from the argument in the 'help' X-Git-Tag: v2.7a1~1090 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=d67ea7d4c68a417d9854a15bc4f51478770ef920;p=thirdparty%2FPython%2Fcpython.git fix issue #6121 by stripping spaces from the argument in the 'help' function. --- diff --git a/Lib/pydoc.py b/Lib/pydoc.py index a70f01600cce..76a2b6462124 100755 --- a/Lib/pydoc.py +++ b/Lib/pydoc.py @@ -1751,6 +1751,7 @@ has the same effect as typing a particular string at the help> prompt. def help(self, request): if type(request) is type(''): + request = request.strip() if request == 'help': self.intro() elif request == 'keywords': self.listkeywords() elif request == 'symbols': self.listsymbols() diff --git a/Lib/test/test_pydoc.py b/Lib/test/test_pydoc.py index 91a997783c5f..7990d3a492d9 100644 --- a/Lib/test/test_pydoc.py +++ b/Lib/test/test_pydoc.py @@ -237,6 +237,14 @@ class PyDocDocTest(unittest.TestCase): self.assertEqual(expected, result, "documentation for missing module found") + def test_input_strip(self): + missing_module = " test.i_am_not_here " + result = run_pydoc(missing_module) + expected = missing_pattern % missing_module.strip() + self.assertEqual(expected, result, + "white space was not stripped from module name " + "or other error output mismatch") + class TestDescriptions(unittest.TestCase): diff --git a/Misc/NEWS b/Misc/NEWS index daab366c3d18..a2b8233bfcdf 100644 --- a/Misc/NEWS +++ b/Misc/NEWS @@ -307,6 +307,9 @@ Core and Builtins Library ------- +- Issue #6121: pydoc now ignores leading and trailing spaces in the + argument to the 'help' function. + - In unittest, using a skipping decorator on a class is now equivalent to skipping every test on the class. The ClassTestSuite class has been removed.