
   SPaĽU>                      S SK r \S:X  a  \ R                  S   \ R                  S'    S SK7  \ R                  S:X  a  S S	K	J
r
  \
" 5         S S
KJr  S SKJr  S SKrS SKrS SKrS SKrS SKJr  S SKrS SKrS SKrS SKJr  S SKrS SKrS SKrS SKrS SKJr  S SKJr  S SK J!r!  S SK"J#r#  S SK"J$r$  S SK%J&r&J'r'  S SK(J)r)  S SK*J+r+  S SK"J,r,  S SK"J-r-  S SK.J/r/J0r0J1r1  S SK2J3r3  Sq4Sr5S r6 Sr7\7\8l7        \7\9l7        \ R                  q; S5S jr<Sq=S r>\>" S5        S\R~                  4S  jr@\@\l?         " S! S"\&5      rA " S# S$\)5      rB " S% S&\5      rC " S' S(\35      rD " S) S*\!5      rE " S+ S,\-R                  5      rGS- rH " S. S/\5      rI " S0 S1\+5      rJS2 rKS3rLS4 rM\S:X  a  \M" 5         \>" S5        g! \ a    \" S\ R                  S9  \" S5      ef = f! \: a     Nf = f)6    N__main__zidlelib.pyshell)*zJ** IDLE can't import Tkinter.
Your Python may not be configured for Tk. **file   win32)fix_win_hidpi)
messagebox)InteractiveInterpreter)python_version)TextWrapper)ColorDelegator)idleConf)	Delegatordebugger)
debugger_r)EditorWindowfixwordbreaks)FileList)OutputWindow)replace)rpc)idle_formatwarningStdInputFileStdOutputFile)UndoDelegatorFz	127.0.0.1zCtrl-D (end-of-file)c           
          Uc  [         n UR                  [        XX#US95        UR                  S5        g! [        [        4 a     gf = f)zShow Idle-format warning (after replacing warnings.showwarning).

The differences are the formatter called, the file=None replacement,
which can be None, the capture of the consequence AttributeError,
and the output of a hard-coded prompt.
N)linez>>> )warning_streamwriter   AttributeErrorOSError)messagecategoryfilenamelinenor   r   s         &/usr/lib/python3.13/idlelib/pyshell.pyidle_showwarningr)   C   sS     |

%8$@ 	A

6G$ s   +7 A
	A
