mirror of
https://github.com/python/cpython.git
synced 2025-11-03 03:22:27 +00:00
bpo-46434: Handle missing docstrings in pdb help (GH-30705)
This commit is contained in:
parent
a1bf329bca
commit
60705cff70
4 changed files with 27 additions and 0 deletions
|
|
@ -1577,6 +1577,9 @@ class Pdb(bdb.Bdb, cmd.Cmd):
|
||||||
self.error('No help for %r; please do not run Python with -OO '
|
self.error('No help for %r; please do not run Python with -OO '
|
||||||
'if you need command help' % arg)
|
'if you need command help' % arg)
|
||||||
return
|
return
|
||||||
|
if command.__doc__ is None:
|
||||||
|
self.error('No help for %r; __doc__ string missing' % arg)
|
||||||
|
return
|
||||||
self.message(command.__doc__.rstrip())
|
self.message(command.__doc__.rstrip())
|
||||||
|
|
||||||
do_h = do_help
|
do_h = do_help
|
||||||
|
|
|
||||||
|
|
@ -1474,6 +1474,27 @@ def bœr():
|
||||||
self.assertNotIn(b'SyntaxError', stdout,
|
self.assertNotIn(b'SyntaxError', stdout,
|
||||||
"Got a syntax error running test script under PDB")
|
"Got a syntax error running test script under PDB")
|
||||||
|
|
||||||
|
def test_issue46434(self):
|
||||||
|
# Temporarily patch in an extra help command which doesn't have a
|
||||||
|
# docstring to emulate what happens in an embeddable distribution
|
||||||
|
script = """
|
||||||
|
def do_testcmdwithnodocs(self, arg):
|
||||||
|
pass
|
||||||
|
|
||||||
|
import pdb
|
||||||
|
pdb.Pdb.do_testcmdwithnodocs = do_testcmdwithnodocs
|
||||||
|
"""
|
||||||
|
commands = """
|
||||||
|
continue
|
||||||
|
help testcmdwithnodocs
|
||||||
|
"""
|
||||||
|
stdout, stderr = self.run_pdb_script(script, commands)
|
||||||
|
output = (stdout or '') + (stderr or '')
|
||||||
|
self.assertNotIn('AttributeError', output,
|
||||||
|
'Calling help on a command with no docs should be handled gracefully')
|
||||||
|
self.assertIn("*** No help for 'testcmdwithnodocs'; __doc__ string missing", output,
|
||||||
|
'Calling help on a command with no docs should print an error')
|
||||||
|
|
||||||
def test_issue13183(self):
|
def test_issue13183(self):
|
||||||
script = """
|
script = """
|
||||||
from bar import bar
|
from bar import bar
|
||||||
|
|
|
||||||
|
|
@ -1675,6 +1675,7 @@ Evgeny Sologubov
|
||||||
Cody Somerville
|
Cody Somerville
|
||||||
Anthony Sottile
|
Anthony Sottile
|
||||||
Edoardo Spadolini
|
Edoardo Spadolini
|
||||||
|
Tom Sparrow
|
||||||
Geoffrey Spear
|
Geoffrey Spear
|
||||||
Clay Spence
|
Clay Spence
|
||||||
Stefan Sperling
|
Stefan Sperling
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,2 @@
|
||||||
|
:mod:`pdb` now gracefully handles ``help`` when :attr:`__doc__` is missing,
|
||||||
|
for example when run with pregenerated optimized ``.pyc`` files.
|
||||||
Loading…
Add table
Add a link
Reference in a new issue