
    
dЊ                     F   d Z ddlZddlZddlZddlZddlZddlZddlZddlm	Z	 ddl
mZ ddlmZ ddlmZ ddlmZmZ ddlmZmZ dd	lmZmZmZmZmZmZ esdd
lmZ ddl Z e!fZ"n
ddl#Z ddl$m%Z  ej&        e'          Z( G d de)          Z* G d dee)          Z+d Z,dS )zSpyder debugger.    N)
namedtuple)ZMQExitAutocall)Pdb)get_ipython)	CommErrorfrontend_request)path_is_librarycapture_last_Expr)TimeoutErrorPY2_printisidentifierPY3input)TransformerManager)IPythonInputSplitterc                   $    e Zd ZdZd Zd Zd ZdS )DebugWrapperz;
    Notifies the frontend when debugging starts/stops
    c                     || _         d S N)pdb_obj)selfr   s     Blib/python3.11/site-packages/spyder_kernels/customize/spyderpdb.py__init__zDebugWrapper.__init__,   s        c                     d| j         _        	 t          d                              d           dS # t          t
          f$ r t                              d           Y dS w xY w)z#
        Debugging starts.
        Tblocking/Could not send debugging state to the frontend.Nr   _frontend_notifiedr   set_debug_stater   r   loggerdebugr   s    r   	__enter__zDebugWrapper.__enter__/   sy     +/'	Ld+++;;DAAAAA<( 	L 	L 	LLLJKKKKKK	L   #3 +A"!A"c                     d| j         _        	 t          d                              d           dS # t          t
          f$ r t                              d           Y dS w xY w)z!
        Debugging ends.
        FTr   r   Nr    )r   exc_typeexc_valexc_tbs       r   __exit__zDebugWrapper.__exit__9   sy     +0'	Ld+++;;EBBBBB<( 	L 	L 	LLLJKKKKKK	Lr'   N)__name__
__module____qualname____doc__r   r&   r,    r   r   r   r   (   sS           L L LL L L L Lr   r   c                   $    e Zd ZdZdZdZ	 	 d& fd	Zd Zd Zd	 Z	d
 Z
	 	 d' fd	Z fdZ fdZeZeZd Zd Zd Zd Z fdZd Z fdZ fdZ fdZd Zd(dZd)dZd Z fdZerd Zd Z d  Z!d* fd!	Z"d* fd"	Z# fd#Z$d$ Z%d% Z& xZ'S )+	SpyderPdbz
    Extends Pdb to add features:

     - Process IPython magics.
     - Accepts multiline input.
     - Better interrupt signal handling.
     - Option to skip libraries while stepping.
     - Add completion to non-command code.
    TtabNFc                 R   d| _         d| _        d| _        d| _        d| _        d| _        d| _        d| _        t          t          |           
                                 d| _        d| _        d| _        d| _        d| _        d| _        t#          | d          rd| j        d<   dS dS )z	Init Pdb.NFT_predicatesdebuggerskip)curframe_localscontinue_if_has_breakpointspdb_ignore_libpdb_execute_eventspdb_use_exclamation_mark_exclamation_warning_printedpdb_stop_first_line_disable_next_stack_entrysuperr3   r   _pdb_breakingr!   _previous_stepreport_skippedremote_filename_cmd_input_linehasattrr6   )r   completekeystdinstdoutskipnosigint	__class__s         r   r   zSpyderPdb.__init__R   s      $+0(#"'(-%,1)#' ).&i'')))""' # $  $  $ 4'' 	5 05D^,,,	5 	5r   c                 D    | j         st          d           d| _         dS dS )z'Print pdb warning for exclamation mark.z]Warning: The exclamation mark option is enabled. Please use '!' as a prefix for Pdb commands.TN)r=   printr%   s    r   print_exclamation_warningz#SpyderPdb.print_exclamation_warning|   s@    0 	5 A B B B04D---	5 	5r   c                 :   | j         }|dd         dk    r|dd         }nP| j        rI|                                  |                     d|                                d         z   dz              dS |                    d          r|                     d           dS | j        }| j        j        }| j        r| 	                    |          \  }}}|r||v p||v p|t          j        v }|d	v r!||v rt          ||         t                    rd
}t          | d|z   d          }|du}	d
}
	 t          j        t          j        |                    D ] }t          |t          j                  rd}
 n!n# t&          $ r Y nw xY w|	r*|s|