c                     U (       a(  [         c   [        R                  q [        [        l        gg[         b  [         [        l        Sq gg)z>Replace warning.showwarning with idle_showwarning, or reverse.N)_warnings_showwarningwarningsshowwarningr)   )captures    r(   capture_warningsr/   V   sA      ($,$8$8!#3H  ) !,#8H $(! -    Tc                     [         R                  n0 n[        U5       H'  nUSS USS -   S:X  d  M  UR                  U5      X4'   M)     U" U 5        UR	                  U5        g)aW  Extend linecache.checkcache to preserve the <pyshell#...> entries

Rather than repeating the linecache code, patch it to save the
<pyshell#...> entries, call the original linecache.checkcache()
(skipping them), and then restore the saved entries.

orig_checkcache is bound at definition time to the original
method, allowing it to be patched.
Nr   <>)	linecachecachelistpopupdate)r&   orig_checkcacher5   savekeys        r(   extended_linecache_checkcacher<   e   s^     OOEDE{r7SX%		#DI  H	LLr0   c                   n    \ rS rSrSrS r/ SQrSS jrS rSS jr	SS	 jr
S
 rS rS rS rS rS rSrg)PyShellEditorWindow|   z6Regular text edit window in IDLE, supports breakpointsc                    / U l         [        R                  " U /UQ76   U R                  R	                  SU R
                  5        U R                  R	                  SU R                  5        U R                  R	                  SU R                  R                  5        [        R                  R                  [        R                  S5      U l        U R                  R                   U 4S jnU R                  R#                  U5        U R                  R$                  (       a  U R'                  5         U R)                  5         g )N<<set-breakpoint>><<clear-breakpoint>>z<<open-python-shell>>zbreakpoints.lstc                 2    UR                  5         U " 5         g N)restore_file_breaks)old_hookselfs     r(   filename_changed_hook;PyShellEditorWindow.__init__.<locals>.filename_changed_hook   s    $$&Jr0   )breakpointsr   __init__textbindset_breakpoint_eventclear_breakpoint_eventflist
open_shellospathjoinr   userdirbreakpointPathiofilename_change_hookset_filename_change_hookr&   rE   color_breakpoint_text)rG   argsrH   s      r(   rK   PyShellEditorWindow.__init__   s    d*T*		+T-F-FG		-t/J/JK		.

0E0EF !ggll  "35 ,077+G+G'+	 	(()>?77$$&""$r0   ))Cutz<<cut>>rmenu_check_cut)Copyz<<copy>>rmenu_check_copy)Pastez	<<paste>>rmenu_check_paste)NNN)zSet BreakpointrA   N)zClear BreakpointrB   Nc                     U R                   c  gU(       a-  [        R                  " 5       n[        R                  " US5      nOSSS.nU R                  R                  SU5        g)z,Turn colorizing of breakpoint text on or offNbreak )
foreground
backgroundBREAK)rW   r   CurrentThemeGetHighlightrL   
tag_config)rG   colorthemecfgs       r(   rZ   )PyShellEditorWindow.color_breakpoint_text   sO    77?))+E''w7C!#26C		Wc*r0   c                    U R                   nU R                  R                  nUR                  SSU-  SUS-   -  5         U R                  R                  U5         U R                  R                  R                  R                  nUR                  X15        g ! [         a    U R                  R                  U5         Ndf = f!    g = f)Nrh   z%d.0r   )rL   rW   r&   tag_addrJ   index
ValueErrorappendrP   pyshellinterpr   set_breakpoint)rG   r'   rL   r&   debugs        r(   rw   "PyShellEditorWindow.set_breakpoint   s    yy77##Wfvov/BC	,""6*	JJ&&--66E  2	  	,##F+	,
	s    B ;C %C ?C CNc                     U R                   nU R                  R                  nU(       d  UR                  5         g [	        [        UR                  S5      5      5      nU R                  U5        g )Ninsert)rL   rW   r&   bellintfloatrr   rw   )rG   eventrL   r&   r'   s        r(   rN   (PyShellEditorWindow.set_breakpoint_event   sO    yy77##IIKU4::h/01F#r0   c                    U R                   nU R                  R                  nU(       d  UR                  5         g [	        [        UR                  S5      5      5      n U R                  R                  U5        UR                  SSS5         U R                  R                  R                  R                  nUR                  X45        g !    NT= f!    g = f)Nr{   rh   insert linestartzinsert lineend +1char)rL   rW   r&   r|   r}   r~   rr   rJ   remove
tag_removerP   ru   rv   r   clear_breakpoint)rG   r   rL   r&   r'   rx   s         r(   rO   *PyShellEditorWindow.clear_breakpoint_event   s    yy77##IIKU4::h/01	##F+ 	!3/	1	JJ&&--66E""84		s   C
 ;C 
CCc                 ^   U R                   (       a  U R                  nU R                  R                  nU(       d  UR	                  5         g / U l         UR                  SS[        5         U R                  R                  R                  R                  nUR                  U5        g g !    g = f)Nrh   1.0)rJ   rL   rW   r&   r|   r   ENDrP   ru   rv   r   clear_file_breaks)rG   rL   r&   rx   s       r(   r   %PyShellEditorWindow.clear_file_breaks   s    99Dww''H		!DOOGUC0

**11::''1 s   +;B( (B,c                 .   U R                   nU R                  R                  n [        U R                  5       nUR                  5       nSSS5         [        U R                  S5       nW H/  nUR                  US-   5      (       a  M  UR                  U5        M1     U R                  5         U R                   nU(       a#  UR                  US-   [        U5      -   S-   5        SSS5        g! , (       d  f       N= f! [         a    / n Nf = f! , (       d  f       g= f! [         ah  n[        U R                  SS5      (       dB  SU R                  l        [        R                  " SS	[        U5      -  U R                   S
9   SnAg SnAgSnAff = f)z#Save breakpoints when file is savedNw=
breakpoint_error_displayedFTz
IDLE Errorz$Unable to update breakpoint list:
%s)titler$   parent)rJ   rW   r&   openrV   	readlinesr#   
startswithr!   update_breakpointsstrgetattrrootr   r
   	showerrorrL   )rG   breaksr&   fplinesnew_filer   errs           r(   store_file_breaks%PyShellEditorWindow.store_file_breaks   sG   $ !!77##	d))*b +	&d))3/8!D??8c>:: t, " '')))NN8c>CK#?$#FG 0/ +* 	E	 0/  	&499&BEJJ7;		4$$<Cc(#99& K	&sl   C? C.
C? D" )D
AD%D" .
C<8C? <C? ?DD
DD" D" "
F,AFFc                    U R                   R                  5         U R                  c  g U R                  R                  nUc  g [        R
                  R                  U R                  5      (       a  [        U R                  5       nUR                  5       nS S S 5        W HR  nUR                  US-   5      (       d  M  [        U[        U5      S-   S  5      nU H  nU R                  U5        M     MT     g g ! , (       d  f       Nh= f)Nr   r   )rL   r8   rW   r&   rR   rS   isfilerV   r   r   r   evallenrw   )rG   r&   r   r   r   breakpoint_linenumbersbreakpoint_linenumbers          r(   rE   'PyShellEditorWindow.restore_file_breaks  s    		77?77##77>>$--..d))*b +??8c>22-1$s8}Q7G2H-I*1G-++,AB 2H  /**s   C99
Dc                 l    U R                   nUR                  S5      nU R                  U5      nX0l        g)z3Retrieves all the breakpoints in the current windowrh   N)rL   
tag_rangesranges_to_linenumbersrJ   )rG   rL   rangeslinenumber_lists       r(   r   &PyShellEditorWindow.update_breakpoints  s/    yy)44V<*r0   c                    / n[        S[        U5      S5       Hj  n[        [        X   R                  5      5      n[        [        XS-      R                  5      5      nXE:  d  MM  UR                  U5        US-  nXE:  a  M  Ml     U$ )Nr      r   )ranger   r}   r~   stringrt   )rG   r   r   rr   r'   ends         r(   r   )PyShellEditorWindow.ranges_to_linenumbers#  sx    1c&k1-Ev}3345FeF7O2234C,V$! , . r0   c                 P    U R                  5         [        R                  " U 5        g)z7Extend base method - clear breaks when module is closedN)r   r   _closerG   s    r(   r   PyShellEditorWindow._close4  s     D!r0   )rV   rJ   )TrD   )__name__
__module____qualname____firstlineno____doc__rK   rmenu_specsrZ   rw   rN   rO   r   r   rE   r   r   r   __static_attributes__ r0   r(   r>   r>   |   sE    <%(K
+$&(&TC"+""r0   r>   c                   *    \ rS rSrSr\rSrSS jrSr	g)PyShellFileListi:  z8Extend base class: IDLE supports a shell and breakpointsNc                    U R                   (       a0  U R                   R                  R                  5         U R                   $ [        U 5      U l         U R                   (       a   U R                   R	                  5       (       d  g U R                   $ rD   )ru   topwakeupPyShellbeginrG   r   s     r(   rQ   PyShellFileList.open_shellC  s_    <<LL##% ||	 #4=DL||||))++||r0   )ru   rD   )
r   r   r   r   r   r>   r   ru   rQ   r   r   r0   r(   r   r   :  s    > 'LGr0   r   c                   $    \ rS rSrSrS rS rSrg)ModifiedColorDelegatoriN  z8Extend base class: colorizer for the shell window itselfc                 |    U R                  SSS5        U R                  SSS5        [        R                  " U 5        g )NTODOr   iomarkSYNC)r   rq   r   recolorize_mainr   s    r(   r   &ModifiedColorDelegator.recolorize_mainP  s0    x0VUH-&&t,r0   c                 P    U R                    H  nU R                  USS5        M     g )Nr   r   )tagdefsr   )rG   tags     r(   removecolors#ModifiedColorDelegator.removecolorsU  s     <<COOC51  r0   r   N)r   r   r   r   r   r   r   r   r   r0   r(   r   r   N  s    >-
2r0   r   c                   @   ^  \ rS rSrSrSS jrSS jrU 4S jrSrU =r	$ )ModifiedUndoDelegatori[  z;Extend base class: forbid insert/delete before the I/O markc                      U R                   R                  USS5      (       a  U R                   R                  5         g  [        R
                  " XX#5        g ! [         a     N$f = fN<r   )delegatecomparer|   TclErrorr   r{   rG   rr   charstagss       r(   r{   ModifiedUndoDelegator.insert]  s^    	}}$$UC::""$ ;
 	T%6  		   <A 
A%$A%c                      U R                   R                  USS5      (       a  U R                   R                  5         g  [        R
                  " XU5        g ! [         a     N$f = fr   )r   r   r|   r   r   delete)rG   index1index2s      r(   r   ModifiedUndoDelegator.deletef  s^    	}}$$VS(;;""$ <
 	T62  		r   c                    >^ U R                   R                  mU4S jU R                   l         [        TU ]  U5        TU R                   l        g ! TU R                   l        f = f)Nc                    > T" XS5      $ Nstdinr   )rr   r   orig_inserts     r(   <lambda>2ModifiedUndoDelegator.undo_event.<locals>.<lambda>v  s    U7!Cr0   )r   r{   super
undo_event)rG   r   r   	__class__s     @r(   r    ModifiedUndoDelegator.undo_evento  sN    
 mm**C 		/Gu%#.DMM ;DMM s   A A#r   rD   )
r   r   r   r   r   r{   r   r   r   __classcell__r   s   @r(   r   r   [  s    A73/ /r0   r   c                   "    \ rS rSrSrSS jrSrg)UserInputTaggingDelegatori}  z.Delegator used to tag user input with "stdin".Nc                 F    Uc  SnU R                   R                  XU5        g r   )r   r{   r   s       r(   r{    UserInputTaggingDelegator.insert  s     <DU40r0   r   rD   )r   r   r   r   r   r{   r   r   r0   r(   r   r   }  s
    81r0   r   c                       \ rS rSrS rSrg)MyRPCClienti  c                     [         e)z0Override the base class - just re-raise EOFError)EOFErrorr   s    r(   
handle_EOFMyRPCClient.handle_EOF  s    r0   r   N)r   r   r   r   r   r   r   r0   r(   r   r     s    r0   r   c                     SU=(       d    S S3nU [        U5      :  a*  [        U [        U5      -
  S5      u  p4X4-   S-   U US-   3$ USS $ )zReturn width long restart line formatted with filename.

Fill line with balanced '='s, with any extras and at least one at
the beginning.  Do not end with a trailing space.
z= RESTART: Shellz =r   r   N)r   divmod)widthr&   r   divmods        r(   restart_liner    sb     +G,B
/CC5#c(?Q/7C-c#gY//3Bxr0   c                       \ rS rSrS rSrSrSrS rS r	S r
S"S jrS rS	 rS
 rS rS#S jrSrS rSrS rS rS rS rSrS rS$S jrS rS rS rS$S jrS rS r S r!S r"S r#S r$S r%S  r&S!r'g)%ModifiedInterpreteri  c                     Xl         [        R                  S   R                  n[        R
                  " XS9  SU l        S U l        [        U l	        U R                  R                  R                  U l        g )Nr   )localsF)	tkconsolesysmodules__dict__r   rK   
restartingsubprocess_arglistPORTportcompilecompilerflagsoriginal_compiler_flags)rG   r  r  s      r(   rK   ModifiedInterpreter.__init__  sW    "Z(11''<"&	'+||'<'<'B'B$r0   Nc                     U R                   c  U R                  5       U l         [        [        R                  SS9n[
        R                  " U R                   US9U l        g )Ndumb)TERM)env)r  build_subprocess_arglistdictrR   environ
subprocessPopen
rpcsubproc)rG   r  s     r(   spawn_subprocess$ModifiedInterpreter.spawn_subprocess  sI    ""*&*&C&C&ED#2::F+$**4+B+BLr0   c                    U R                   S:w  d   S5       e[        R                   Vs/ s H  nSU-   PM
     nn[        R                  " SSSSSS	9nS
U< S3n[        R
                  /U-   SU[        U R                   5      /-   $ s  snf )Nr   z/Socket should have been assigned a port number.z-WmainGeneralzdelete-exitfuncFbool)defaulttypez#__import__('idlelib.run').run.main()-c)r  r  warnoptionsr   	GetOption
executabler   )rG   sr   	del_exitfcommands        r(   r  ,ModifiedInterpreter.build_subprocess_arglist  s    		1 	?=	?"/!TAX/ &&vy:K/46C	7	}AF!#tWc$))n&EEE 0s   Bc                 J   [         U R                  4n[        S5       H*  n[        R                  " U5         [        U5      U l          O   U R                  5         g U R                  R                  R                  5       S   U l        [        S:w  aC  U R                  R                  R                  [        R                  [        R                  S5        U R!                  5         U R                  R                  R#                  S5         U R                  R%                  5         U R                  R+                  SU R,                  5        U R                  R+                  SU R,                  R.                  5        U R                  R+                  SU R,                  R0                  5        U R                  R+                  SU R,                  R2                  5        U R                  R+                  S	U R,                  R4                  5        U R                  R+                  S
[6        5        U R                  R+                  SU 5        U R9                  SS9  U R;                  5         U R                  $ ! [         a     GMc  f = f! [&         a    U R)                  5          g f = f)N   r   r   
   consoler   stdoutstderrrP   r4   rv   Twith_cwd)HOSTr  r   timesleepr   rpccltr#   display_port_binding_errorlistening_sockgetsocknamer  
setsockoptsocket
SOL_SOCKETSO_REUSEADDRr#  
settimeoutacceptTimeoutErrordisplay_no_subprocess_errorregisterr  r   r8  r9  rP   r4   transfer_pathpoll_subprocess)rG   addris      r(   start_subprocess$ModifiedInterpreter.start_subprocess  s   dii qAJJqM)$/	  ++-KK..::<Q?	19
 KK&&11&2C2C+1+>+>C 	""--b1	KK  	Y7Wdnn&:&:;Xt~~'<'<=Xt~~'<'<=Wdnn&:&:;[)4Xt,D){{C  *  	,,.	s#   I3J 3
JJJ"!J"c                 P   U R                   (       a  U R                  $ SU l         U R                  5       nU(       a!   [        R                  " U R                  5        U R                  R                  5         U R                  5         U R                  nUR                  nSUl        U R                  5          U R                  R                  5         U R                  US9  UR                  5         UR                  R!                  SS5        UR#                  S5        UR#                  [%        UR&                  U5      5        UR                  R)                  SS5        UR                  R+                  SS5        U(       d  UR-                  5         U(       a0  [        R.                  " U R                  5        UR1                  5         U R2                  U R4                  R6                  l        SU l         U R                  $ !    GN= f! [         a    U R                  5          g f = f)	NTFr:  r   end-1cr   restartleft)r  r?  getdebuggerr   close_subprocess_debuggercloseterminate_subprocessr  	executingr#  rH  rI  rJ  rL  stop_readlinerL   r   r!   r  r  mark_setmark_gravity
showpromptrestart_subprocess_debuggerload_breakpointsr  r  r  r  )rG   r;  r&   rx   r7  was_executings         r(   restart_subprocess&ModifiedInterpreter.restart_subprocess  s   ??;;  "44T[[A 	!!#..))!	KK  	H-Hh/dl7==(;<i2!!)V4 224;;?""$&*&B&B#{{A  	,,.	s    H  7H  HH%$H%c                 @    U R                   R                  SSS0 5        g )Nexecinterrupt_the_serverr   )r?  
remotecallr   s    r(   __request_interrupt'ModifiedInterpreter.__request_interrupt  s    v'=r2Fr0   c                 \    [         R                  " U R                  S9R                  5         g )N)target)	threadingThread'_ModifiedInterpreter__request_interruptstartr   s    r(   interrupt_subprocess(ModifiedInterpreter.interrupt_subprocess  s     8 89??Ar0   c                    U R                   b/  U R                  R                  R                  U R                   5         U R                  R
                  R                  5          U R                  R                  5         U R                  5         SU R                  l	        S U l        g ! [         a     NPf = f! [         a     NEf = f)NF)
_afteridr  rL   after_cancelr?  rA  rX  r"   rY  rZ  r   s    r(   kill_subprocess#ModifiedInterpreter.kill_subprocess  s    ==$NN,,T]];	KK&&,,.	KK 	!!##(   		  		s#   $B& #B6 &
B32B36
CCc                      U R                   R                  5          U R                   R                  5         g! [         a     gf = f! [         a     gf = f)z"Make sure subprocess is terminatedN)r"  killwaitr#   r   s    r(   rY  (ModifiedInterpreter.terminate_subprocess'  sQ    		OO  "
$$&   		s    A 8 
AA
AAc                     U(       a#  S/nUR                  [        R                  5        O[        R                  nU R                  SR	                  U5      5        g )Nre   zTif 1:
        import sys as _sys
        _sys.path = {!r}
        del _sys
        
)extendr  rS   
runcommandformat)rG   r;  rS   s      r(   rL  !ModifiedInterpreter.transfer_path4  sA    4DKK!88D  fTl		r0   c                    U R                   nUc  g  UR                  U R                  SS9nU(       a  U R                  R                  5         S U l        Uu  p4U R                  R                  nUS:X  a  Ub  [        [        U5      US9  OaUS:X  a1  U R                  R                  S5      (       a  U R                  5         O*US:X  a$  Sn[        Xd[        R                   S9  [        XdUS9   U R                  R#                  5         U R                  R                  (       dJ  U R                  R&                  R)                  U R                  R*                  U R,                  5      U l        g g ! [        [        [
        4 a3    U R                  R                  (       a   g S nU R                  5          GNf = f! [$         a     Nf = f)	Ng?)ry  OKr   	EXCEPTION<<toggle-jit-stack-viewer>>ERRORz/pyshell.ModifiedInterpreter: Subprocess ERROR:
)r?  pollresponse
active_seqr   r#   KeyboardInterruptr  closingrb  resetoutputr7  printreprgetvarremote_stack_viewerr  
__stderr__endexecutingr"   rL   afterpollintervalrM  rs  )rG   cltresponsehowwhatr7  errmsgs          r(   rM  #ModifiedInterpreter.poll_subprocessC  sx   kk;	&''d'CH NN&&("DO ICnn,,Gd{#$t*73#>>(()FGG,,.Kf8f1++- ~~%% NN//55++T-A-ACDM &9 '#45 	& ~~%%H##%	&2 " s)   E- -F8 -0F5F54F58
GGc                     Xl         g rD   r   )rG   r   s     r(   setdebuggerModifiedInterpreter.setdebuggerk  s     r0   c                     U R                   $ rD   r   r   s    r(   rV  ModifiedInterpreter.getdebuggern  s    }}r0   c                 d    U R                   R                  R                  SU R                  5        g)ab  Initiate the remote stack viewer from a separate thread.

This method is called from the subprocess, and by returning from this
method we allow the subprocess to unblock.  After a bit the shell
requests the subprocess to open the remote stack viewer which returns a
static object looking at the last exception.  It is queried through
the RPC mechanism.

i,  N)r  rL   r  r  r   s    r(   open_remote_stack_viewer,ModifiedInterpreter.open_remote_stack_viewerq  s'     	!!#t'?'?@r0   c                 
   SSK Jn  U R                  R                  SSS0 5      nUc%  U R                  R
                  R                  5         g UR                  U R                  U5      nSSKJ	nJ
n  [        U R                  R
                  5      n[        R                  " 5       n[        R                  " US5      S   nU" XhSS	9n	U	R                  R!                  S
SS9  U" U	R"                  S U5      n
U
R%                  5         g )Nr   )
debugobj_rre  stackviewer)rP   )ScrolledCanvasTreeNodenormalrg   )bghighlightthicknessr   both)expandfill)idlelibr  r?  remotequeuer  r   r|   StubObjectTreeItemidlelib.treer  r  Toplevelr   ri   rj   framepackcanvasr  )rG   r  oiditemr  r  r   rm   rg   scnodes              r(   r  'ModifiedInterpreter.remote_stack_viewer~  s    &kk%%fmZL;NN$$&,,T[[#>9t~~**+%%'**5(;LI
C1E
QV,		4.r0   r   c                 H    U R                  U5      nU R                  X!5        g)z1Like runsource() but assumes complete exec sourceN)stuffsourceexecfilerG   sourcer&   s      r(   
execsourceModifiedInterpreter.execsource  s    ##F+h'r0   c                 *   Ucc  [         R                  " U5       nUR                  5       n[        (       a)  S[        R
                  R                  U5       S3U-   S-   nSSS5         [        X!S5      nU R                  U5        g! , (       d  f       N-= f! [        [        4 ak    U R                  R                  5         [        SU R                  R                  S9  [        R                   " X5        U R                  R#                  5          gf = f)zExecute an existing fileNz__file__ = r'''z'''
z
del __file__re  zB*** Error in script or command!
Traceback (most recent call last):r   )tokenizer   readuse_subprocessrR   rS   abspathr  runcodeOverflowErrorSyntaxErrorr  r  r  r9  r   showsyntaxerrorr^  )rG   r&   r  r   codes        r(   r  ModifiedInterpreter.execfile  s    >x(B!> /0I/J%P &')9:F )

	6V4D LL )( {+ 	(NN&&( 6~~,,. #224BNN%%'	(s   AB(B 
BA8DDc                     U R                  U5      n[        U[        5      (       d   e[        R                  " XU5      $ )zBExtend base class method: Stuff the source in the line cache first)r  
isinstancer   r   	runsourcer  s      r(   r  ModifiedInterpreter.runsource  s:    ##F+&#&&&& &//hGGr0   c                     SU R                   -  nU R                   S-   U l         UR                  S5      n[        U5      S-   SX24[        R                  U'   U$ )z"Stuff source in the filename cachez<pyshell#%d>r   r   r   )gidsplitr   r4   r5   )rG   r  r&   r   s       r(   r  ModifiedInterpreter.stuffsource  sO    !DHH,88a<T"$'KM1e$E	!r0   c                 D    U R                  SR                  U5      5        g)z>Prepend sys.path with file's directory if not already includeda*  if 1:
            _filename = {!r}
            import sys as _sys
            from os.path import dirname as _dirname
            _dir = _dirname(_filename)
            if not _dir in _sys.path:
                _sys.path.insert(0, _dir)
            del _filename, _sys, _dirname, _dir
            
N)r}  r~  rG   r&   s     r(   prepend_syspath#ModifiedInterpreter.prepend_syspath  s      &"	$r0   c                    U R                   nUR                  nUR                  SSS5        [        R                  " 5       u  pVn[        USS5      =(       d    U=(       d    Sn[        USS5      =(       d    Sn	[        US	S5      =(       d    S
n
U
S
:X  a  U	S-  n	U	S:X  a	  SU
S-
  -  nOSU	S-
  U
S-
  4-  nUR                  XK5        UR                  5         U R                  SU-  5        UR                  5         g)zOverride Interactive Interpreter method: Use Colorizing

Color the offending position instead of printing it and pointing at it
with a caret.

r  r   r   msgre   z<no detail available>r'   r   offsetr   ziomark + %d charsz&iomark linestart + %d lines + %d charszSyntaxError: %s
N)
r  rL   r   r  exc_infor   colorize_syntax_errorr  r!   r^  )rG   r&   kwargsr  rL   r*  valuetbr  r'   r  poss               r(   r  #ModifiedInterpreter.showsyntaxerror  s     NN	~~.,,.ReUB'K5K4K"-2"-2Q;aKFQ;%2C:!8VAX&'C''2

&,-r0   c                     U R                   R                  5         U R                  5         [        R                  " U 5        U R                   R                  S5      (       a  U R                   R                  5         gg)z1Extend base class method to reset output properlyr  N)r  r  checklinecacher   showtracebackr  open_stack_viewerr   s    r(   r  !ModifiedInterpreter.showtraceback  sX    ""$,,T2>>  !>??NN,,. @r0   c                 n    [         R                  n[        U5       H  nUSS USS -   S:w  d  M  X	 M     g)z%Remove keys other than '<pyshell#n>'.Nr   r2   r3   )r4   r5   r6   )rG   r5   r;   s      r(   r  "ModifiedInterpreter.checklinecache  s7    ;C2AwRS!T)J r0   c                     U R                   R                  (       a  U R                  5         gU R                  (       a   U R                  R	                  SSU40 5        g[        XR                  5        g)z*Run the code without invoking the debuggerr   re  r  r   )r  rZ  display_executing_dialogr?  r  re  r  )rG   r  s     r(   r}  ModifiedInterpreter.runcommand  sW     >>##))+;;KK##FIwC  {{#r0   c                    U R                   R                  (       a  U R                  5         U R                  5         U R                  n U R                   R                  5         U(       d2  U R                  b%  U R                  R                  SSU40 5      U l        O:U(       a  UR                  " XR                  5        O[        XR                  5         [$        (       d   U R                   R+                  5         gg! [         a`    U R                   R                  (       dC  [        R                  " SSSU R                   R                   S9(       a  e U R#                  5          Ne   [$        (       aJ  ['        SU R                   R(                  S	9  U R#                  5         U R                   R+                  5          NU R                   R,                  (       a2  S
U R                   l        ['        SU R                   R(                  S	9   GN4U R#                  5          GNG= f! [.         a     gf = f! [$        (       d,   U R                   R+                  5         f ! [.         a     f f = ff = f)Override base class methodNre  r  zExit?zDo you want to exit altogether?yesr)  r   z IDLE internal error in runcode()r   Fr  )r  rZ  rb  r  r   beginexecutingr?  
asyncqueuer  runr  re  
SystemExitr  r
   askyesnorL   r  r  r  r9  r  canceledr"   )rG   r  r   s      r(   r  ModifiedInterpreter.runcode  s   >>####%==&	NN))+ 7"&++"8"89=#ET;;/T;;'4 ">NN//1 "3  	>>))&&5!>>..	0
 &&(	)~8>>002""$++->>**.3DNN+-DNN4I4IJ&&(
 &  ">NN//1%  "s   	AC> H0 #C> ?H0  C> H0 "H  >A&H$H0 &AH;H0 =A
HH0 
HH0  
H-,H-0I)=II)
I%"I)$I%%I)c                 L    U R                   R                  R                  U5      $ )r  )r  r9  r!   )rG   r0  s     r(   r!   ModifiedInterpreter.write*  s    ~~$$**1--r0   c                 X    [         R                  " SSU R                  R                  S9  g )NzPort Binding ErroraA  IDLE can't bind to a TCP/IP port, which is necessary to communicate with its Python execution server.  This might be because no networking is installed on this computer.  Run IDLE with the -n command line switch to start without a subprocess and refer to Help/IDLE Help 'Running without a subprocess' for further details.r   r
   r   r  rL   r   s    r(   r@  .ModifiedInterpreter.display_port_binding_error.  s'     / >>&&	(r0   c                 X    [         R                  " SSU R                  R                  S9  g )NzSubprocess Connection ErrorzIDLE's subprocess didn't make connection.
See the 'Startup failure' section of the IDLE doc, online at
https://docs.python.org/3/library/idle.html#startup-failurer  r  r   s    r(   rJ  /ModifiedInterpreter.display_no_subprocess_error9  s(    )J >>&&	(r0   c                 X    [         R                  " SSU R                  R                  S9  g )NzAlready executingzYThe Python Shell window is already executing a command; please wait until it is finished.r  r  r   s    r(   r  ,ModifiedInterpreter.display_executing_dialogA  s%    0>>&&		(r0   )rs  r  r   r  r  r  r  r?  r"  r  r  )Fre   )FrD   )(r   r   r   r   rK   rs  r?  r"  r#  r  rP  rb  rn  rp  ru  rY  rL  r  rM  r   r  rV  r  r  r  r  r  r  r  r  r  r  r  r}  r  r!   r@  rJ  r  r   r   r0   r(   r	  r	    s    C HFJM
F)V*XGB J$CL H!" C(
(H
$4/
,\.	(((r0   r	  c            	       t  ^  \ rS rSrSSKJr  S\" 5       -   r\r	\
r/ SQr\R                  S/-   rS\" \" \R$                  " S \5      5      5      -   r\R)                  \S	5        CS
rSrSSKJr  SSKJr  S;S jrU 4S jrU 4S jrS rS rS r S;S jr!S
r"S
r#S
r$S
r%S
r&S
r'S r(S r)S;S jr*S r+S;S jr,S r-S r.S r/S r0S r1S r2S  r3S! r4S" r5S#r6S$ r7S% r8S& r9S' r:S;S( jr;S) r<S* r=S+ r>S, r?\@R                  " S-5      rBS. rCS;S/ jrDS;S0 jrES;S1 jrFS2 rGS3 rHS4 rIS<S5 jrJU 4S6 jrKU 4S7 jrLS;S8 jrMS9 rNS:rOU =rP$ )=r   iI  r   )SqueezerzIDLE Shell ))r   _File)edit_Edit)rx   _Debug)options_Options)window_Window)help_Help)Squeeze<<squeeze-current-text>>r   c                     U S   S:g  $ )Nr   r_   r   )
rmenu_items    r(   r   PyShell.<lambda>a  s    :a=F2r0   )zCopy with prompts<<copy-with-prompts>>r`   Fr   )History)ShellSidebarc                 	   U R                   nUS   S   S:w  a  UR                  SS5        [        U 5      U l        Uc0  [	        5       n[        U5        UR                  5         [        U5      nS U l        [        R                  " XS S 5        SU l        SU l        [        [        S5      (       a  [        R                  OSU l        U R                   R#                  S	5      S
   U l        U R                   U l        U R(                  nUR+                  SS9  UR-                  SU R.                  5        UR-                  SU R0                  5        UR-                  SU R2                  5        UR-                  SU R4                  5        UR-                  SU R6                  5        UR-                  SU R8                  5        UR-                  SU R:                  5        UR-                  SU R<                  5        [>        (       a8  UR-                  SU R@                  5        UR-                  SU RB                  5        U RE                  U 5      U l#        UR-                  SU RH                  5        [        RJ                  U l&        [        RN                  U l(        [        RR                  U l*        SSK+J,n  [[        U SUR\                  UR^                  5      U l)        [a        U SUR\                  UR^                  5      U l%        [a        U SUR\                  S5      U l'        [a        U SUR\                  UR^                  5      U l1        [>        (       d?  U RJ                  [        l%        U RN                  [        l'        U RR                  [        l)         SS K2nURf                  Ul4        U Rm                  U R(                  5      U l7        SU l8        U Rs                  U 5      U l        U Rt                  Rv                  R                  U R(                  l        U Rt                  Ry                  [{        5       5        [>        (       d'  U R}                  SSS5        U R}                  SS S5        g g !   [        Rj                  [        l'        e = f)!Nr   r   shell)r  She_llF   ps1z>>>
r   r2   char)wrapz<<newline-and-indent>>z<<plain-newline-and-indent>>z<<interrupt-execution>>z<<end-of-file>>z<<open-stack-viewer>><<toggle-debugger>>r  r  z<<view-restart>>z<<restart-shell>>r  )iomenur   r8  r9  backslashreplacer7  2   disabledr   )?
menu_specsr{   r	  rv   Tkr   withdrawr   shell_sidebarr   rK   usetabsindentwidthhasattrr  r  sys_ps1r  prompt_last_linepromptrL   	configurerM   enter_callbacklinefeed_callbackcancel_callbackeof_callbackr  toggle_debuggertoggle_jit_stack_viewercopy_with_prompts_callbackr  view_restart_markrestart_shellr   squeezersqueeze_current_text_eventr8  save_stdoutr9  save_stderrr   
save_stdinr  r  r   encodingerrorsr   r7  pydoc
plainpagerpagerr  r  historyr  r  perr   insertfilterr   update_menu_state)rG   rP   msr   rL   r  r:  s          r(   rK   PyShell.__init__o  sZ   __a58wIIa,-)$/=4D$MMO#D)E!d46")#u"5"5sww7 $ 2 24 8 <llyyF#		*D,?,?@		0$2H2HI		+T-A-AB		#T%6%67		)4+A+AB		')=)=>		/1M1MN		)4+J+JK>II($*@*@AII)4+=+=>d+		,11	3 ::::))"!$"(//6==B
#D($*OOV]]D#D($*OO5GI$T9%+__fmmE~CJCJ

CI	**EK
 ||DII.!..t4
  88<<..		79:~""7Az:""7Az: !	CJs   Q$ $R c                 r   > [         TU ]  5         U R                  b  U R                  R                  5         g g rD   )r   	ResetFontr"  update_fontrG   r   s    r(   rD  PyShell.ResetFont  s1    )**, *r0   c                   > [         TU ]  5         [        R                  " 5       nS S S.[        R                  " US5      [        R                  " US5      [        R                  " US5      S.nUR                  5        H"  u  p4U R                  R                  " U40 UD6  M$     U R                  b  U R                  R                  5         g g )N)rg   rf   r8  r9  r  )r   r8  r9  r7  )
r   ResetColorizerr   ri   rj   itemsrL   tag_configurer"  update_colors)rG   rm   
tag_colorsr   tag_colors_configr   s        r(   rI  PyShell.ResetColorizer  s     %%'"&d;))%:))%:**5(;	

 '1&6&6&8"CII##C=+<= '9 ),,. *r0   c                 B    [         R                   " U R                  SS9  g)Nr   )insert_tagsrd   )r   rL   r   s     r(   replace_eventPyShell.replace_event  s    		w7r0   c                 *    [         R                  " SS9$ )NT)
shell_only)r   GetExtensionsr   s    r(   get_standard_extension_names$PyShell.get_standard_extension_names  s    %%66r0   c                 p   U R                   R                  X5      n[        [        [	        U5      5      [        [	        U5      5      5      nU Vs/ s H(  nU R
                  R                  R                  U5      PM*     nnSR                  S [        XcR                  5       5       5       5      S-   $ s  snf )z6Return text between first and last with prompts added.r   c              3   >   #    U  H  u  pUc  UOU SU 3v   M     g 7f)N r   ).0r(  r   s      r(   	<genexpr>*PyShell.get_prompt_text.<locals>.<genexpr>  s-      
 ? ND6(!D6(:: ?s   )
rL   getr   r}   r~   r"  line_promptsrT   zip
splitlines)rG   firstlastrL   lineno_ranger'   promptss          r(   get_prompt_textPyShell.get_prompt_text  s    yy}}U)ed '
& ++//7& 	 
 yy 
 #G__-> ?
 
  		
s   /B3c                     U R                   nUR                  S5      nUc  gUR                  S5      nUS   S:w  a  UR                  S5      nUR                  5         U R                  X45      nUR	                  U5        g)zCopy selected lines to the clipboard, with prompts.

This makes the copied text useful for doc-tests and interactive
shell code examples.

This always copies entire lines, even if only part of the first
and/or last lines is selected.
zsel.first linestartNsel.lastr2   0zsel.last+1line linestart)rL   rr   clipboard_clearrg  clipboard_append)rG   r   rL   selfirstsellastprompt_texts         r(   r0  "PyShell.copy_with_prompts_callback  sx     yy::34**Z(2;#jj!;<G**8=k*r0   c                     Uq g rD   r    )rG   streams     r(   set_warning_streamPyShell.set_warning_stream
  s    r0   c                     [         $ rD   rs  r   s    r(   get_warning_streamPyShell.get_warning_stream  s    r0   c                    U R                   (       a1  [        R                  " SSU R                  S9  U R	                  5         gU R
                  R                  5       nU(       a  U R                  5         g U R                  5         g )NzDon't debug nowz*You can only toggle the debugger when idler  rd   )	rZ  r
   r   rL   set_debugger_indicatorrv   rV  close_debuggeropen_debugger)rG   r   dbs      r(   r.  PyShell.toggle_debugger  sb    >>  !2<yy" '')((*B##%""$r0   c                 d    U R                   R                  5       nU R                  SU(       5        g )Nr  )rv   rV  setvarrG   r~  s     r(   r{  PyShell.set_debugger_indicator  s%    [[$$&)2v6r0   c                     g rD   r   r   s     r(   r/  PyShell.toggle_jit_stack_viewer#  s    r0   c                    U R                   R                  5       nU(       a  U R                   R                  S 5        UR                  5         U R                   R                  (       a*  [
        R                  " U R                   R                  5        U R                  5         U R                  R                  S5        U R                  U l        U R                  5         U R                  5         g )Nz[DEBUG OFF]
)rv   rV  r  rX  r?  r   close_remote_debuggerr  r7  r!   r&  r(  r^  r{  r  s     r(   r|  PyShell.close_debugger&  s    [[$$&KK##D)HHJ{{!!001C1CDLL/,,DKOO##%r0   c                 |   U R                   R                  (       a,  [        R                  " U R                   R                  U 5      nO[        R
                  " U 5      nU R                   R                  U5        UR                  5         SU R                  -   U l	        U R                  5         U R                  5         g )Nz[DEBUG ON]
)rv   r?  r   start_remote_debuggerr   Debuggerr  r`  r&  r(  r^  r{  )rG   dbg_guis     r(   r}  PyShell.open_debugger3  s    ;; 66t{{7I7I;?AG ''-G(  "$t||3##%r0   c                 T    U R                   (       a  SOSnU R                  SSU5        g )Nr  r  rx   z*tack*iewer)rZ  r@  )rG   states     r(   debug_menu_postcommandPyShell.debug_menu_postcommand?  s!    "nn
(wu=r0   c                 2    U R                  5         SU l        g)Helper for ModifiedInterpreterTN)r  rZ  r   s    r(   r  PyShell.beginexecutingC  s    r0   c                 @    SU l         SU l        U R                  5         g)r  FN)rZ  r  r^  r   s    r(   r  PyShell.endexecutingH  s    r0   c                     U R                   (       a'  [        R                  " SSSU R                  S9nUSL a  gU R	                  5         SU l        SU l        [        R                  " U 5      $ )zExtend EditorWindow.close()zKill?z7Your program is still running!
 Do you want to kill it?okr  FcancelT)	rZ  r
   askokcancelrL   r[  r  r  r   rX  )rG   r  s     r(   rX  PyShell.closeN  sa    >>!--Jyy	"H
 5 !!$''r0   c                 d   U R                  5         [        (       a  U R                  R                  5         U R                  [
        l        U R                  [
        l        U R                  [
        l
        SU l        SU l        SU R                  l        SU l        [        R                   " U 5        g)zEExtend EditorWindow._close(), shut down debugger and execution serverN)r|  r  rv   ru  r5  r  r8  r6  r9  r7  r   r7  rP   ru   r=  r   r   r   s    r(   r   PyShell._close]  sw    >KK'')%%
%%
OO	!

D!r0   c                     g)z8Override EditorWindow method: never remove the colorizerTr   r  s     r(   ispythonsourcePyShell.ispythonsourcem  s    r0   c                     U R                   $ rD   )shell_titler   s    r(   short_titlePyShell.short_titleq  s    r0   z>Enter "help" below or click "Help" above for more information.c           
         U R                   R                  SS5        U R                  5         [        (       a5  SnU R                  R                  5       nU(       d  U R                  5         gOSn[        R                  [        l        U R                  S[        R                  < S[        R                  < SU R                  < SU< 35        U R                   R                  5         U R                  5         S	S KnS
Ul        S Ul        g
)Nr   r{   re   Fz==== No Subprocess ====

WARNING: Running IDLE without a Subprocess is deprecated
and will be removed in a later version. See Help/IDLE Help
for details.

zPython z on r   r   T)rL   r\  r  r  rv   rP  rX  r   displayhookr  r!   versionplatform
SPLASHLINEfocus_forcer^  tkinter_support_default_root_default_root)rG   nosubclientr  s       r(   r   PyShell.beginv  s    		8X.>E[[113F

 'E "ooCO

KKtG 	H		(,% $r0   c                 j    U R                   (       d  g SU l        U R                  R                  5         g NT)reading_stop_readline_flagr   quitr   s    r(   r[  PyShell.stop_readline  s!    ||#' r0   c                    U R                   n SU l         U R                  R                  5         Xl         U R                  (       a  SU l        gU R                  R                  SS5      n[        U5      S:X  a  SnU R                  5         U R                  (       a  SU l        [        (       d  [        eU R                  (       a	  SU l        SnU$ ! Xl         f = f)NTFre   r   rS  r   r   )r  r   mainloopr  rL   r_  r   r  r  r  r  	endoffile)rG   r:   r   s      r(   readlinePyShell.readline  s    ||	 DLHHL##',D$yy}}Xx0t9>D==!DM!>''>>"DND  Ls   !C Cc                     gr  r   r   s    r(   isattyPyShell.isatty  s    r0   c                     U R                   R                  SSS5      (       a  g  U R                  (       dM  U R                  (       d<  U R	                  5         U R
                  R                  S5        U R                  5         gSU l        SU l	        U R                  (       ao  U R
                  R                  (       aT  U R
                  R                  5       (       a  U R
                  R                  5         OU R
                  R                  5         U R                  (       a  U R                  R                  5         g!    GN= f)N	sel.firstz!=rj  zKeyboardInterrupt
rd   FT)rL   r   rZ  r  r  rv   r!   r^  r  r  r?  rV  rb  rp  r   r  r   s     r(   r,  PyShell.cancel_callback  s    	yy  dJ?? @ $,,KK34OONNt{{11{{&&((..0002<<HHMMO!	s   "D> >Ec                    U R                   (       a  U R                  (       d  g U R                  R                  SSS5      (       a"  U R                  R                  SSS5      (       d  g U R                   (       d!  U R	                  5         U R                  5         gSU l        SU l        U R                  R                  5         g)Nr   z==r{   rS  FTrd   )
rZ  r  rL   r   r  rX  r  r  r   r  r   s     r(   r-  PyShell.eof_callback  s    >>$,,		!!(D(;;		!!(D(;;~~JJL
  "DM!DNHHMMOr0   c                     U R                   (       a8  U R                  R                  SS5        U R                  R                  S5        gU R	                  U5        g)Nr{   r   rd   )r  rL   r{   seenewline_and_indent_eventr   s     r(   r+  PyShell.linefeed_callback  sE    <<IIXt,IIMM(#  ))%0r0   c                 Z
   U R                   (       a  U R                  (       d  g  U R                  R                  SS5      nU(       a4  U R                  R	                  SSS5      (       a  U R                  X!5        gU R                  R	                  SSS5      (       Ga  U R                  R                  S	S5      nU(       Ga>  U R                  R	                  SSUS
   5      (       Ga  SU R                  R                  S5      ;  a  U R                  R                  SS5      nU(       a2  U R                  R	                  US
   SUS   5      (       a
  US
   US
   4nU R                  R                  SS5      nU(       aN  U R                  R	                  US   SUS
   5      (       a&  US   U R                  R                  US   S-   5      4nU R                  U R                  R                  US   US
   5      U5        gU R                  R                  S	S5      nU(       a  U R                  R	                  SSUS   5      (       a  U R                  R                  SS5      nU(       aN  U R                  R	                  US   SUS
   5      (       a&  US   U R                  R                  US   S-   5      4nU R                  U R                  R                  US   US
   5      U5        gU R                  R                  SS5      nU(       aU  U R                  R	                  US   SS5      (       a0  U R                  U R                  R                  US
   S5      U5        gU R                  U R                  R                  SS5      U5        gU R                  R	                  SSS5      (       a  U R                  R                  SS5        U R                  R                  SS5      nU(       a1  UR                  5       (       d  U R                  R                  SS5        U R                  R	                  SSS5      (       a  U R                  U5        gU R                  R                  SS5        U R                  (       a8  U R                  R                  SS5        U R                  R                  S5        OU R                  U5        U R                  R!                  5         U R                  (       a  U R"                  R%                  5         gU R'                  5         g!    GN= f)Nr  rj  z<=r   rd   r{   r   iomark linestartr   r   r7  z>=r   z+1czinsert lineendr   rS  zend-1c linestartr   )rZ  r  rL   r_  r   recalltag_prevrange	tag_namestag_nextrangerr   r\  stripr   r  r{   r  update_idletasksr   r  runit)	rG   r   selprev	prev_cons	next_consnextindicesr0  s	            r(   r*  PyShell.enter_callback  s   >>$,,	))--Z8C99$$Zx@@KK+" 99Xs,>??
 99**7H=DII%%hT!W==TYY%8%8%BB II33IxH	!2!29Q<tAw!O!O%aL$q'2D II33IxH	!2!29Q<d1g!N!N GTYY__Yq\E5I%JKDDIIMM$q'47;UC99**7H=D		))*:D$q'JJ II33I?OP	!2!29Q<d1g!N!N GTYY__Yq\E5I%JKDDIIMM$q'47;UCii--i9KLGyy  T3EFFDIIMM'!*6FGO  DIIMM*<>NOQVW 99XsH55IIx2 IIMM(H-QWWYYIIXx0 99Xs,>??))%0		8X.<<IIXt,IIMM(#))%0		""$<<HHMMO  JJLE	s   AT% %T*c                    [         R                  " SSU5      n[         R                  " SSU5      nUR                  S5      nU R                  R	                  5          U R                  R                  SSS5        U R                  R                  SS	5        U R                  R                  S
S5      nUR                  5       R                  S5      (       a-  U R                  U5        U R                  R                  S
S5      nU R                  R                  SUS   R                  5       U R                  5        [        U5      S:  a  [         R                  " SUS   5      R!                  S5      n[         R                  " SU5      R!                  S5      nUSS   Ha  nUR#                  U5      (       a  Xg[        U5      S  -   nU R                  R                  SSUR                  5       -   U R                  5        Mc     U R                  R%                  S5        U R                  R'                  5         g ! U R                  R%                  S5        U R                  R'                  5         f = f)Nz^\s*\nre   z\n\s*$r   r  r   r   r{   rS  r   :r   r   z	^([ \t]*))resubr  rL   undo_block_startr   r\  r_  rstripendswithr  r{   r  user_input_insert_tagsr   searchgroupr   r  undo_block_stop)rG   r0  r   r   prefixorig_base_indentnew_base_indentr   s           r(   r  PyShell.recall-  s   FF9b!$FF9b!$		""$	(II  u5IIx2YY]]#5x@F}}'',,--e4'98DIIXuQx~~'7!88:5zA~#%99\58#D#J#J1#M #%99\6#B#H#H#K!!"ID'788.c:J6K6L1MMII$$Xtdkkm/C%)%@%@B	 & IIMM(#II%%' IIMM(#II%%'s   F&H9 97I0z[ \t]*(\n[ \t]*)?\Zc                    U R                   R                  S5      nU R                   R                  SS5      nU R                  R	                  SU5      nU R
                  R                  U5      nU(       d`  U R                   R                  U5      S:X  a&  U R                   R                  U R                  U5        U R                  R                  5         g g )Nend-2cr   rS  re   r   )rL   rr   r_  _last_newline_rer  rv   r  r   r  r"  update_sidebar)rG   index_beforer   input_is_completes       r(   r  PyShell.runitJ  s    yyx0yy}}Xx0 $$((T2 KK11$7 yy}}\*d2		$$T%@%@,O--/ !r0   c                 "   U R                   R                  (       a  U R                   R                  5       $ SSKJn   U" U R
                  [        R                  U R                  5        g !   [        R                  " SSU R                  S9   g = f)Nr   )StackBrowserzNo stack tracez:There is no stack trace yet.
(sys.last_exc is not defined)r  )rv   r?  r  idlelib.stackviewerr  r   r  last_excrP   r
   r   rL   )rG   r   r  s      r(   r  PyShell.open_stack_viewerV  sp    ;;;;22444	"CLL$**= 	"  !10yy" s   ,A* *"Bc                 p    U R                   R                  S5        U R                   R                  S5        g )Nr   rT  )rL   r  r   s     r(   r1  PyShell.view_restart_markd  s"    		h		i r0   c                 6    U R                   R                  SS9  g)z&Callback for Run/Restart Shell Cntl-F6Tr:  N)rv   rb  r   s     r(   r2  PyShell.restart_shellh  s    &&&5r0   c                    U R                  5         U R                  nU R                  (       a9  UR                  U R                  5      (       a  US [	        U R                  5      *  nU R
                  R                  SS5        U R                  R                  U5        U R                  R                  5         U R
                  R                  SS5        U R                  5         U R                  R                  5         g )Nr7  z	iomark-1cr{   rS  )r  r(  r&  r  r   rL   rq   r7  r!   r"  r  r\  set_line_and_columnrW   
reset_undo)rG   r(  s     r(   r^  PyShell.showpromptl  s    <<FOODLL99/c$,,//0F		)[16"))+		8X.  "r0   c                    U R                   R                  R                  n[        USSS9nSR	                  UR                  U5      5      nUR                  S5      (       d  US-  nU R                  R                  R                  SUS5        g )N   T)r  tabsizeexpand_tabsr   r  r9  )
rv   r  r  r   rT   r  r  r>  bottomr{   )rG   r  r  wrapperwrapped_msgs        r(   show_warningPyShell.show_warningz  sr    %%++E1$GiiS 12##D))4K1;Ir0   c                    U R                   R                  SS5      nU R                  (       a  U R                  R                  U5        U R                   R                  S5      S:w  a  U R                   R	                  SS5        U R                   R                  SS5        U R                  5         U R                  R                  5         g )Nr   rS  r  r   )	rL   r_  r=  storer{   r\  r  ctipremove_calltip_window)rG   r  s     r(   r  PyShell.resetoutput  s    x2<<LLv&99=="d*IIXt,		8X.  "		'')r0   c                     U R                   R                  SS5        [        R                  " XUS5      nU R                   R                  SS5        U R                  (       a  SU l        [
        (       d  [        eU$ !   e = f)Nr   rightrU  F)rL   r]  r   r!   r  r  r  )rG   r0  r   counts       r(   r!   PyShell.write  sm    	II""8W5 &&th?EII""8V4 ==!DM!>''	s   AA= =B c                    >  U R                   R                  SSS5      (       a  g [        TU ]  5       $ ! [         a     gf = f)Nr  r   r   r  )rL   r   r   r   r^   rF  s    r(   r^   PyShell.rmenu_check_cut  sM    	yy  c8<<! = w&((  		s   "5 
AAc                 f   > U R                   R                  SSS5      (       a  g[        TU ]  5       $ )Nr{   r   r   r  )rL   r   r   rb   rF  s    r(   rb   PyShell.rmenu_check_paste  s-    99Xc(33w(**r0   c                 l    U R                   R                  5         U R                  R                  5         g rD   )r3  squeeze_current_textr"  r  r   s     r(   r4  "PyShell.squeeze_current_text_event  s$    **,))+r0   c                 8    U R                   R                  5         g rD   )r"  r  )rG   rr   rL   r   s       r(   on_squeezed_expandPyShell.on_squeezed_expand  s    ))+r0   )r  r  r  r7  r  rZ  r=  r$  rv   r  r(  r'  r  r6  r7  r5  r"  r3  r9  r   r8  r&  r#  rD   )r   )Qr   r   r   r   idlelib.squeezerr   r   r  r   r   r   r   r  r   r   r   r6   	itertools	takewhile_idxr{   allow_line_numbersr  idlelib.historyr  idlelib.sidebarr  rK   rD  rI  rR  rW  rg  r0  r  rZ  r  r  r  r  ru  rx  r.  r{  r/  r|  r}  r  r  r  rX  r   r  r  r  r   r[  r  r  r,  r-  r+  r*  r  r  r  r  r  r  r1  r2  r^  r  r  r!   r^   rb   r4  r  r   r   r   s   @r(   r   r   I  s   )."22K ,N)MJ **/. K s4	++2KA   D t 2 3 	$ (,P;d-/ 7"+( GIHIG %7&
&>
("   RJ4.,M^(8 zz"89
0!6J*)+
,, ,r0   r   c           
          U R                   S:X  a0  S H)  nU R                  USSU R                  US5      -   5        M+     gg)z6Make paste replace selection on x11.  See issue #5124.x11)TextEntrySpinboxz	<<Paste>>z%catch {%W delete sel.first sel.last}
N)_windowingsystem
bind_class)r   clss     r(   fix_x11_paster&    sG    %-COO8[9:; . &r0   a  
USAGE: idle  [-deins] [-t title] [file]*
       idle  [-dns] [-t title] (-c cmd | -r file) [arg]*
       idle  [-dns] [-t title] - [arg]*

  -h         print this help message and exit
  -n         run IDLE without a subprocess (DEPRECATED,
             see Help/IDLE Help for details)

The following options will override the IDLE 'settings' configuration:

  -e         open an edit window
  -i         open a shell window

The following options imply -i and will open a shell:

  -c cmd     run the command in a shell, or
  -r file    run script from file

  -d         enable the debugger
  -s         run $IDLESTARTUP or $PYTHONSTARTUP before anything else
  -t title   set title of shell window

A default edit window will be bypassed when -c, -r, or - are used.

[arg]* are passed to the command (-c) or script (-r) in sys.argv[1:].

Examples:

idle
        Open an edit window or shell depending on IDLE's configuration.

idle foo.py foobar.py
        Edit the files, also open a shell if configured to start with shell.

idle -est "Baz" foo.py
        Run $IDLESTARTUP or $PYTHONSTARTUP, edit foo.py, and open a shell
        window with the title "Baz".

idle -c "import sys; print(sys.argv)" "foo"
        Open a shell window and run the command, passing "-c" in sys.argv[0]
        and "foo" in sys.argv[1].

idle -d -s -r foo.py "Hello World"
        Open a shell window, run a startup script, enable the debugger, and
        run foo.py, passing "foo.py" in sys.argv[0] and "Hello World" in
        sys.argv[1].

echo "import sys; print(sys.argv)" | idle - "foobar"
        Open a shell window, run the script piped in, passing '' in sys.argv[0]
        and "foobar" in sys.argv[1].
c            	      6   SS K n SSKJn  SSKJn  SSKJn  [        S5        SqSnSnSnS nS nSn	 U R                  [        R                  SS  S5      u  pW
 H  u  pUS:X  a  UnSnUS:X  a  SnSnUS:X  a  SnUS:X  a8  [        R                  R!                  [        5        [        R                  " 5         US:X  a  SnUS:X  a  [        S[        R                  S9  SqUS:X  aJ  Un["        R$                  R'                  U5      (       a  O![        SU5        [        R                  " 5         SnUS:X  a  Sn	SnUS:X  d  M  U[(        l        SnM     W(       a)  US   S:X  a   [        R,                  R/                  5       nSn[1        [3        [        R$                  5      5       HD  n["        R$                  R5                  [        R$                  U   5      [        R$                  U'   MF     U(       a  US   S:X  a  S/USS  -   [        l	        GOU(       a  S/U-   [        l	        GOU(       a  U/U-   [        l	        OU(       a  Sn/ nU H1  nUR7                  ["        R$                  R9                  U5      5        M3     U HX  n["        R$                  R5                  U5      nU[        R$                  ;  d  M8  [        R$                  R;                  SU5        MZ     OI["        R<                  " 5       nU[        R$                  ;  a   [        R$                  R;                  SU5        [>        R@                  " SSSSS9nU=(       d    UnU=(       d    U(       + n[        (       a  U(       d
  [C        5         [E        SS 9q#[F        RI                  5         SS!K%J&n  U" [F        5        ["        R$                  RO                  ["        R$                  R9                  [P        5      S"5      nU" 5       S#:X  a4  ["        R$                  RO                  US$5      n[F        RS                  US%9  OURU                  5       (       d}  [V        S&:  a  S'nS(nOS)nS*nU Vs/ s H(  n["        R$                  RO                  US+UU4-  5      PM*     nnU Vs/ s H  n[Y        [F        US,9PM     nn[F        RZ                  " S/UQ76   []        [F        5        [_        [F        5        [a        [F        5      q1URe                  [F        [b        5        U(       a^  U(       dW  U(       dP  US S   H,  n[b        Rg                  U5      b  M  URi                  U5        M.     U(       d  [b        Rk                  5         U(       aa  [b        Rm                  5       nU(       d  g URU                  5       (       a/  [b        Rn                  (       a  URp                  Rs                  5         O[b        Rt                  nU(       a  URw                  5         U	(       a  ["        Rx                  R{                  S-5      =(       d    ["        Rx                  R{                  S.5      nU(       a?  ["        R$                  R'                  U5      (       a  UR|                  R                  U5        U(       d  U(       a  UR|                  R                  S/R                  [        R                  5      5        U(       a  UR|                  R                  U5        OmU(       a6  UR|                  R                  U5        UR|                  R                  U5        O/U(       a(  UR                  5       nU(       a  UR                  U5        [b        R                  (       a+  [F        R                  5         [b        R                  (       a  M+  [F        R                  5         [        S5        g ! U R                   aC  n[        S	U S
[         3[        R                  S9  [        R                  " S5         S nAGNS nAff = fs  snf s  snf )0Nr   )system)testing)macosxTFr   zc:deihnr:st:zError: r   r   r   r,  z-dz-ez-hz-iz-nz: Warning: running IDLE without a subprocess is deprecated.z-rzNo script file: z-sz-t-re   r&  r'  zeditor-on-startupr(  )r*  Idle)	className)fix_scalingIconsWindowszidle.ico)r)  g333333!@z.png)       0      z.gif)r1  r2  r3  z	idle_%d%s)masterr   IDLESTARTUPPYTHONSTARTUPzdif 1:
            import sys as _sys
            _sys.argv = {!r}
            del _sys
            
)Igetoptr  r(  r  r)  r*  r/   r  r  argverrorr  	usage_msgr9  exitr8  r!   rR   rS   r   r   r  r   r  r   r   r  rt   dirnamer{   getcwdr   r.  NoDefaultRootr   r   r!  idlelib.runr.  rT   __file__wm_iconbitmapisAquaTk	TkVersion
PhotoImagewm_iconphotor   r&  r   rP   setupAppr   r   newrQ   r  r   lowerru   r}  r  r_  rv   r  r}  r~  r  r  preferTabsPreferenceWarningr  inversedictr  destroy)r8  r(  r)  r*  enable_shellenable_editrx   cmdscriptstartupoptsr[   r  oarO  pathxr&   dir
edit_startr.  icondiriconfileextsizessize	iconfilesiconsr  prefer_tabs_preference_warnings                                 r(   r&  r&    s    TNLKE
CFG]]388AB<@
 9CL9EL9K9JJY'HHJ9L9Nzz#"N9Fww~~f%%(&1
L9GL9"#GL? @ Q3iinn3sxx=!ggoochhqk2 "Q34$qr(?	6D=	8d?	HLL23 C''//#&C#((?3' 
 iikchhHHOOAs###FI$7fFJ+K2{?L ~gDMMO' ggll277??84g>Gx977<<48,__C%EC E!&(!& WW\\';$+DE!& 	 ( "+,!*X 4h7!* 	 ,$'' $$D!E
OOD% v G::h'/KK) $ 		  "??
 IIOO ::>>-0 3::>>/2 	x00LL!!(+
f ! &"		$
 LL##C(LL((0LL!!&)	 *0)K)K)M&)=>


 


LLNUy << uByk*<n(,s#   %^; /``;`8`		`)NN)Nr  r   r  r  ImportErrorr  r  r  r  idlelib.utilr	   r
   r  r   r  r4   rR   os.pathr   r  rD  r   textwrapr   rl  r=  r  r,   idlelib.colorizerr   idlelib.configr   idlelib.delegatorr   r  r   r   idlelib.editorr   r   idlelib.filelistr   idlelib.outwinr   r   r   r@  r   r   r   idlelib.undor   r  r<  r  eofr<  r  	NameErrorr    r)   r+   r/   
checkcacher<   r>   r   r   r   r   	RPCClientr   r  r	  r   r&  r;  r&  r   r0   r(   <module>ro     s   z%([[%<CKK!" <<7*O  '   	  # 	         , # '   6 % '   G G & 	
 CDHDH  >B"  )  +/2;2F2F( 5	 {", {"|h (
2^ 
2/M /D1	 1#-- m(0 m(`c	,l c	,L;4	lnb zF  w4  	 9?B~~O
Q-b  		s   F- #G - GGG