本文整理汇总了Python中IPython.core.debugger.Pdb.botframe方法的典型用法代码示例。如果您正苦于以下问题:Python Pdb.botframe方法的具体用法?Python Pdb.botframe怎么用?Python Pdb.botframe使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IPython.core.debugger.Pdb
的用法示例。
在下文中一共展示了Pdb.botframe方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: debug_shell
# 需要导入模块: from IPython.core.debugger import Pdb [as 别名]
# 或者: from IPython.core.debugger.Pdb import botframe [as 别名]
def debug_shell(user_ns, user_global_ns, traceback=None, execWrapper=None):
ipshell = None
if traceback:
try:
from IPython.core.debugger import Pdb
from IPython.terminal.ipapp import TerminalIPythonApp
ipapp = TerminalIPythonApp.instance()
ipapp.interact = False # Avoid output (banner, prints)
ipapp.initialize(argv=[])
def_colors = ipapp.shell.colors
pdb_obj = Pdb(def_colors)
pdb_obj.botframe = None # not sure. exception otherwise at quit
ipshell = lambda: pdb_obj.interaction(None, traceback=traceback)
except Exception:
pass
if not ipshell:
try:
import IPython
import IPython.terminal.embed
class DummyMod(object): pass
module = DummyMod()
module.__dict__ = user_global_ns
module.__name__ = "DummyMod"
ipshell = IPython.terminal.embed.InteractiveShellEmbed(
user_ns=user_ns, user_module=module)
except Exception:
pass
else:
if execWrapper:
old = ipshell.run_code
ipshell.run_code = lambda code: execWrapper(lambda: old(code))
if ipshell:
ipshell()
else:
if traceback:
import pdb
pdb.post_mortem(traceback)
else:
simple_debug_shell(user_global_ns, user_ns)
示例2: Pdb
# 需要导入模块: from IPython.core.debugger import Pdb [as 别名]
# 或者: from IPython.core.debugger.Pdb import botframe [as 别名]
except ImportError, err:
if throw:
raise
sys.__stdout__.write("cannot set breakpoint: %s:%s : %s" %
(file, line, err))
return
file = mod.__file__
sys.__stdout__.write("breaking in: %s" % file)
if file.endswith(".pyc"):
file = file[:-1]
pdb = Pdb(color_scheme='Linux', stdout=sys.__stdout__) # use sys.__stdout__ to work with nose tests
pdb.reset()
pdb.curframe = frame
while frame:
frame.f_trace = pdb.trace_dispatch
pdb.botframe = frame
frame = frame.f_back
templine = line
while templine < line + 10:
error = pdb.set_break(file, templine, cond=cond, temporary=temp)
if error:
templine += 1
else:
break
if error:
error = pdb.set_break(file, line, cond=cond, temporary=temp)
if throw:
raise Error(error)
sys.__stdout__.write("\n%s\n" % error)
return
sys.__stdout__.write("\n")