当前位置: 首页>>代码示例>>Python>>正文


Python sys.call_tracing方法代码示例

本文整理汇总了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']) 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:25,代码来源:test_sys.py

示例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 
开发者ID:Microvellum,项目名称:Fluid-Designer,代码行数:18,代码来源:pdb.py

示例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 
开发者ID:bkerler,项目名称:android_universal,代码行数:22,代码来源:pdb.py

示例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 
开发者ID:glmcdona,项目名称:meddle,代码行数:13,代码来源:pdb.py

示例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) 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:5,代码来源:test_sys.py

示例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) 
开发者ID:kdart,项目名称:pycopia,代码行数:10,代码来源:debugger.py

示例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) 
开发者ID:Microvellum,项目名称:Fluid-Designer,代码行数:4,代码来源:test_sys.py

示例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,)) 
开发者ID:ms-iot,项目名称:iot-utilities,代码行数:10,代码来源:visualstudio_py_debugger.py

示例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 
开发者ID:ofermend,项目名称:medicare-demo,代码行数:13,代码来源:pdb.py

示例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 
开发者ID:sassoftware,项目名称:conary,代码行数:13,代码来源:__init__.py

示例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 
开发者ID:sassoftware,项目名称:epdb,代码行数:13,代码来源:__init__.py

示例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 
开发者ID:duo-labs,项目名称:dlint,代码行数:36,代码来源:test_bad_sys_use.py


注:本文中的sys.call_tracing方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。