]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
fix issue #6121 by stripping spaces from the argument in the 'help'
authorR. David Murray <rdmurray@bitdance.com>
Wed, 27 May 2009 20:07:21 +0000 (20:07 +0000)
committerR. David Murray <rdmurray@bitdance.com>
Wed, 27 May 2009 20:07:21 +0000 (20:07 +0000)
function.

Lib/pydoc.py
Lib/test/test_pydoc.py
Misc/NEWS

index a70f01600cce0d871fed21b712ac0476050e561b..76a2b6462124181c4e3f40c60858e8168072161d 100755 (executable)
@@ -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()
index 91a997783c5f076d65222a256362ca5b04e8b8a7..7990d3a492d9e7327e5bc5a9aaaa642766c65e21 100644 (file)
@@ -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):
 
index daab366c3d18bfee36d3c977bfac39c897ba785b..a2b8233bfcdf682338c5b820c00e7e0dc5249d7f 100644 (file)
--- 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.