當前位置: 首頁>>代碼示例>>Python>>正文


Python debugger.Pdb方法代碼示例

本文整理匯總了Python中IPython.core.debugger.Pdb方法的典型用法代碼示例。如果您正苦於以下問題:Python debugger.Pdb方法的具體用法?Python debugger.Pdb怎麽用?Python debugger.Pdb使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在IPython.core.debugger的用法示例。


在下文中一共展示了debugger.Pdb方法的14個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: test_ipdb_magics2

# 需要導入模塊: from IPython.core import debugger [as 別名]
# 或者: from IPython.core.debugger import Pdb [as 別名]
def test_ipdb_magics2():
    '''Test ipdb with a very short function.

    >>> def bar():
    ...     pass

    Run ipdb.

    >>> with PdbTestInput([
    ...    'continue',
    ... ]):
    ...     debugger.Pdb().runcall(bar)
    > <doctest ...>(2)bar()
          1 def bar():
    ----> 2    pass
    <BLANKLINE>
    ipdb> continue
    ''' 
開發者ID:ktraunmueller,項目名稱:Computable,代碼行數:20,代碼來源:test_debugger.py

示例2: __init__

# 需要導入模塊: from IPython.core import debugger [as 別名]
# 或者: from IPython.core.debugger import Pdb [as 別名]
def __init__(self, color_scheme='NoColor', call_pdb=False, ostream=None):
        # Whether to call the interactive pdb debugger after printing
        # tracebacks or not
        self.call_pdb = call_pdb

        # Output stream to write to.  Note that we store the original value in
        # a private attribute and then make the public ostream a property, so
        # that we can delay accessing io.stdout until runtime.  The way
        # things are written now, the io.stdout object is dynamically managed
        # so a reference to it should NEVER be stored statically.  This
        # property approach confines this detail to a single location, and all
        # subclasses can simply access self.ostream for writing.
        self._ostream = ostream

        # Create color table
        self.color_scheme_table = exception_colors()

        self.set_colors(color_scheme)
        self.old_scheme = color_scheme  # save initial value for toggles

        if call_pdb:
            self.pdb = debugger.Pdb(self.color_scheme_table.active_scheme_name)
        else:
            self.pdb = None 
開發者ID:ktraunmueller,項目名稱:Computable,代碼行數:26,代碼來源:ultratb.py

示例3: debug

# 需要導入模塊: from IPython.core import debugger [as 別名]
# 或者: from IPython.core.debugger import Pdb [as 別名]
def debug(f, *args, **kwargs):
    from pdb import Pdb as OldPdb
    try:
        from IPython.core.debugger import Pdb
        kw = dict(color_scheme='Linux')
    except ImportError:
        Pdb = OldPdb
        kw = {}
    pdb = Pdb(**kw)
    return pdb.runcall(f, *args, **kwargs) 
開發者ID:Frank-qlu,項目名稱:recruit,代碼行數:12,代碼來源:testing.py

示例4: set_trace

# 需要導入模塊: from IPython.core import debugger [as 別名]
# 或者: from IPython.core.debugger import Pdb [as 別名]
def set_trace():
    from IPython.core.debugger import Pdb
    try:
        Pdb(color_scheme='Linux').set_trace(sys._getframe().f_back)
    except Exception:
        from pdb import Pdb as OldPdb
        OldPdb().set_trace(sys._getframe().f_back)

# -----------------------------------------------------------------------------
# contextmanager to ensure the file cleanup 
開發者ID:Frank-qlu,項目名稱:recruit,代碼行數:12,代碼來源:testing.py

示例5: with_fake_debugger

# 需要導入模塊: from IPython.core import debugger [as 別名]
# 或者: from IPython.core.debugger import Pdb [as 別名]
def with_fake_debugger(func):
        @functools.wraps(func)
        def wrapper(*args, **kwds):
            with tt.monkeypatch(debugger.Pdb, 'run', staticmethod(eval)):
                return func(*args, **kwds)
        return wrapper 
開發者ID:ktraunmueller,項目名稱:Computable,代碼行數:8,代碼來源:test_run.py

示例6: set_trace

# 需要導入模塊: from IPython.core import debugger [as 別名]
# 或者: from IPython.core.debugger import Pdb [as 別名]
def set_trace():
    from IPython.core.debugger import Pdb
    try:
        Pdb(color_scheme='Linux').set_trace(sys._getframe().f_back)
    except:
        from pdb import Pdb as OldPdb
        OldPdb().set_trace(sys._getframe().f_back)

#------------------------------------------------------------------------------
# contextmanager to ensure the file cleanup 
開發者ID:ktraunmueller,項目名稱:Computable,代碼行數:12,代碼來源:testing.py

示例7: set_trace

# 需要導入模塊: from IPython.core import debugger [as 別名]
# 或者: from IPython.core.debugger import Pdb [as 別名]
def set_trace(frame=None):
    update_stdout()
    wrap_sys_excepthook()
    if frame is None:
        frame = sys._getframe().f_back
    Pdb(def_colors).set_trace(frame) 
開發者ID:microsoft,項目名稱:DualLearning,代碼行數:8,代碼來源:__main__.py

示例8: post_mortem

# 需要導入模塊: from IPython.core import debugger [as 別名]
# 或者: from IPython.core.debugger import Pdb [as 別名]
def post_mortem(tb):
    update_stdout()
    wrap_sys_excepthook()
    p = Pdb(def_colors)
    p.reset()
    if tb is None:
        return
    p.interaction(None, tb) 
