本文整理汇总了Python中sys.call_tracing方法的典型用法代码示例。如果您正苦于以下问题:Python sys.call_tracing方法的具体用法?Python sys.call_tracing怎么用?Python sys.call_tracing使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类sys
的用法示例。
在下文中一共展示了sys.call_tracing方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_call_tracing
# 需要导入模块: import sys [as 别名]
# 或者: from sys import call_tracing [as 别名]
def test_call_tracing(self):
def f(i):
return i * 2
def g():
pass
# outside of a traceback
self.assertEqual(10, sys.call_tracing(f, (5, )))
# inside of a traceback
log = []
def thandler(frm, evt, pl):
if evt == 'call':
log.append(frm.f_code.co_name)
if log[-1] == 'g':
sys.call_tracing(f, (5, ))
return thandler
sys.settrace(thandler)
g()
sys.settrace(None)
self.assertEqual(log, ['g', 'f'])
示例2: do_debug
# 需要导入模块: import sys [as 别名]
# 或者: from sys import call_tracing [as 别名]
def do_debug(self, arg):
"""debug code
Enter a recursive debugger that steps through the code
argument (which is an arbitrary expression or statement to be
executed in the current environment).
"""
sys.settrace(None)
globals = self.curframe.f_globals
locals = self.curframe_locals
p = Pdb(self.completekey, self.stdin, self.stdout)
p.prompt = "(%s) " % self.prompt.strip()
self.message("ENTERING RECURSIVE DEBUGGER")
sys.call_tracing(p.run, (arg, globals, locals))
self.message("LEAVING RECURSIVE DEBUGGER")
sys.settrace(self.trace_dispatch)
self.lastcmd = p.lastcmd
示例3: do_debug
# 需要导入模块: import sys [as 别名]
# 或者: from sys import call_tracing [as 别名]
def do_debug(self, arg):
"""debug code
Enter a recursive debugger that steps through the code
argument (which is an arbitrary expression or statement to be
executed in the current environment).
"""
sys.settrace(None)
globals = self.curframe.f_globals
locals = self.curframe_locals
p = Pdb(self.completekey, self.stdin, self.stdout)
p.prompt = "(%s) " % self.prompt.strip()
self.message("ENTERING RECURSIVE DEBUGGER")
try:
sys.call_tracing(p.run, (arg, globals, locals))
except Exception:
exc_info = sys.exc_info()[:2]
self.error(traceback.format_exception_only(*exc_info)[-1].strip())
self.message("LEAVING RECURSIVE DEBUGGER")
sys.settrace(self.trace_dispatch)
self.lastcmd = p.lastcmd
示例4: do_debug
# 需要导入模块: import sys [as 别名]
# 或者: from sys import call_tracing [as 别名]
def do_debug(self, arg):
sys.settrace(None)
globals = self.curframe.f_globals
locals = self.curframe_locals
p = Pdb(self.completekey, self.stdin, self.stdout)
p.prompt = "(%s) " % self.prompt.strip()
print >>self.stdout, "ENTERING RECURSIVE DEBUGGER"
sys.call_tracing(p.run, (arg, globals, locals))
print >>self.stdout, "LEAVING RECURSIVE DEBUGGER"
sys.settrace(self.trace_dispatch)
self.lastcmd = p.lastcmd
示例5: test_call_tracing
# 需要导入模块: import sys [as 别名]
# 或者: from sys import call_tracing [as 别名]
def test_call_tracing(self):
self.assertEqual(sys.call_tracing(str, (2,)), "2")
self.assertRaises(TypeError, sys.call_tracing, str, 2)
示例6: debug
# 需要导入模块: import sys [as 别名]
# 或者: from sys import call_tracing [as 别名]
def debug(self, arg):
sys.settrace(None)
globals = self.curframe.f_globals
locals = self.curframe.f_locals
p = Debugger(io=self._ui.IO)
p.reset()
sys.call_tracing(p.run, (arg, globals, locals))
sys.settrace(p.trace_dispatch)
示例7: test_call_tracing
# 需要导入模块: import sys [as 别名]
# 或者: from sys import call_tracing [as 别名]
def test_call_tracing(self):
self.assertRaises(TypeError, sys.call_tracing, type, 2)
示例8: context_dispatcher
# 需要导入模块: import sys [as 别名]
# 或者: from sys import call_tracing [as 别名]
def context_dispatcher(self, old, new):
self.stepping = STEPPING_NONE
# for those tasklets that started before we started tracing
# we need to make sure that the trace is set by patching
# it in the context switch
if old and new:
if hasattr(new.frame, "f_trace") and not new.frame.f_trace:
sys.call_tracing(new.settrace,(self.trace_func,))
示例9: do_debug
# 需要导入模块: import sys [as 别名]
# 或者: from sys import call_tracing [as 别名]
def do_debug(self, arg):
sys.settrace(None)
globals = self.curframe.f_globals
locals = self.curframe.f_locals
p = Pdb(self.completekey, self.stdin, self.stdout)
p.prompt = "(%s) " % self.prompt.strip()
print >>self.stdout, "ENTERING RECURSIVE DEBUGGER"
sys.call_tracing(p.run, (arg, globals, locals))
print >>self.stdout, "LEAVING RECURSIVE DEBUGGER"
sys.settrace(self.trace_dispatch)
self.lastcmd = p.lastcmd
示例10: do_debug
# 需要导入模块: import sys [as 别名]
# 或者: from sys import call_tracing [as 别名]
def do_debug(self, arg):
sys.settrace(None)
globals = self.curframe.f_globals
locals = self.curframe.f_locals
p = Epdb()
p.prompt = "(%s) " % self.prompt.strip()
print "ENTERING RECURSIVE DEBUGGER"
sys.call_tracing(p.run, (arg, globals, locals))
print "LEAVING RECURSIVE DEBUGGER"
sys.settrace(self.trace_dispatch)
self.lastcmd = p.lastcmd
示例11: do_debug
# 需要导入模块: import sys [as 别名]
# 或者: from sys import call_tracing [as 别名]
def do_debug(self, arg):
sys.settrace(None)
globals = self.curframe.f_globals
locals = self.curframe.f_locals
p = Epdb()
p.prompt = "(%s) " % self.prompt.strip()
print("ENTERING RECURSIVE DEBUGGER")
sys.call_tracing(p.run, (arg, globals, locals))
print("LEAVING RECURSIVE DEBUGGER")
sys.settrace(self.trace_dispatch)
self.lastcmd = p.lastcmd
示例12: test_bad_sys_usage
# 需要导入模块: import sys [as 别名]
# 或者: from sys import call_tracing [as 别名]
def test_bad_sys_usage(self):
python_node = self.get_ast_node(
"""
import sys
sys.call_tracing(lambda: 42, ())
sys.setprofile(lambda: 42)
sys.settrace(lambda: 42)
"""
)
linter = dlint.linters.BadSysUseLinter()
linter.visit(python_node)
result = linter.get_results()
expected = [
dlint.linters.base.Flake8Result(
lineno=4,
col_offset=0,
message=dlint.linters.BadSysUseLinter._error_tmpl
),
dlint.linters.base.Flake8Result(
lineno=5,
col_offset=0,
message=dlint.linters.BadSysUseLinter._error_tmpl
),
dlint.linters.base.Flake8Result(
lineno=6,
col_offset=0,
message=dlint.linters.BadSysUseLinter._error_tmpl
),
]
assert result == expected