s|| _         ||          S |                                  	 t+                                          |          }t.          j        }t.          j        }t.          j        }	 | j        t.          _        | j        t.          _        | j        t.          _        |r&t7                      j                            d           t          j        |          }|                                dd         dk    rd
}nt?          |d          \  }}||urddg}t          j         |d<   ||d<   |fd|D             z  }|dz   gz  }|dgz  }|g dz  }t          j        d!                    |          dz             }|j"        d         j"        dd         |j"        z   |j"        d         j"        dd         z   |j"        d         _"        |}tG          tI          |dd          |           |r|%                    dd          }|t.          j        &                                 t.          j'        &                                 	 tQ          d
          )                    tU          |                     n4# tV          tX          f$ r  t[          dtU          |                     Y nw xY w|r&t7                      j                            d           |t.          _        |t.          _        |t.          _        dS # |r&t7                      j                            d           |t.          _        |t.          _        |t.          _        w xY w# t\          $ r t^          rat/          j0                    dd         \  }}tc          |          tc          d           k    r|}n|j2        }tZ          | j        z	  d!|d"z   |f Y dS t/          j0                    dd         }|                     tg          j4        | d         5                                           Y dS w xY w)#z6
        Default way of running pdb statment.
        N   !zUnknown command 'r   'z%debugzhPlease don't use '%debug' in the debugger.
For a recursive debugger, use the pdb 'debug' command instead)quitexitFdo_Tpre_execute;_spyderpdb_outz    zdef _spyderpdb_code():_spyderpdb_builtins_locals_spyderpdb_localsc                 `    g | ]*}t          |          d                     |          z   +S )z{k} = _spyderpdb_locals['{k}'])k)r   format).0r^   indents     r   
<listcomp>z%SpyderPdb.default.<locals>.<listcomp>   s[     A A A!"QAV&F&M&M 'N ' '  A A Ar   z6_spyderpdb_locals.update(_spyderpdb_builtins_locals())z_spyderpdb_code())zdel _spyderpdb_codezdel _spyderpdb_localszdel _spyderpdb_builtins_locals
z<stdin>execr   z	pdb out> post_execute    ***:)6r;   r<   rO   errorsplit
startswithr8   curframe	f_globals	parselinebuiltins__dict__
isinstancer   getattrastwalkparseAssignSyntaxErrorlastcmdr   transform_cellsysrI   rH   displayhookr   eventstriggerrstripr
   localsjoinbodyrd   compilepopflushstderrr   show_pdb_outputreprr   r   rN   BaseExceptionr   exc_infotyper-   	tracebackformat_exception_onlystrip)r   lineexecute_eventsr   globalscmdargcmd_in_namespacecmd_func
is_pdb_cmdis_assignmentnodesave_stdout
save_stdinsave_displayhookcode_astcapture_last_expressioncodefun_astouttvexc_type_namer   ra   s                           @r   defaultzSpyderPdb.default   sP    08s??8DD* 	**,,,JJ*TZZ\\!_<sBCCCF??8$$ 	JJ * + + + F%-)( "	9!^^D11NCd 97N 0f}0h// ! ***g~~*#CL/+; +;~ ,1("4d;;%T1
 % #4 9 9 " "%dCJ77 ",0M!E" #   D  9+ 9M 9'+'x}}, 66888p	L%''66t<<D*KJ"`3 J	![
"&"2! A ]])11-@@@9T??;;==%,,.3++8I "294 945H5 ((* $F45D =EOG89 4:G/0  A A A A&,A A A AD
 V '= = > >D 011D     D "i		$$(>??G  Q,SbS1"-(!,q/.rss34 LO(
  'HWXy&997CCC* 
:!++&6==C
((***
((***:,e<<<LL $S		+ + + + )<8 : : :!+tCyy99999:
 " B ]])11.AAA(
&	"2	 " B ]])11.AAA(
&	"22222 
	L 
	L 
	L 	L|~~bqb)177d2hh&&$%MM&'jm#UMC,?BBBBB<>>"1"-

3X>rBHHJJL L L L L L
	Lsm   )AE1 1
