#9964: fix pdb failure to import under -OO. Warn the user that help is simply not available in this case.
This commit is contained in:
parent
66c221e993
commit
9e7dbc8a70
35
Lib/pdb.py
35
Lib/pdb.py
|
@ -1261,6 +1261,10 @@ class Pdb(bdb.Bdb, cmd.Cmd):
|
||||||
except AttributeError:
|
except AttributeError:
|
||||||
self.error('No help for %r' % arg)
|
self.error('No help for %r' % arg)
|
||||||
else:
|
else:
|
||||||
|
if sys.flags.optimize >= 2:
|
||||||
|
self.error('No help for %r; please do not run Python with -OO '
|
||||||
|
'if you need command help' % arg)
|
||||||
|
return
|
||||||
self.message(command.__doc__.rstrip())
|
self.message(command.__doc__.rstrip())
|
||||||
|
|
||||||
do_h = do_help
|
do_h = do_help
|
||||||
|
@ -1275,7 +1279,7 @@ class Pdb(bdb.Bdb, cmd.Cmd):
|
||||||
(Pdb) global list_options; list_options = ['-l']
|
(Pdb) global list_options; list_options = ['-l']
|
||||||
(Pdb)
|
(Pdb)
|
||||||
"""
|
"""
|
||||||
self.message(self.help_exec.__doc__.strip())
|
self.message((self.help_exec.__doc__ or '').strip())
|
||||||
|
|
||||||
def help_pdb(self):
|
def help_pdb(self):
|
||||||
help()
|
help()
|
||||||
|
@ -1332,23 +1336,24 @@ class Pdb(bdb.Bdb, cmd.Cmd):
|
||||||
(fp.read(), self.mainpyfile)
|
(fp.read(), self.mainpyfile)
|
||||||
self.run(statement)
|
self.run(statement)
|
||||||
|
|
||||||
# Collect all command help into docstring
|
# Collect all command help into docstring, if not run with -OO
|
||||||
|
|
||||||
# unfortunately we can't guess this order from the class definition
|
if __doc__ is not None:
|
||||||
_help_order = [
|
# unfortunately we can't guess this order from the class definition
|
||||||
'help', 'where', 'down', 'up', 'break', 'tbreak', 'clear', 'disable',
|
_help_order = [
|
||||||
'enable', 'ignore', 'condition', 'commands', 'step', 'next', 'until',
|
'help', 'where', 'down', 'up', 'break', 'tbreak', 'clear', 'disable',
|
||||||
'jump', 'return', 'retval', 'run', 'continue', 'list', 'longlist',
|
'enable', 'ignore', 'condition', 'commands', 'step', 'next', 'until',
|
||||||
'args', 'print', 'pp', 'whatis', 'source', 'alias', 'unalias',
|
'jump', 'return', 'retval', 'run', 'continue', 'list', 'longlist',
|
||||||
'debug', 'quit',
|
'args', 'print', 'pp', 'whatis', 'source', 'alias', 'unalias',
|
||||||
]
|
'debug', 'quit',
|
||||||
|
]
|
||||||
|
|
||||||
docs = set()
|
for _command in _help_order:
|
||||||
for _command in _help_order:
|
__doc__ += getattr(Pdb, 'do_' + _command).__doc__.strip() + '\n\n'
|
||||||
__doc__ += getattr(Pdb, 'do_' + _command).__doc__.strip() + '\n\n'
|
__doc__ += Pdb.help_exec.__doc__
|
||||||
__doc__ += Pdb.help_exec.__doc__
|
|
||||||
|
del _help_order, _command
|
||||||
|
|
||||||
del _help_order, _command
|
|
||||||
|
|
||||||
# Simplified interface
|
# Simplified interface
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue