本文整理匯總了Python中pdb.main方法的典型用法代碼示例。如果您正苦於以下問題:Python pdb.main方法的具體用法?Python pdb.main怎麽用?Python pdb.main使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類pdb
的用法示例。
在下文中一共展示了pdb.main方法的8個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: _runscript
# 需要導入模塊: import pdb [as 別名]
# 或者: from pdb import main [as 別名]
def _runscript(self, filename):
# The script has to run in __main__ namespace (or imports from
# __main__ will break).
#
# So we clear up the __main__ and set several special variables
# (this gets rid of pdb's globals and cleans old variables on restarts).
import __main__
__main__.__dict__.clear()
__main__.__dict__.update({"__name__" : "__main__",
"__file__" : filename,
"__builtins__": __builtins__,
})
# When bdb sets tracing, a number of call and line events happens
# BEFORE debugger even reaches user's code (and the exact sequence of
# events depends on python version). So we take special measures to
# avoid stopping before we reach the main script (see user_line and
# user_call for details).
self._wait_for_mainpyfile = 1
self.mainpyfile = self.canonic(filename)
self._user_requested_quit = 0
statement = 'execfile( "%s")' % filename
self.run(statement)
# Simplified interface
示例2: _runscript
# 需要導入模塊: import pdb [as 別名]
# 或者: from pdb import main [as 別名]
def _runscript(self, filename):
# The script has to run in __main__ namespace (or imports from
# __main__ will break).
#
# So we clear up the __main__ and set several special variables
# (this gets rid of pdb's globals and cleans old variables on restarts).
import __main__
__main__.__dict__.clear()
__main__.__dict__.update({"__name__" : "__main__",
"__file__" : filename,
"__builtins__": __builtins__,
})
# When bdb sets tracing, a number of call and line events happens
# BEFORE debugger even reaches user's code (and the exact sequence of
# events depends on python version). So we take special measures to
# avoid stopping before we reach the main script (see user_line and
# user_call for details).
self._wait_for_mainpyfile = 1
self.mainpyfile = self.canonic(filename)
self._user_requested_quit = 0
statement = 'execfile(%r)' % filename
self.run(statement)
# Simplified interface
示例3: do_continue
# 需要導入模塊: import pdb [as 別名]
# 或者: from pdb import main [as 別名]
def do_continue(self, arg):
"""c(ont(inue))
Continue execution, only stop when a breakpoint is encountered.
"""
if not self.nosigint:
try:
self._previous_sigint_handler = \
signal.signal(signal.SIGINT, self.sigint_handler)
except ValueError:
# ValueError happens when do_continue() is invoked from
# a non-main thread in which case we just continue without
# SIGINT set. Would printing a message here (once) make
# sense?
pass
self.set_continue()
return 1
示例4: do_continue
# 需要導入模塊: import pdb [as 別名]
# 或者: from pdb import main [as 別名]
def do_continue(self, arg):
"""c(ont(inue))
Continue execution, only stop when a breakpoint is encountered.
"""
if not self.nosigint:
try:
Pdb._previous_sigint_handler = \
signal.signal(signal.SIGINT, self.sigint_handler)
except ValueError:
# ValueError happens when do_continue() is invoked from
# a non-main thread in which case we just continue without
# SIGINT set. Would printing a message here (once) make
# sense?
pass
self.set_continue()
return 1
示例5: _interaction
# 需要導入模塊: import pdb [as 別名]
# 或者: from pdb import main [as 別名]
def _interaction(self, frame, traceback):
# Restore the previous signal handler at the Pdb prompt.
if getattr(pdb.Pdb, '_previous_sigint_handler', None):
try:
signal.signal(signal.SIGINT, pdb.Pdb._previous_sigint_handler)
except ValueError: # ValueError: signal only works in main thread
pass
else:
pdb.Pdb._previous_sigint_handler = None
ret = self.setup(frame, traceback)
if ret:
# no interaction desired at this time (happens if .pdbrc contains
# a command like "continue")
self.forget()
return
if self.config.exec_if_unfocused:
self.exec_if_unfocused()
# Handle post mortem via main: add exception similar to user_exception.
if frame is None and traceback:
exc = sys.exc_info()[:2]
if exc != (None, None):
self.curframe.f_locals['__exception__'] = exc
if not self.sticky:
self.print_stack_entry(self.stack[self.curindex])
self.print_hidden_frames_count()
with self._custom_completer():
self.config.before_interaction_hook(self)
# Use _cmdloop on py3 which catches KeyboardInterrupt.
if hasattr(self, '_cmdloop'):
self._cmdloop()
else:
self.cmdloop()
self.forget()
示例6: do_run
# 需要導入模塊: import pdb [as 別名]
# 或者: from pdb import main [as 別名]
def do_run(self, arg):
"""Restart program by raising an exception to be caught in the main
debugger loop. If arguments were given, set them in sys.argv."""
if arg:
import shlex
argv0 = sys.argv[0:1]
sys.argv = shlex.split(arg)
sys.argv[:0] = argv0
raise Restart
示例7: do_run
# 需要導入模塊: import pdb [as 別名]
# 或者: from pdb import main [as 別名]
def do_run(self, arg):
"""run [args...]
Restart the debugged python program. If a string is supplied
it is split with "shlex", and the result is used as the new
sys.argv. History, breakpoints, actions and debugger options
are preserved. "restart" is an alias for "run".
"""
if arg:
import shlex
argv0 = sys.argv[0:1]
sys.argv = shlex.split(arg)
sys.argv[:0] = argv0
# this is caught in the main debugger loop
raise Restart
示例8: _runscript
# 需要導入模塊: import pdb [as 別名]
# 或者: from pdb import main [as 別名]
def _runscript(self, filename):
# The script has to run in __main__ namespace (or imports from
# __main__ will break).
#
# So we clear up the __main__ and set several special variables
# (this gets rid of pdb's globals and cleans old variables on restarts).
import __main__
__main__.__dict__.clear()
__main__.__dict__.update({"__name__" : "__main__",
"__file__" : filename,
"__builtins__": __builtins__,
})
# When bdb sets tracing, a number of call and line events happens
# BEFORE debugger even reaches user's code (and the exact sequence of
# events depends on python version). So we take special measures to
# avoid stopping before we reach the main script (see user_line and
# user_call for details).
self._wait_for_mainpyfile = True
self.mainpyfile = self.canonic(filename)
self._user_requested_quit = False
with open(filename, "rb") as fp:
statement = "exec(compile(%r, %r, 'exec'))" % \
(fp.read(), self.mainpyfile)
self.run(statement)
# Collect all command help into docstring, if not run with -OO