E>=E>.AS 4GQ? 0O= <Q? =.P.+Q? -P..Q? 1AS ?ASS A/VAVVc                     | j         rt          |                     d           t          j        d           d| _        |                                  |                     t          j                               dS )z
        Handle a sigint signal. Break on the frame above this one.

        This method is not present in python2 so this won't be called there.
        z-
Program interrupted. (Use 'cont' to resume).NT)	allow_kbdintKeyboardInterruptmessager{   settracerA   set_step	set_trace	_getframe)r   signumframes      r   sigint_handlerzSpyderPdb.sigint_handler-  sk      	$##EFFFT!s}'''''r   c                    | j         r+d| _         |r"|j        r|                     |j        |          S |                     ||           |                     | j        | j                            | j        r|                                  n;t          |           5  |                                  ddd           n# 1 swxY w Y   | 
                                 dS )z
        Called when a user interaction is required.

        If this is from sigint, break on the upper frame.
        If the frame is in spydercustomize.py, quit.
        Notifies spyder and print current code.

        FN)rA   f_backinteractionsetupprint_stack_entrystackcurindexr!   _cmdloopr   forget)r   r   r   s      r   r   zSpyderPdb.interaction<  s     	A!&D A A''i@@@

5)$$$tz$-8999" 	 MMOOOOd##                                 s   B::B>B>
-> c                 x    | j         r	d| _         dS t          t          |                               |||          S )z*Disable printing stack entry if requested.FN)r?   r@   r3   r   )r   frame_linenoprompt_prefixcontextrL   s       r   r   zSpyderPdb.print_stack_entryS  sF     ) 	-2D*FY%%77-2 2 	2r   c                 8   |1d|j         v r(|j         d         dk    r|                     d           dS t          t          |                               |          sdS |j        j        }|                    d          rdS | j        rt          |          rdS dS )zCheck if pdb should stop here.N__tracebackhide____pdb_exit__rU   F<T)
f_localsonecmdr@   r3   	stop_heref_codeco_filenamerl   r:   r	   )r   r   filenamerL   s      r   r   zSpyderPdb.stop_here]  s    '5>99N#67>IIKK5Y%%//66 	5<+s## 	4 	?8#<#< 	5tr   c                    t          t          |                               |           	 t          d                                           dS # t          t
          f$ r t                              d           Y dS w xY w)a4  w(here)
        Print a stack trace, with the most recent frame at the bottom.
        An arrow indicates the "current frame", which determines the
        context of most commands. 'bt' is an alias for this command.

        Take a number as argument as an (optional) number of context line to
        printFr   z-Could not send where request to the frontend.N)r@   r3   do_wherer   r   r   r#   r$   )r   r   rL   s     r   r   zSpyderPdb.do_whereo  s     	i'',,,	Je,,,5577777<( 	J 	J 	JLLHIIIIII	Js   "A +A>=A>c                 h    | j         r|                     ||          S |                     ||          S )z0
        Respond to a complete request.
        )r<   _complete_exclamation_complete_default)r   r   
cursor_poss      r   do_completezSpyderPdb.do_complete  s;     ( 	<--dJ???))$
;;;r   c                    |t          |          }|d|                             d          d         }|}|                                }|sdS t          |          t          |          z
  }|t          |          z
  |z
  }||z
  }d}	d}
|dk    rG|                     |          \  }}}|dk    r'	 t	          | d|z             }	d}
n$# t
          $ r Y nw xY wn|d         d	k    r| j        }	d
 }|r' ||          s|dd         }|dz  }|r ||          g |	r |	||||          |t          |          z
  }|
rt                      j        }| j	        rV| j
        r.t          dddg          } || j
        | j	        j                  }n| j	        }|j                            |           |                    ||          }|j                                         |	s|S |d         }||d         k     r|||d                  fd|D             }n2|d         |k     r&||d         |         fdD             |d         }fd|D             z  ||i ddS )zP
        Respond to a complete request if not pdb_use_exclamation_mark.
        N rX   Tr   rg   	complete_FrR   c                 h    | r| d         dk    rdS t          |                     dd                    S Nr   .Frg   r   replacetexts    r   is_name_or_composedz8SpyderPdb._complete_default.<locals>.is_name_or_composed  s7     47c>>uS" 5 5666r   rQ   Framer   rn   matchescursor_startc                     g | ]}|z   S r1   r1   r`   mmissing_txts     r   rb   z/SpyderPdb._complete_default.<locals>.<listcomp>  s    DDD1{QDDDr   c                     g | ]}|z   S r1   r1   r   s     r   rb   z/SpyderPdb._complete_default.<locals>.<listcomp>  s    <<<q;?<<<r   c                     g | ]}|v|	S r1   r1   )r`   matchr   s     r   rb   z/SpyderPdb._complete_default.<locals>.<listcomp>  s#    OOO%%w:N:N:N:N:Nr   okr   
