Format: application/x-python-code
1 o
2
3 ��hZ� � @ s d Z ddlmZ ddlZddlZddlZddlZddlZddlm Z ddl
4 mZ ddlm
5 Z
6 ddlmZ ddlmZmZmZ dd lmZ erLdd
7 lmZ dZdZdd
8 lmZ dZejdk Zdd� Z d dd�Z!e�"d�Z#dd� Z$d!dd�Z%G dd� de�ZG dd� de�Z&d"dd�Z'dS )#a�
9 Pdb debugger class.
10
11
12 This is an extension to PDB which adds a number of new features.
13 Note that there is also the `IPython.terminal.debugger` class which provides UI
14 improvements.
15
16 We also strongly recommend to use this via the `ipdb` package, which provides
17 extra configuration options.
18
19 Among other things, this subclass of PDB:
20 - supports many IPython magics like pdef/psource
21 - hide frames in tracebacks based on `__tracebackhide__`
22 - allows to skip frames based on `__debuggerskip__`
23
24
25 Global Configuration
26 --------------------
27
28 The IPython debugger will by read the global ``~/.pdbrc`` file.
29 That is to say you can list all commands supported by ipdb in your `~/.pdbrc`
30 configuration file, to globally configure pdb.
31
32 Example::
33
34 # ~/.pdbrc
35 skip_predicates debuggerskip false
36 skip_hidden false
37 context 25
38
39 Features
40 --------
41
42 The IPython debugger can hide and skip frames when printing or moving through
43 the stack. This can have a performance impact, so can be configures.
44
45 The skipping and hiding frames are configurable via the `skip_predicates`
46 command.
47
48 By default, frames from readonly files will be hidden, frames containing
49 ``__tracebackhide__ = True`` will be hidden.
50
51 Frames containing ``__debuggerskip__`` will be stepped over, frames whose parent
52 frames value of ``__debuggerskip__`` is ``True`` will also be skipped.
53
54 >>> def helpers_helper():
55 ... pass
56 ...
57 ... def helper_1():
58 ... print("don't step in me")
59 ... helpers_helpers() # will be stepped over unless breakpoint set.
60 ...
61 ...
62 ... def helper_2():
63 ... print("in me neither")
64 ...
65
66 One can define a decorator that wraps a function between the two helpers:
67
68 >>> def pdb_skipped_decorator(function):
69 ...
70 ...
71 ... def wrapped_fn(*args, **kwargs):
72 ... __debuggerskip__ = True
73 ... helper_1()
74 ... __debuggerskip__ = False
75 ... result = function(*args, **kwargs)
76 ... __debuggerskip__ = True
77 ... helper_2()
78 ... # setting __debuggerskip__ to False again is not necessary
79 ... return result
80 ...
81 ... return wrapped_fn
82
83 When decorating a function, ipdb will directly step into ``bar()`` by
84 default:
85
86 >>> @foo_decorator
87 ... def bar(x, y):
88 ... return x * y
89
90
91 You can toggle the behavior with
92
93 ipdb> skip_predicates debuggerskip false
94
95 or configure it in your ``.pdbrc``
96
97
98
99 License
100 -------
101
102 Modified from the standard pdb.Pdb class to avoid including readline, so that
103 the command line completion of other programs which include this isn't
104 damaged.
105
106 In the future, this class will be expanded with improvements over the standard
107 pdb.
108
109 The original code in this file is mainly lifted out of cmd.py in Python 2.2,
110 with minor changes. Licensing should therefore be under the standard Python
111 terms. For details on the PSF (Python Software Foundation) standard license,
112 see:
113
114 https://docs.python.org/2/license.html
115
116
117 All the changes since then are under the same license as IPython.
118
119 � )�annotationsN)�contextmanager)� lru_cache)�get_ipython)�exception_colors)�
120 PyColorize� coloransi� py3compat)�
121 TYPE_CHECKING)�InteractiveShellTzipdb> )�PdbZ__debuggerskip__)� �
122 c C s( | dkrd| d d S | dkrdS dS )z<generate the leading arrow in front of traceback or debugger� �-�> � �>� � )�padr r �Kc:\Users\shubh\Videos\agent\nova\Lib\site-packages\IPython/core/debugger.py�
123 make_arrow� s
124 r c C s t d��)z�Exception hook which handles `BdbQuit` exceptions.
125
126 All other exceptions are processed using the `excepthook`
127 parameter.
128 zs`BdbQuit_excepthook` is deprecated since version 5.1. It is still around only because it is still imported by ipdb.)�
129 ValueError)�etZev�tb�
130 excepthookr r r �BdbQuit_excepthook� s �r z
131 (?<=\n)\s+c C s t �d| �S )Nr )�RGX_EXTRA_INDENT�sub)Zmultiline_stringr r r �strip_indentation� � r r c s&