本文整理匯總了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