cursor_endr   metadatastatus)lenrk   lstripro   rs   AttributeErrorcompletenamesr   kernelrm   r8   r   rn   shellset_completer_frame_do_complete)r   r   r   r   origliner   strippedbegidxendidxcompfuncipython_do_completer   args_r   r   r   r   r   resultipy_matchesr   r   s                        @@r   r   zSpyderPdb._complete_default  s7    TJ KZK &&s++B/   	Fx==3t99,c$ii'(2h&"A::>>$//LCqbyy&t[3->??H*/''%   D  !W^^)H	7 	7 	7  	..t44 	8DaKF  	..t44 	  	;htT66::G!CII- 	P ]])F} 8' *&w[0IJJE!E$"6"&-"9; ;EE !ME00777((z::FL,,...  +Kf^444"<~0F#FGDDDDDDD',66"6.#9,#FG<<<<G<<<%n5 OOOO;OOOOG"( ,	    	 s   4C
 

CCc                    |t          |          }|d|                             d          d         }|}|                                }|sdS |d         dk    }d}t          |          t          |          z
  }|t          |          z
  |z
  }	||z
  }
d}|rz|dd         }|	dz  }	|
dz  }
|	dk    rd}|dd         }|	dz  }	| j        }nG|                     |          \  }}}|d	k    r&	 t          | d
|z             }n# t          $ r Y dS w xY wdS |s,d }|r' ||          s|dd         }|	dz  }	|r ||          |t          |          z
  }g }|r ||||	|
          }|||i ddS t                      j        }| j	        rV| j
        r.t          dddg          } || j
        | j	        j                  }n| j	        }|j                            |           |                    ||          }|j                                         |S )zL
        Respond to a complete request if pdb_use_exclamation_mark.
        Nr   rX   r   rR   FrQ   Trg   r   c                 h    | r| d         dk    rdS t          |                     dd                    S r   r   r   s    r   r   z<SpyderPdb._complete_exclamation.<locals>.is_name_or_composed  s7     !tAw#~~ 5#DLLb$9$9:::r   r   r   r   r   rn   )r   rk   r   r   ro   rs   r   r   r   rm   r8   r   rn   r   r   r   )r   r   r   r   r   r   is_pdb_commandis_pdb_command_namer   r   r   r   r   r   r   r   r   r   r   r   r   r   s                         r   r   zSpyderPdb._complete_exclamation  s    TJ KZK &&s++B/   	FaC#x==3t99,c$ii'(2h& 	8DaKFaKF||&*#ABBx!-#~~d33T1"99#*4s1B#C#C)   
 F" 
	; ; ;  22488 ABBx!  22488  "CII- 	htT66::G"( ,   %= 	4# &"7Z,EFFd2"m57 7 L,,U333$$T:66((***s   -D 
DDc                     d | _         d S r   )rB   r%   s    r   postloopzSpyderPdb.postloop<  s     #r   c                    	 t          d                                          }|d         | _        |d         | _        |d         | _        |d         | _        | j        r|                     |d                    | j        r| 	                                 n1# t          t          f$ r t                              d           Y nw xY wt          t          |                                            d	S )
z>Ask Spyder for breakpoints before the first prompt is created.Tr   r:   r;   r<   r>   breakpointsz,Could not get breakpoints from the frontend.N)r   get_pdb_settingsr:   r;   r<   r>   startingset_spyder_breakpointssend_initial_notificationpublish_pdb_stater   r   r#   r$   r@   r3   preloop)r   pdb_settingsrL   s     r   r  zSpyderPdb.preloopB  s    	I+T:::KKMML"./?"@D&23G&HD#,8*-,D)'34I'JD$} I++L,GHHH- )&&(((<( 	I 	I 	ILLGHHHHH	Ii&&(((((s   BB +CCc                 >    |                      | j        dd           dS )z
        Stop only at breakpoints or when finished.

        Reimplemented to avoid stepping out of debugging if there are no
        breakpoints. We could add more later.
        NrX   )_set_stopinfobotframer%   s    r   set_continuezSpyderPdb.set_continueS  s$     	4=$33333r   c                 |    t          t          |                                            | t                      _        dS )z3
        Register Pdb session after reset.
        N)r@   r3   resetr   pdb_session)r   rL   s    r   r  zSpyderPdb.reset]  s3     	i$$&&&$(!!!r   c                    	 t          t          |                               |           n# t          $ r t          r_t          j                    dd         \  }}t          |          t          d          k    r|}n|j        }t          | j
        z	  d|dz   |f nTt          j                    dd         }|                     t          j        | d                                                    Y nw xY w| t                      _        dS )z
        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).
        Nrf   rg   rh   ri   rX   )r@   r3   do_debug	Exceptionr   r{   r   r   r-   rN   rI   rj   r   r   r   r   r  )r   r   r   r   r   r   rL   s         r   r  zSpyderPdb.do_debugd  s   	L)T""++C0000 
	L 
	L 
	L 	L|~~bqb)177d2hh&&$%MM&'jm#UMC,?BBB<>>"1"-

