當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。