開發者ID:microsoft,項目名稱:DualLearning,代碼行數:10,代碼來源:__main__.py

示例9: run

# 需要導入模塊: from IPython.core import debugger [as 別名]
# 或者: from IPython.core.debugger import Pdb [as 別名]
def run(statement, globals=None, locals=None):
    Pdb(def_colors).run(statement, globals, locals) 
開發者ID:microsoft,項目名稱:DualLearning,代碼行數:4,代碼來源:__main__.py

示例10: runcall

# 需要導入模塊: from IPython.core import debugger [as 別名]
# 或者: from IPython.core.debugger import Pdb [as 別名]
def runcall(*args, **kwargs):
    return Pdb(def_colors).runcall(*args, **kwargs) 
開發者ID:microsoft,項目名稱:DualLearning,代碼行數:4,代碼來源:__main__.py

示例11: runeval

# 需要導入模塊: from IPython.core import debugger [as 別名]
# 或者: from IPython.core.debugger import Pdb [as 別名]
def runeval(expression, globals=None, locals=None):
    return Pdb(def_colors).runeval(expression, globals, locals) 
開發者ID:microsoft,項目名稱:DualLearning,代碼行數:4,代碼來源:__main__.py

示例12: set_trace

# 需要導入模塊: from IPython.core import debugger [as 別名]
# 或者: from IPython.core.debugger import Pdb [as 別名]
def set_trace():
    from IPython.core.debugger import Pdb
    try:
        Pdb(color_scheme='Linux').set_trace(sys._getframe().f_back)
    except:
        from pdb import Pdb as OldPdb
        OldPdb().set_trace(sys._getframe().f_back)

# -----------------------------------------------------------------------------
# contextmanager to ensure the file cleanup 
開發者ID:nccgroup,項目名稱:Splunking-Crime,代碼行數:12,代碼來源:testing.py

示例13: test_ipdb_magics

# 需要導入模塊: from IPython.core import debugger [as 別名]
# 或者: from IPython.core.debugger import Pdb [as 別名]
def test_ipdb_magics():
    '''Test calling some IPython magics from ipdb.

    First, set up some test functions and classes which we can inspect.

    >>> class ExampleClass(object):
    ...    """Docstring for ExampleClass."""
    ...    def __init__(self):
    ...        """Docstring for ExampleClass.__init__"""
    ...        pass
    ...    def __str__(self):
    ...        return "ExampleClass()"

    >>> def example_function(x, y, z="hello"):
    ...     """Docstring for example_function."""
    ...     pass

    Create a function which triggers ipdb.

    >>> def trigger_ipdb():
    ...    a = ExampleClass()
    ...    debugger.Pdb().set_trace()

    >>> with PdbTestInput([
    ...    'pdef example_function',
    ...    'pdoc ExampleClass',
    ...    'pinfo a',
    ...    'continue',
    ... ]):
    ...     trigger_ipdb()
    --Return--
    None
    > <doctest ...>(3)trigger_ipdb()
          1 def trigger_ipdb():
          2    a = ExampleClass()
    ----> 3    debugger.Pdb().set_trace()
    <BLANKLINE>
    ipdb> pdef example_function
     example_function(x, y, z='hello')
     ipdb> pdoc ExampleClass
    Class Docstring:
        Docstring for ExampleClass.
    Constructor Docstring:
        Docstring for ExampleClass.__init__
    ipdb> pinfo a
    Type:       ExampleClass
    String Form:ExampleClass()
    Namespace:  Locals
    File:       ...
    Docstring:  Docstring for ExampleClass.
    Constructor Docstring:Docstring for ExampleClass.__init__
    ipdb> continue
    ''' 
開發者ID:ktraunmueller,項目名稱:Computable,代碼行數:55,代碼來源:test_debugger.py

示例14: debugger

# 需要導入模塊: from IPython.core import debugger [as 別名]
# 或者: from IPython.core.debugger import Pdb [as 別名]
def debugger(self,force=False):
        """Call up the pdb debugger if desired, always clean up the tb
        reference.

        Keywords:

          - force(False): by default, this routine checks the instance call_pdb
          flag and does not actually invoke the debugger if the flag is false.
          The 'force' option forces the debugger to activate even if the flag
          is false.

        If the call_pdb flag is set, the pdb interactive debugger is
        invoked. In all cases, the self.tb reference to the current traceback
        is deleted to prevent lingering references which hamper memory
        management.

        Note that each call to pdb() does an 'import readline', so if your app
        requires a special setup for the readline completers, you'll have to
        fix that by hand after invoking the exception handler."""

        if force or self.call_pdb:
            if self.pdb is None:
                self.pdb = debugger.Pdb(
                    self.color_scheme_table.active_scheme_name)
            # the system displayhook may have changed, restore the original
            # for pdb
            display_trap = DisplayTrap(hook=sys.__displayhook__)
            with display_trap:
                self.pdb.reset()
                # Find the right frame so we don't pop up inside ipython itself
                if hasattr(self,'tb') and self.tb is not None:
                    etb = self.tb
                else:
                    etb = self.tb = sys.last_traceback
                while self.tb is not None and self.tb.tb_next is not None:
                    self.tb = self.tb.tb_next
                if etb and etb.tb_next:
                    etb = etb.tb_next
                self.pdb.botframe = etb.tb_frame
                self.pdb.interaction(self.tb.tb_frame, self.tb)

        if hasattr(self,'tb'):
            del self.tb 
開發者ID:ktraunmueller,項目名稱:Computable,代碼行數:45,代碼來源:ultratb.py


注:本文中的IPython.core.debugger.Pdb方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。