3X>rBHHJJL L L
	L %)!!!s   (, CC32C3c                     | j         r<| j        |                     |j        j                  k    s|j        dk    rdS d| _         t          t          |                               ||           dS )z7This function is called when a return trap is set here.r   NF)	_wait_for_mainpyfile
mainpyfilecanonicr   r   f_linenor@   r3   user_return)r   r   return_valuerL   s      r   r  zSpyderPdb.user_return{  sn     $ 	.4<<0H#I#III~**(-D%i**5,?????r   c                     	 	 d| _         |                                  d| _         dS # t          $ r t          d| j                   Y nw xY wL)zModifies the error text.TFzH--KeyboardInterrupt--
For copying text while debugging, use Ctrl+Shift+C)fileN)r   cmdloopr   r   rI   r%   s    r   r   zSpyderPdb._cmdloop  s|    	)
) %)!$)!$ ) ) ) L K) ) ) ) ) ))	)s   "'  A
	A
c                     |                                   ||| _        | j        r/| j                            t	          | j                  dz              d}|s| j        r| j                            d          }n.	 |                     | j                  }n# t          $ r d}Y nw xY w| 
                    |          }|                     |          }|                     ||          }||                                  dS )z
        Repeatedly issue a prompt, accept input, parse an initial prefix
        off the received input, and dispatch to action methods, passing them
        the remainder of the line as argument.
        Nrc   r   EOF)r  introrI   writestrcmdqueuer   	cmd_inputpromptEOFErrorprecmdr   postcmdr   )r   r   stopr   s       r   r  zSpyderPdb.cmdloop  s	    	DJ: 	4Kc$*ood2333 
	,} !}((++!>>$+66DD ! ! ! DDD!;;t$$D;;t$$D<<d++D  
	, 	s   ;B B%$B%rg   c                     t                      j        }|j                                        st	          |          S t
          j                                         t
          j                                         t
          j	                                         t
          j
                                         d _        |                                                    |           t          r't          j                    t          j                    u }n+t%          t          j                    t          j                  }|rl|j        re j        ^|j        }|r?t+          |d          r/t,          j        dk    r|j        j                                         n|r ||           nn j        ^ j        |j                             fd            j        S )z>
        Get input from frontend. Blocks until return
        Napp_wrapperntc                       j         d uS r   )rE   r%   s   r   <lambda>z%SpyderPdb.cmd_input.<locals>.<lambda>  s    ,D8 r   )r   r   frontend_commis_openr   r{   r   r   rI   
__stderr__
__stdout__rE   frontend_call	pdb_inputr   	threadingcurrent_threadmain_threadrr   _MainThread	eventlooprF   osnamer+  appupdate
wait_until)r   r%  r   is_main_threadr9  s   `    r   r$  zSpyderPdb.cmd_input  s    %#++-- 	!==  	

  $((000  	C(**i.C.E.EE N ((**I,AC CN  	f. 	&.",	  '&-"@"@ 4&*113333 If%%%% &. ' ++8888: : : ##r   c                 X    | j         s|S |s|S |d         dk    r|dd         }nd|z   }|S )z
        Hook method executed just before the command line is
        interpreted, but after the input prompt is generated and issued.

        Here we switch ! and non !
        r   rR   rQ   N)r<   )r   r   s     r   r'  zSpyderPdb.precmd  sK     , 	K 	K7c>>8DD:Dr   c                     t           j                                         t           j                                         |                                  t          t          |                               ||          S )z?Hook method executed just after a command dispatch is finished.)r{   r1  r   r2  r  r@   r3   r(  )r   r)  r   rL   s      r   r(  zSpyderPdb.postcmd  s_     	   Y%%--dD999r   c                    ddl m} |                     |j        j                  }	 t          |d          }n# t          $ r Y nw xY w|| j        vrdS |j        }|| j        |         vr|j        j	        }|| j        |         vrdS  ||||          \  }}|r>|j
        | _        |r.|j        r'|                     t          |j
                             dS dS )zy
            Breakpoints don't work for files with non-ascii chars in Python 2

            Fixes Issue 1484
            r   )	effectiveutf-8FT)bdbrC  r  r   r   unicode	TypeErrorbreaksr  co_firstlinenonumber	currentbp	temporarydo_clearr"  )r   r   rC  r   linenobpflags          r   
break_herezSpyderPdb.break_here  s    &%%%%%||EL$<==H"8W55   t{**u^FT[222 4X!666 5 #8VU;;JR !# 2R\ 2MM#bi..111tus   8 
AAc                 t   |                                   t          j        j        D ]}|r|                                 dt          j        _        i t          j        _        dgt          j        _        t          |                                          D ]I\  }}|D ]A\  }}	 | 	                    | 
                    |          ||           2# t          $ r Y >w xY wJ| j        rd| _        | j        }|sdS |j        }|                     |j        j                  }	| j        r| j        o|	o||	d         k     }
n| j        o|	o||	d         k     }
|
rf	 | j        rd}nd}t+          d                              |           dS # t.          t0          f$ r t2                              d	           Y dS w xY wdS dS )
zSet Spyder breakpoints.rQ   N)condFr   z	!continuecontinuer   z3Could not send a Pdb continue call to the frontend.)clear_all_breaksrE  
Breakpoint
bpbynumberdeleteMenextbplistlistitems	set_breakr  
ValueErrorr  rm   r  get_file_breaksr   r   r>   r9   r<   r   pdb_executer   r   r#   r$   )r   r  rO  fnamedata
linenumber	conditionr   rN  rH  do_continuecont_cmds               r   r  z SpyderPdb.set_spyder_breakpoints  sR   .+ 	 	B  "%)F! 1 1 3 344 	 	KE4)-  %
INN4<<#6#6
(1 # 3 3 3 3!    D	 = #	O!DM ME ^F))%,*BCCF
 ' 	>4 ++*  4 =#;&)(;<   	OO4 .#.#-$e444@@JJJJJ!<0 O O OLLMO O O O O OOC#	O #	O4	O 	Os$   !+C
CC/F +F32F3c                 z   | j         }|	d| _        dS |                     |j        j                  }t
          r"	 t          |d          }n# t          $ r Y nw xY w|| j        k    r| j	        | j	        }|j
        }| j        ||fk    rdS i }d| _        t          |t                    r/t          |t                    rt          ||          }||f| _        	 t          d                              t          |                     dS # t"          t$          f$ r t&                              d           Y dS w xY w)z
        Send debugger state (frame position) to the frontend.

        The state is only sent if it has changed since the last update.
        NrD  )ra  rN  Fr   )stepz)Could not send Pdb state to the frontend.)rm   rB   r  r   r   r   rF  rG  r  rD   r  rr   
basestringintdictr   	pdb_stater   r   r#   r$   )r   r   ra  rN  rh  s        r   r  zSpyderPdb.publish_pdb_stateW  sq    ="&DF U\566 	w//   DO##(<(H(E5&/11F "eZ(( 	2Z-D-D 	2eF333D#(&/D	Fe,,,66tGGGGG<( 	F 	F 	FLLDEEEEEE	Fs#   A 
AA1D +D:9D:c                     d| _         t          |           5  t          t          |                               |||           ddd           dS # 1 swxY w Y   dS )zDebug a statement executed via the exec() function.

        globals defaults to __main__.dict; locals defaults to globals.
        TN)r  r   r@   r3   run)r   r   r   r   rL   s       r   rn  zSpyderPdb.run}  s    
 $ 	= 	=)T""&&sGV<<<	= 	= 	= 	= 	= 	= 	= 	= 	= 	= 	= 	= 	= 	= 	= 	= 	= 	=   +AAAc                     d| _         t          |           5  t          t          |                               |||           ddd           dS # 1 swxY w Y   dS )zDebug an expression executed via the eval() function.

        globals defaults to __main__.dict; locals defaults to globals.
        TN)r  r   r@   r3   runeval)r   exprr   r   rL   s       r   rq  zSpyderPdb.runeval  s    
 $ 	B 	B)T""**4&AAA	B 	B 	B 	B 	B 	B 	B 	B 	B 	B 	B 	B 	B 	B 	B 	B 	B 	Bro  c                     d| _         t          |           5   t          t          |           j        |i | ddd           dS # 1 swxY w Y   dS )zWDebug a single function call.

        Return the result of the function call.
        TN)r  r   r@   r3   runcall)r   r   kwdsrL   s      r   rt  zSpyderPdb.runcall  s    
 $ 	: 	:*E)T""*D9D999	: 	: 	: 	: 	: 	: 	: 	: 	: 	: 	: 	: 	: 	: 	: 	: 	: 	:s   !AA
A
c                    t          j        d           | j        j        }| j        }t          | j        | j        | j                  }| j	        |_	        d| j
                                        z  |_
        |                    |           ||_        t          j        |j        |||f           t          j        | j                   |j        | _        | t%                      _        d| _        dS )z-
        Enter debugger recursively.
        N)rG   rH   rI   z(%s) )r{   r   rm   rn   r8   r3   rG   rH   rI   use_rawinputr%  r   set_remote_filenamer9   call_tracingrn  trace_dispatchry   r   r  rB   )r   r   r   r9   r   r   debuggers          r   enter_recursive_debuggerz"SpyderPdb.enter_recursive_debugger  s    
 	T-)%(*T[2 2 2 !% 1!DK$5$5$7$77$$X.../J, 	gv'>???T()))'$(! #r   c                 V    || _         |                     |          | _        d| _        dS )z3Set remote filename to signal Spyder on mainpyfile.TN)rD   r  r  r  )r   r   s     r   rx  zSpyderPdb.set_remote_filename  s+    ',,x00$(!!!r   )r4   NNNF)r   Nr   )rg   )NN)(r-   r.   r/   r0   r  r  r   rO   r   r   r   r   r   r   do_wdo_btr   r   r   r   r  r  r  r  r  r   r  r$  r'  r(  r   rQ  r  r  rn  rq  rt  r|  rx  __classcell__)rL   s   @r   r3   r3   D   s         !%H=A%*'5 '5 '5 '5 '5 '5T5 5 5gL gL gLT( ( (  . =D"&2 2 2 2 2 2    $J J J J J DE< < <Y  Y  Y vS S Sl# # #) ) ) ) )"4 4 4) ) ) ) )) ) ) ) ).	@ 	@ 	@ 	@ 	@) ) )    2/$ /$ /$ /$b  ": : : : :  	 	 	B:O :O :Ox$F $F $FL= = = = = =B B B B B B: : : : :# # #>) ) ) ) ) ) )r   r3   c                 Z    t                      }|                    |            ||_        |S )zGet a new debugger.)r3   rx  r9   )r   r9   r{  s      r   get_new_debuggerr    s,    {{H  ***+FH(Or   )-r0   rt   rE  loggingr:  r{   r   r5  collectionsr   IPython.core.autocallr   IPython.core.debuggerr   ipyPdbIPython.core.getipythonr   !spyder_kernels.comms.frontendcommr   r   spyder_kernels.customize.utilsr	   r
   spyder_kernels.py3compatr   r   r   r   r   r   IPython.core.inputtransformer2r   rp   r"  ri  __builtin__IPython.core.inputsplitterr   	getLoggerr-   r#   objectr   r3   r  r1   r   r   <module>r     s     



 



  				 



         " " " " " " 1 1 1 1 1 1 / / / / / / / / / / / / I I I I I I I I M M M M M M M M9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9  VAAAAAAOOOJJ""""UUUUUU 
	8	$	$L L L L L6 L L L8w) w) w) w) w) w) w) w)t    r   