Format: application/x-python-code
⬇ Download File (28.4 KB)
   1  o
   2  
   3  ��hZ��@sdZddlmZddlZddlZddlZddlZddlZddlm	Z	ddl
   4  mZddlm
   5  Z
   6  ddlmZddlmZmZmZdd	lmZerLdd
   7  lmZdZdZdd
   8  lmZdZejdkZdd�Z d dd�Z!e�"d�Z#dd�Z$d!dd�Z%Gdd�de�ZGdd�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  cCs(|dkrd|ddS|dkrdSdS)z<generate the leading arrow in front of traceback or debugger��-�> ��>��)�padrr�Kc:\Users\shubh\Videos\agent\nova\Lib\site-packages\IPython/core/debugger.py�
 123  make_arrow�s
 124  rcCstd��)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  excepthookrrr�BdbQuit_excepthook�s�rz
 131  (?<=\n)\s+cCst�d|�S)Nr)�RGX_EXTRA_INDENT�sub)Zmultiline_stringrrr�strip_indentation��r rcs&�fdd�}|jrt|j�||_|S)z�Make new_fn have old_fn's doc string. This is particularly useful
 132      for the ``do_...`` commands that hook into the help system.
 133      Adapted from from a comp.lang.python posting
 134      by Duncan Booth.cs�|i|��S�Nr)�args�kw��new_fnrr�wrapper�sz%decorate_fn_with_doc.<locals>.wrapper)�__doc__r )r&Zold_fnZadditional_textr'rr%r�decorate_fn_with_doc�sr)cs�eZdZUdZded<erdZddddd�ZdYd
 135  d�Zdd
 136  �Z	dZ�fdd�	Z
 137  dd�Zdd�Zer>dd�Z
 138  edd��Zdd�Zdd�Z�fdd�Zdd�Zeeej�ZZdZd d!�Z	"	d[d#d$�Zd%d&�Zd\d(d)�Zd]d*d+�Zd,d-�Zd.d/�Zd0d1�Zd2d3�Z e Z!d4d5�Z"d6d7�Z#e#Z$d8d9�Z%d:d;�Z&d<d=�Z'd>d?�Z(d@dA�Z)dBdC�Z*dDdE�Z+dFdG�Z,e,Z-�fdHdI�Z.dJdK�Z/e0dL�dMdN��Z1e0dL�dOdP��Z2�fdQdR�Z3dSdT�Z4dUdV�Z5e5Z6e4Z7dWdX�Z8�Z9S)^raLModified Pdb class, does not load readline.
 139  
 140      for a standalone version that uses prompt_toolkit, see
 141      `IPython.terminal.debugger.TerminalPdb` and
 142      `IPython.terminal.debugger.set_trace()`
 143  
 144  
 145      This debugger can hide and skip frames that are tagged according to some predicates.
 146      See the `skip_predicates` commands.
 147  
 148      r�shelli�TF)�tbhide�readonly�ipython_internal�debuggerskipN�c
 149  Ks
 150  zt|�|_|jdkrtd��Wnttfy#}ztd�|�d}~wwtj||||fi|��t�|_|jdurNtj	d}ddl
 151  m}|��|_|tj	d<|jj
 152  }	i|_t�|_tj}
 153  |j}tj|	d�|_|�|	�t|_d|_d|_|j|_tr�t�|_d|_dSdS)a>Create a new IPython debugger.
 154  
 155          Parameters
 156          ----------
 157          completekey : default None
 158              Passed to pdb.Pdb.
 159          stdin : default None
 160              Passed to pdb.Pdb.
 161          stdout : default None
 162              Passed to pdb.Pdb.
 163          context : int
 164              Number of lines of source code context to show when
 165              displaying stacktrace information.
 166          **kwargs
 167              Passed to pdb.Pdb.
 168  
 169          Notes
 170          -----
 171          The possibilities are python version dependent, see the python
 172          docs for more info.
 173          r�"Context must be a positive integerN�__main__)�TerminalInteractiveShell)�styleT) �int�contextr�	TypeError�OldPdb�__init__rr*�sys�modulesZ!IPython.terminal.interactiveshellr2�instance�colors�aliasesr�color_scheme_tablerZ
 174  TermColorsr�Parser�parser�
 175  set_colors�prompt�skip_hidden�report_skipped�default_predicates�_predicates�CHAIN_EXCEPTIONS�tuple�_chained_exceptions�_chained_exception_index)�self�completekey�stdin�stdoutr5�kwargs�eZ	save_mainr2Zcolor_scheme�CZcstrrrr8�s>
 176  
 177  �
 178  ��
 179  
 180  
 181  
 182  
 183  
 184  �zPdb.__init__cCs|j�|�||j_dS)z;Shorthand access to the color table scheme selector method.N)r>Zset_active_schemer@r3)rK�schemerrrrA3szPdb.set_colorscs$|dur	t��j}||_t��|�Sr")r9�	_getframe�f_back�
 185  initial_frame�super�	set_trace�rK�frame��	__class__rrrW8s
 186  z
 187  Pdb.set_tracecCsv|jdr|jj}tj�|�rt�|tj�sdS|jdr9||jt	|dd�fvr*dS|�
 188  |�}d|vr5dS|dSdS)zX
 189          Given a frame return whether it it should be hidden or not by IPython.
 190          r,Tr+rUNFZ__tracebackhide__)rF�f_code�co_filename�os�path�isfile�access�W_OK�curframe�getattr�_get_frame_locals)rKrY�fnameZframe_localsrrr�_hidden_predicate>s
 191  
 192  
 193  zPdb._hidden_predicatecsL�fdd�|D�}dd�t|�D���r$�jdr$�fdd�t|�D�}|S)z�
 194          Given an index in the stack return whether it should be skipped.
 195  
 196          This is used in up/down and where to skip frames.
 197          csg|]	}��|d��qS)r)rg)�.0�s�rKrr�
 198  <listcomp>]sz%Pdb.hidden_frames.<locals>.<listcomp>cSsg|]
 199  \}}|dkr|�qS)Z__ipython_bottom__r)rh�irirrrrk^sr-cs$g|]\}}|�dkr|nd�qS)rTr)rhrl�h)�ip_startrrrk`s$)�	enumeraterF)rK�stackZip_hider)rnrKr�
 200  hidden_framesSs
 201  
 202  zPdb.hidden_framescCs�g}t|t�rF|j|}}|durE||vrn/|�|�|jdur$|j}n|jdur/|js/|j}t|�|jkrA|�	d|j�d��n|dusn|}t
 203  t|��|fS)ae
 204              Given a tracecack or an exception, return a tuple of chained exceptions
 205              and current traceback to inspect.
 206              This will deal with selecting the right ``__cause__`` or ``__context__``
 207              as well as handling cycles, and return a flattened list of exceptions we
 208              can jump to with do_exceptions.
 209              Nz
 210  More than zQ chained exceptions found, not all exceptionswill be browsable with `exceptions`.)�
 211  isinstance�
 212  BaseException�
 213  __traceback__�append�	__cause__�__context__�__suppress_context__�len�MAX_CHAINED_EXCEPTION_DEPTH�messagerH�reversed)rK�	tb_or_exc�_exceptions�	traceback�currentrrr�_get_tb_and_exceptionses,
 214  
 215  
 216  
 217  ����zPdb._get_tb_and_exceptionsccsB�z||_t|�d|_dVWt�|_d|_dSt�|_d|_w)a>
 218              Context manager to ensure proper cleaning of exceptions references
 219              When given a chained exception instead of a traceback,
 220              pdb may hold references to many objects which may leak memory.
 221              We use this context manager to make sure everything is properly cleaned
 222              rNr)rIryrJrH)rK�
 223  exceptionsrrr�_hold_exceptions�s�
 224  �zPdb._hold_exceptionscCsB|js
 225  |�d�dS|sNt|j�D]:\}}||jkrdnd}t|�}t|�dkr0|dd�d}|j|jdur:dn|d	�}|�|�d|�d|���qdSzt|�}Wntyc|�	d
 226  �YdSwd|krqt|j�kr�nn'|j|jdur�|�	d�dS||_|�
 227  d|j|j�|�|j|j
 228  �dS|�	d
 229  �dS)awexceptions [number]
 230              List or change current exception in an exception chain.
 231              Without arguments, list all the current exception in the exception
 232              chain. Exceptions will be numbered, with the current exception indicated
 233              with an arrow.
 234              If given an integer as argument, switch to the exception at that index.
 235              z�Did not find chained exceptions. To move between exceptions, pdb/post_mortem must be given an exception object rather than a traceback.Nr� �P�Mz...z  -z>3zArgument must be an integerrz;This exception does not have a traceback, cannot jump to itzNo exception with that number)rIr{rorJ�reprryrtr4r�error�setup�print_stack_entryrp�curindex)rK�argZix�excrB�repZ	indicator�numberrrr�
 236  do_exceptions�sB����
 237  ��zPdb.do_exceptionscCs�zAtr8|�|�\}}t|t�r|dusJd��|�|��t�|||�Wd�WdS1s0wYWdSt�|||�WdStyV|j�	d|j
 238  ���YdSw)Nz$main exception must have a traceback�
 239  )rGr�rrrsr�r7�interaction�KeyboardInterruptrN�writer*Zget_exception_only)rKrYr}rIrrrrr��s
 240  &��zPdb.interactioncsF|�d�rd|dd�}n
 241  |�d�rd|dd�}t��|�}|S)z<Perform useful escapes on the command before it is executed.z??zpinfo2 N������?zpinfo �����)�endswithrV�precmd)rK�linerZrrr��s
 242  
 243  z
 244  Pdb.precmdcCst�||�Sr")r7�do_quit�rKr�rrr�new_do_quit�r!zPdb.new_do_quitc
 245  Cs
 246  |jj}|j}|dur|j}zt|�}|dkrtd��Wnttfy/}ztd�|�d}~wwzJd}t|�|j	�|j	�D]'\}}|rK|j
 247  rK|d7}q=|r]t|j�d|�d|�d��d}|j
 248  ||d�q=|rxt|j�d|�d|�d��WdSWdSty�YdSw)Nrr0rz    [... skipping � hidden frame(s)]r�)r5)r>�
 249  active_colors�Normalr5r4rr6�ziprqrprC�print�excNamer�r�)rKr5�Colors�ColorsNormalrP�skipped�hidden�frame_linenorrr�print_stack_trace�sB�
 250  ��
 251  �
 252  ���zPdb.print_stack_trace�
 253  -> c
 254  Cs�|dur|j}zt|�}|dkrtd��Wnttfy(}ztd�|�d}~wwt|�|d|�|jd�|\}}|jj}|j	j
 255  �||d�dS)Nrr0r��file)r5r4rr6r��format_stack_entryrNr\r]r*�hooks�synchronize_with_editor)rKr�Z
 256  prompt_prefixr5rPrY�lineno�filenamerrrr�s�
 257  ��zPdb.print_stack_entrycCs|t|dd�ur|jS|jS)aj "
 258          Accessing f_local of current frame reset the namespace, so we want to avoid
 259          that or the following can happen
 260  
 261          ipdb> foo
 262          "old"
 263          ipdb> foo = "new"
 264          ipdb> foo
 265          "new"
 266          ipdb> where
 267          ipdb> foo
 268          "old"
 269  
 270          So if frame is self.current_frame we instead return self.curframe_locals
 271  
 272          rcN)rd�curframe_locals�f_localsrXrrrreszPdb._get_frame_locals�: c
 273  Cs<|dur|j}zt|�}|dkrtd|jd�Wnttfy*td|jd�Ynwddl}g}|jj}|j	}d|j
 274  |f}d|j|j|f}	d|j
 275  |f}
 276  d|j|j|f}|\}}
 277  d}|�|�}d	|vrt|d	}||�|�d
 278  7}|�|�|�|jj�}|t�|�}|jjr�|jj}nd}d}|dkr�d
 279  |vr�|�|d
 280  �}nd}|	||f}||jur�|�d�n|�d�|�d||
 281  |f�|
 282  d|d}t�|�}t|t|�|�}t|d�}||||�}t|�D]+\}}|d||
 283  k}||ju�s|�r|�p|
 284  }|�|j |||d|||d��q�d�!|�S)Nrr0r�z%s%%s%sz%s%%s%s%%s%s�%%s%s%%s %s%%s�%%s%s%%s %s%%s%srZ
 285  __return__r�z<lambda>r��__args__z()rz  z	%s(%s)%s
 286  rr��arrow)"r5r4r�rNr6r�reprlibr>r�r�Z
 287  filenameEmZvNameZvalEmr��linenoEmr�rer�ruZcanonicr\r]r	Zcast_unicode�co_namerc�	linecache�getlines�minry�maxro�_Pdb__format_line�join)rKr�Zlprefixr5r��retr�r�Ztpl_linkZtpl_call�tpl_line�tpl_line_emrYr��return_valueZ	loc_frame�rvr��link�func�callr#�start�linesrlr�Z
 288  show_arrowZlinetplrrrr�.sl��
 289  
 290  
 291  
 292  
 293  
 294  
 295  ��
 296  zPdb.format_stack_entrycCs�d}d}|j�|d�\}}	|	s|}d}
 297  ||�|�vr$|�||�}|d}
 298  |
 299  r8|jj}t|
 300  j�}|j}|
 301  j	s8|j
 302  }d}
 303  |rS|
 304  tt|��t|�}dt|�t|�f}nd|
 305  t|�t|�f}|||||fS)Nr�strr��z%s%sz%*s)
 306  r@Zformat2Zget_file_breaksZ
 307  get_breaksr>r�r�r�Zbreakpoint_enabled�enabledZbreakpoint_disabledryr)rKr�r�r�r�r�Zbp_markZ
 308  bp_mark_color�new_line�err�bpZbpsr�Z
 309  numbers_widthr�numrrrZ
 310  __format_linevs*
 311  zPdb.__format_linecCs�zi|jj}|j}d|j|f}d|j|j|f}g}|dkr&t|d�r&|j}t||d�D]/}	t	�
 312  ||	�}
 313  |
 314  s9n$|	|jjkrJ|j
 315  |||	|
 316  dd�}
 317  n
 318  |j
 319  |||	|
 320  dd�}
 321  |�|
 322  �|	|_q-td	�|�|jd
 323  �WdStysYdSw)zIThe printing (as opposed to the parsing part of a 'list'
 324          command.r�r�z<string>�_exec_filenamerTr�Frr�N)r>r�r�r�r�r��hasattrr��ranger��getlinerc�f_linenor�rur�r�rNr�)rKr��first�lastr�r�r�r��srcr�r�rrr�print_list_lines�s2
 325  �
 326  �
 327  �zPdb.print_list_linescCs�|��std�|j��D]\}}td|d|�q
 328  dS|���d�}t|�dkr6tdt|j������dS|\}}||jvrOt|�dt|j������dS|��d	vr^t|�d
 329  ��dS|��dv|j|<t	|j�
 330  ��sttd�dSdS)
 331  aA
 332          Turn on/off individual predicates as to whether a frame should be hidden/skip.
 333  
 334          The global option to skip (or not) hidden frames is set with skip_hidden
 335  
 336          To change the value of a predicate
 337  
 338              skip_predicates key [true|false]
 339  
 340          Call without arguments to see the current values.
 341  
 342          To permanently change the value of an option add the corresponding
 343          command to your ``~/.pdbrc`` file. If you are programmatically using the
 344          Pdb instance you can also change the ``default_predicates`` class
 345          attribute.
 346          zcurrent predicates:z   �:Nr�rz:Usage: skip_predicates <type> <value>, with <type> one of z not in )�true�yes�1�no�false�0zA is invalid - use one of ('true', 'yes', '1', 'no', 'false', '0'))r�r�r��KWarning, all predicates set to False, skip_hidden may not have any effects.)�stripr�rF�items�splitry�set�keys�lower�any�values)rKr#�p�vZ
 347  type_value�type_�valuerrr�do_skip_predicates�s4�
 348  ���zPdb.do_skip_predicatescCsh|��std|j�d��n|����dvrd|_n|����dvr%d|_t|j���s2td�dSdS)	zk
 349          Change whether or not we should skip frames with the
 350          __tracebackhide__ attribute.
 351          zskip_hidden = z/, use 'yes','no', 'true', or 'false' to change.)r�r�T)r�r�Fr�N)r�r�rCr�r�rFr�r�rrr�do_skip_hidden�s���zPdb.do_skip_hiddencCsd|_d}|rJ|dkrJz.t|ii�}t|�td�kr/|\}}t|�}t|�}||kr.||}n	tdt|�d�}Wn(tdt|�|jd�YdS|jdusS|dkr]td|j	j
 352  d�}n|jd}|durj|d	}|�|j	jj
 353  ||�|}|j	jj
 354  }|jj�||d
 355  �dS)z9Print lines of code from the current stack frame
 356          �listN�.rrr/z*** Error in argument:r��
 357  r)�lastcmd�eval�typer4r�r�r�rNr�rcr�r�r\r]r*r�r�)rKr�r��xr�r�r�rrr�do_list�s4��
 358  
 359  zPdb.do_listcCs\t�|�\}}t�|�r|j|�|�ur|dfSt�|�r!|dfSt�||d��|dfS)Nr)�inspect�
 360  findsource�isframe�	f_globalsre�ismodule�getblock)rK�objr�r�rrr�getsourceliness
 361  zPdb.getsourcelinesc
 362  Cspd|_z
 363  |�|j�\}}Wnty%}z|�|�WYd}~dSd}~ww|t|�}|�|jjj||�dS)zfPrint lines of code from the current stack frame.
 364  
 365          Shows more lines than 'list' does.
 366          ZlonglistN)	r�rrc�OSErrorr�ryr�r\r])rKr�r�r�r�r�rrr�do_longlist"s
 367  ��zPdb.do_longlistcCs�t��}t�d�|jj}|j}|j|j|j|j	d�}|j
 368  |_
 369  d|j��|_|�
 370  d�t�|j|||f�|�
 371  d�t�|�|j|_dS)z�debug code
 372          Enter a recursive debugger that steps through the code
 373          argument (which is an arbitrary expression or statement to be
 374          executed in the current environment).
 375          N)rLrMrNz(%s) zENTERING RECURSIVE DEBUGGERzLEAVING RECURSIVE DEBUGGER)r9�gettrace�settracercr�r�r[rLrMrNZuse_rawinputrBr�r{�call_tracing�runr�)rKr�Ztrace_function�globals�localsr�rrr�do_debug1s
 376  �
 377  
 378  
 379  zPdb.do_debugcC�.d|jfd|jjfg}|j�d�||d�dS)zZPrint the call signature for any callable object.
 380  
 381          The debugger interface to %pdef�Locals�GlobalsZpdef��
 382  namespacesN�r�rcr�r*Zfind_line_magic�rKr�rrrr�do_pdefE�
 383  �zPdb.do_pdefcCr)zLPrint the docstring for an object.
 384  
 385          The debugger interface to %pdoc.r
 386  rZpdocrNrrrrr�do_pdocOrzPdb.do_pdoccCr)zuPrint (or run through pager) the file where an object is defined.
 387  
 388          The debugger interface to %pfile.
 389          r
 390  rZpfilerNrrrrr�do_pfileYs
 391  �zPdb.do_pfilecCr)zdProvide detailed information about an object.
 392  
 393          The debugger interface to %pinfo, i.e., obj?.r
 394  rZpinforNrrrrr�do_pinfodrzPdb.do_pinfocCr)zlProvide extra detailed information about an object.
 395  
 396          The debugger interface to %pinfo2, i.e., obj??.r
 397  rZpinfo2rNrrrrr�	do_pinfo2nrz
 398  Pdb.do_pinfo2cCr)z;Print (or run through pager) the source code for an object.r
 399  rZpsourcerNrrrrr�
 400  do_psourcexs
 401  �zPdb.do_psourcec
 402  Cs\|r(zt|�}Wnty }z|�|�WYd}~dSd}~ww|�|�dS|��dS)a4w(here)
 403          Print a stack trace, with the most recent frame at the bottom.
 404          An arrow indicates the "current frame", which determines the
 405          context of most commands. 'bt' is an alias for this command.
 406  
 407          Take a number as argument as an (optional) number of context line to
 408          printN)r4rr�r�)rKr�r5r�rrr�do_where�s
 409  ��zPdb.do_wherecsNt��|�}|r
 410  |S|jdr%t|jjvrdS|jr%|�|j��t�r%dSdS)a#
 411          _stop_in_decorator_internals is overly restrictive, as we may still want
 412          to trace function calls, so we need to also update break_anywhere so
 413          that is we don't `stop_here`, because of debugger skip, we may still
 414          stop at any point inside the function
 415  
 416          r.TF)	rV�break_anywhererF�DEBUGGERSKIPr\�co_varnamesrTre�get)rKrY�suprZrrr�s	
 417  zPdb.break_anywherecCs|jdsdS|�|�S)z]
 418          Utility to tell us whether we are in a decorator internal and should stop.
 419  
 420          r.F)rF�_cachable_skiprXrrr�)_is_in_decorator_internal_and_should_skip�s
 421  
 422  z-Pdb._is_in_decorator_internal_and_should_skipicCs6t|dd�r|j}|�|��t�rdSt|dd�sdS)z�
 423          Cache looking up for DEBUGGERSKIP on parent frame.
 424  
 425          This should speedup walking through deep frame when one of the highest
 426          one does have a debugger skip.
 427  
 428          This is likely to introduce fake positive though.
 429          rTNT)rdrTrerrrXrrr�%_cached_one_parent_frame_debuggerskip�s
 430  �z)Pdb._cached_one_parent_frame_debuggerskipcCs"t|jjvrdS|�|�rdSdS)NTF)rr\rr"rXrrrr �s
 431  
 432  zPdb._cachable_skipcs`|�|�dur	dSd}|jr|�|�}|r*|jr*|jj}|j}t|j�d|�d��t	��
 433  |�S)NTFz     [... skipped 1 hidden frame]r�)r!rCrgrDr>r�r�r�r�rV�	stop_here)rKrYr�r�r�rZrrr#�s
 434  �z
 435  Pdb.stop_herec
 436  Cs|jdkr|�d�dSzt|pd�}Wnty%|�d|�YdSwd}|dkr/d}n:d}|�|j�}t|jddd�D]}||rN|jrN|d7}q@|d7}||krXnq@|�d�dS|jj	}|j
 437  }	|}|�|�|r�t|j
 438  �d|�d	|	�d
 439  ��dSdS)z�u(p) [count]
 440          Move the current frame count (default one) levels up in the
 441          stack trace (to an older frame).
 442  
 443          Will skip hidden frames.
 444          rzOldest frameNr�Invalid frame count (%s)r�zGall frames above hidden, use `skip_hidden False` to get get into those.�    [... skipped r�r�)r�r�r4rrqrpr�rCr>r�r��
 445  _select_framer�r�)
 446  rKr��countr��	_newframe�counterrqrlr�r�rrr�do_up�sF
 447  	
 448  ���
 449  ��z	Pdb.do_upc
 450  Cs|jdt|j�kr|�d�dSzt|pd�}Wnty*|�d|�YdSw|dkr7t|j�d}nNd}d}|�|j�}t|jdt|j��D]}||rZ|jrZ|d7}qL|d7}||krdnqL|�d�dS|j	j
 451  }|j}	|r�t|j
 452  �d|�d|	�d	��|}|�|�dS)
 453  z�d(own) [count]
 454          Move the current frame count (default one) levels down in the
 455          stack trace (to a newer frame).
 456  
 457          Will skip hidden frames.
 458          rzNewest frameNr$rzGall frames below hidden, use `skip_hidden False` to get get into those.r%r�r�)r�ryrpr�r4rrqr�rCr>r�r�r�r�r&)
 459  rKr�r'r(r)r�rqrlr�r�rrr�do_downsD
 460  ����zPdb.do_downcCsLzt|�}|dkrt��||_WdSty%|�d|j�d��YdSw)z�context number_of_lines
 461          Set the number of lines of source code to show when displaying
 462          stacktrace information.
 463          rzJThe 'context' command requires a positive integer argument (current value z).N)r4rr5r�)rKr5Znew_contextrrr�
 464  do_context;s
 465  ��zPdb.do_context)NNNr/r")r�N)r�N)F):�__name__�
 466  __module__�__qualname__r(�__annotations__rGrzrEr8rArWrgrqr�rr�r�r�r�r�r)r7r�Zdo_qr�r�rer�r�r�r�r�r�Zdo_lrrZdo_llrrrrrrrrZdo_wrr!rr"r r#r*r+Zdo_dZdo_ur,�
 467  __classcell__rrrZrr�sx
 468  �
 469  O#
 470  .
 471  
 472  �
 473  
 474  H"-"	
 475  
 476  
 477  
 478  
 479  
 480  
 481  .,rc@s"eZdZdZddd�Zdd�ZdS)�InterruptiblePdbzJVersion of debugger where KeyboardInterrupt exits the debugger altogether.NcCsFztj||d�WSty"dd�|_|�d�t�d�d|_�w)z>Wrap cmdloop() such that KeyboardInterrupt stops the debugger.)�introcSsdS)NFr)rYrrr�<lambda>Ssz*InterruptiblePdb.cmdloop.<locals>.<lambda>rNF)r7�cmdloopr�r#r�r9rZquitting)rKr3rrrr5Ns
 482  
 483  
 484  �zInterruptiblePdb.cmdloopcCs8	z
 485  d|_|��d|_WdSty|�d��w)NTFz--KeyboardInterrupt--)Zallow_kbdintr5r�r{rjrrr�_cmdloopYs
 486  �zInterruptiblePdb._cmdloopr")r-r.r/r(r5r6rrrrr2Ks
 487  r2cCs0t�}|dur|�|�|�|pt��j�dS)zm
 488      Start debugging from `frame`.
 489  
 490      If frame is not specified, debugging starts from caller's frame.
 491      N)rr{rWr9rSrT)rY�header�pdbrrrrWgs
 492  rWr")r)NN)(r(�
 493  __future__rr�r�r^�rer9�
 494  contextlibr�	functoolsrZIPythonrZIPython.core.excolorsrZ
 495  IPython.utilsrrr	�typingr
 496  ZIPython.core.interactiveshellrZ__skip_doctest__rBr8rr7r�version_inforGrr�compilerr r)r2rWrrrr�<module>sF{
 497  
 498  	
 499  
 500