
    ѝi                        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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.J/r/J0r0  S SK1J2r2  Sq3Sr4S r5 Sr6\6\7l6        \6\8l6        \ R                  q: S4S jr;Sq<S r=\=" S5        S\R|                  4S jr?\?\l>         " S  S!\%5      r@ " S" S#\(5      rA " S$ S%\5      rB " S& S'\25      rC " S( S)\ 5      rD " S* S+\,R                  5      rFS, rG " S- S.\5      rH " S/ S0\*5      rIS1 rJS2rKS3 rL\S:X  a  \L" 5         \=" S5        g! \ a    \" S\ R                  S9  \" S5      ef = f! \9 a     Nf = f)5    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)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         !lib/python3.13/idlelib/pyshell.pyidle_showwarningr(   B   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.   U   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_checkcacher4   savekeys        r'   extended_linecache_checkcacher;   d   s^     OOEDE{r7SX%		#DI  H	LLr/   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    $$&Jr/   )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%   rD   color_breakpoint_text)rF   argsrG   s      r'   rJ   PyShellEditorWindow.__init__~   s    d*T*		+T-F-FG		-t/J/JK		.

0E0EF !ggll  "35 ,077+G+G'+	 	(()>?77$$&""$r/   ))Cutz<<cut>>rmenu_check_cut)Copyz<<copy>>rmenu_check_copy)Pastez	<<paste>>rmenu_check_paste)NNN)zSet Breakpointr@   N)zClear BreakpointrA   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)rV   r   CurrentThemeGetHighlightrK   
tag_config)rF   colorthemecfgs       r'   rY   )PyShellEditorWindow.color_breakpoint_text   sO    77?))+E''w7C!#26C		Wc*r/   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)Nrg   z%d.0r   )rK   rV   r%   tag_addrI   index
ValueErrorappendrO   pyshellinterpr   set_breakpoint)rF   r&   rK   r%   debugs        r'   rv   "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)rK   rV   r%   bellintfloatrq   rv   )rF   eventrK   r%   r&   s        r'   rM   (PyShellEditorWindow.set_breakpoint_event   sO    yy77##IIKU4::h/01F#r/   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)Nrz   rg   insert linestartzinsert lineend +1char)rK   rV   r%   r{   r|   r}   rq   rI   remove
tag_removerO   rt   ru   r   clear_breakpoint)rF   r~   rK   r%   r&   rw   s         r'   rN   *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)Nrg   1.0)rI   rK   rV   r%   r{   r   ENDrO   rt   ru   r   clear_file_breaks)rF   rK   r%   rw   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)rI   rV   r%   openrU   	readlinesr"   
startswithr    update_breakpointsstrgetattrrootr   r
   	showerrorrK   )rF   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   )rK   r7   rV   r%   rQ   rR   isfilerU   r   r   r   evallenrv   )rF   r%   r   r   r   breakpoint_linenumbersbreakpoint_linenumbers          r'   rD   '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 windowrg   N)rK   
tag_rangesranges_to_linenumbersrI   )rF   rK   rangeslinenumber_lists       r'   r   &PyShellEditorWindow.update_breakpoints  s/    yy)44V<*r/   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}   stringrs   )rF   r   r   rq   r&   ends         r'   r   )PyShellEditorWindow.ranges_to_linenumbers"  sx    1c&k1-Ev}3345FeF7O2234C,V$! , . r/   c                 P    U R                  5         [        R                  " U 5        g)z7Extend base method - clear breaks when module is closedN)r   r   _closerF   s    r'   r   PyShellEditorWindow._close3  s     D!r/   )rU   rI   )TrC   )__name__
__module____qualname____firstlineno____doc__rJ   rmenu_specsrY   rv   rM   rN   r   r   rD   r   r   r   __static_attributes__ r/   r'   r=   r=   {   sE    <%(K
+$&(&TC"+""r/   r=   c                   *    \ rS rSrSr\rSrSS jrSr	g)PyShellFileListi9  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                   $ rC   )rt   topwakeupPyShellbeginrF   r~   s     r'   rP   PyShellFileList.open_shellB  s_    <<LL##% ||	 #4=DL||||))++||r/   )rt   rC   )
r   r   r   r   r   r=   r   rt   rP   r   r   r/   r'   r   r   9  s    > 'LGr/   r   c                   $    \ rS rSrSrS rS rSrg)ModifiedColorDelegatoriM  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   rp   r   recolorize_mainr   s    r'   r   &ModifiedColorDelegator.recolorize_mainO  s0    x0VUH-&&t,r/   c                 P    U R                    H  nU R                  USS5        M     g )Nr   r   )tagdefsr   )rF   tags     r'   removecolors#ModifiedColorDelegator.removecolorsT  s     <<COOC51  r/   r   N)r   r   r   r   r   r   r   r   r   r/   r'   r   r   M  s    >-
2r/   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	$ )ModifiedUndoDelegatoriZ  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   rz   rF   rq   charstagss       r'   rz   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)rF   index1index2s      r'   r   ModifiedUndoDelegator.deletee  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   )rq   r   orig_inserts     r'   <lambda>2ModifiedUndoDelegator.undo_event.<locals>.<lambda>u  s    U7!Cr/   )r   rz   super
undo_event)rF   r~   r   	__class__s     @r'   r    ModifiedUndoDelegator.undo_eventn  sN    
 mm**C 		/Gu%#.DMM ;DMM s   A A#r   rC   )
r   r   r   r   r   rz   r   r   r   __classcell__r   s   @r'   r   r   Z  s    A73/ /r/   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   rz   r   s       r'   rz    UserInputTaggingDelegator.insert~  s     <DU40r/   r   rC   )r   r   r   r   r   rz   r   r   r/   r'   r   r   |  s
    81r/   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    r/   r   N)r   r   r   r   r   r   r   r/   r'   r   r     s    r/   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r/   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   rJ   
restartingsubprocess_arglistPORTportcompilecompilerflagsoriginal_compiler_flags)rF   r  r
  s      r'   rJ   ModifiedInterpreter.__init__  sW    "Z(11''<"&	'+||'<'<'B'B$r/   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dictrQ   environ
subprocessPopen
rpcsubproc)rF   r  s     r'   spawn_subprocess$ModifiedInterpreter.spawn_subprocess  sI    ""*&*&C&C&ED#2::F+$**4+B+BLr/   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   )rF   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stderrrO   r3   ru   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   r7  r8  rO   r3   transfer_pathpoll_subprocess)rF   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)	NTFr9  r   end-1cr   restartleft)r  r>  getdebuggerr   close_subprocess_debuggercloseterminate_subprocessr  	executingr"  rG  rH  rI  rK  stop_readlinerK   r   r    r  r  mark_setmark_gravity
showpromptrestart_subprocess_debuggerload_breakpointsr  r  r  r  )rF   r:  r%   rw   r6  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Fr/   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??Ar/   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  rK   after_cancelr>  r@  rW  r!   rX  rY  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'   rX  (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 )Nrd   zTif 1:
        import sys as _sys
        _sys.path = {!r}
        del _sys
        
)extendr  rR   
runcommandformat)rF   r:  rR   s      r'   rK  !ModifiedInterpreter.transfer_path3  sA    4DKK!88D  fTl		r/   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?)rx  OKr   	EXCEPTION<<toggle-jit-stack-viewer>>ERRORz/pyshell.ModifiedInterpreter: Subprocess ERROR:
)r>  pollresponse
active_seqr   r"   KeyboardInterruptr  closingra  resetoutputr6  printreprgetvarremote_stack_viewerr  
__stderr__endexecutingr!   rK   afterpollintervalrL  rr  )rF   cltresponsehowwhatr6  errmsgs          r'   rL  #ModifiedInterpreter.poll_subprocessB  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 rC   r   )rF   r   s     r'   setdebuggerModifiedInterpreter.setdebuggerj  s     r/   c                     U R                   $ rC   r   r   s    r'   rU  ModifiedInterpreter.getdebuggerm  s    }}r/   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  rK   r  r  r   s    r'   open_remote_stack_viewer,ModifiedInterpreter.open_remote_stack_viewerp  s'     	!!#t'?'?@r/   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_rrd  stackviewer)rO   )ScrolledCanvasTreeNodenormalrf   )bghighlightthicknessr   both)expandfill)idlelibr  r>  remotequeuer  r   r{   StubObjectTreeItemidlelib.treer  r  Toplevelr   rh   ri   framepackcanvasr  )rF   r  oiditemr  r  r   rl   rf   scnodes              r'   r  'ModifiedInterpreter.remote_stack_viewer}  s    &kk%%fmZL;NN$$&,,T[[#>9t~~**+%%'**5(;LI
C1E
QV,		4.r/   r   c                 H    U R                  U5      nU R                  X!5        g)z1Like runsource() but assumes complete exec sourceN)stuffsourceexecfilerF   sourcer%   s      r'   
execsourceModifiedInterpreter.execsource  s    ##F+h'r/   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__rd  zB*** Error in script or command!
Traceback (most recent call last):r   )tokenizer   readuse_subprocessrQ   rR   abspathr  runcodeOverflowErrorSyntaxErrorr  r  r  r8  r   showsyntaxerrorr]  )rF   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Gr/   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   r3   r4   )rF   r  r%   r   s       r'   r  ModifiedInterpreter.stuffsource  sO    !DHH,88a<T"$'KM1e$E	!r/   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}  rF   r%   s     r'   prepend_syspath#ModifiedInterpreter.prepend_syspath  s      &"	$r/   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   msgrd   z<no detail available>r&   r   offsetr   ziomark + %d charsz&iomark linestart + %d lines + %d charszSyntaxError: %s
N)
r  rK   r   r  exc_infor   colorize_syntax_errorr  r    r]  )rF   r%   kwargsr  rK   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

&,-r/   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,,. @r/   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   r1   r2   )r3   r4   r5   )rF   r4   r:   s      r'   r  "ModifiedInterpreter.checklinecache  s7    ;C2AwRS!T)J r/   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   rd  r  r   )r  rY  display_executing_dialogr>  r  rd  r
  )rF   r  s     r'   r|  ModifiedInterpreter.runcommand  sW     >>##))+;;KK##FIwC  {{#r/   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 methodNrd  r  zExit?zDo you want to exit altogether?yesr(  r   z IDLE internal error in runcode()r   Fr  )r  rY  ra  r  r   beginexecutingr>  
asyncqueuer  runr
  rd  
SystemExitr  r
   askyesnorK   r  r  r  r8  r  canceledr!   )rF   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  r8  r    )rF   r/  s     r'   r    ModifiedInterpreter.write)  s    ~~$$**1--r/   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  rK   r   s    r'   r?  .ModifiedInterpreter.display_port_binding_error-  s'     / >>&&	(r/   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'   rI  /ModifiedInterpreter.display_no_subprocess_error8  s(    )J >>&&	(r/   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_dialog@  s%    0>>&&		(r/   )rr  r  r   r  r  r  r  r>  r!  r  r  )Frd   )FrC   )(r   r   r   r   rJ   rr  r>  r!  r"  r  rO  ra  rm  ro  rt  rX  rK  r  rL  r   r  rU  r  r  r  r  r  r  r  r  r  r  r  r|  r  r    r?  rI  r  r   r   r/   r'   r  r    s    C HFJM
F)V*XGB J$CL H!" C(
(H
$4/
,\.	(((r/   r  c            	       d  ^  \ rS rSrSSKJr  S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 r/S r0S r1S  r2S! r3S" r4S#r5S$ r6S% r7S& r8S' r9S;S( jr:S) r;S* r<S+ r=S, r>\?R                  " S-5      rAS. rBS;S/ jrCS;S0 jrDS;S1 jrES2 rFS3 rGS4 rHS<S5 jrIU 4S6 jrJU 4S7 jrKS;S8 jrLS9 rMS:rNU =rO$ )=r   iH  r   )Squeezerz
IDLE Shell))r   _File)edit_Edit)rw   _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>`  s    :a=F2r/   )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   r1   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   r7  r8  backslashreplacer6  2   disabledr   )?
menu_specsrz   r  ru   Tkr   withdrawr   shell_sidebarr   rJ   usetabsindentwidthhasattrr  r  sys_ps1r  prompt_last_linepromptrK   	configurerL   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_eventr7  save_stdoutr8  save_stderrr   
save_stdinr  r  r   encodingerrorsr   r6  pydoc
plainpagerpagerr  r  historyr  r  perr   insertfilterr   update_menu_state)rF   rO   msr   rK   r  r9  s          r'   rJ   PyShell.__init__n  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 rC   )r   	ResetFontr!  update_fontrF   r   s    r'   rC  PyShell.ResetFont  s1    )**, *r/   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)rf   re   r7  r8  r  )r   r7  r8  r6  )
r   ResetColorizerr   rh   ri   itemsrK   tag_configurer!  update_colors)rF   rl   
tag_colorsr   tag_colors_configr   s        r'   rH  PyShell.ResetColorizer  s     %%'"&d;))%:))%:**5(;	

 '1&6&6&8"CII##C=+<= '9 ),,. *r/   c                 B    [         R                   " U R                  SS9  g)Nr   )insert_tagsrc   )r   rK   r   s     r'   replace_eventPyShell.replace_event  s    		w7r/   c                 *    [         R                  " SS9$ )NT)
shell_only)r   GetExtensionsr   s    r'   get_standard_extension_names$PyShell.get_standard_extension_names  s    %%66r/   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   )
rK   getr   r|   r}   r!  line_promptsrS   zip
splitlines)rF   firstlastrK   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.lastr1   0zsel.last+1line linestart)rK   rq   clipboard_clearrf  clipboard_append)rF   r~   rK   selfirstsellastprompt_texts         r'   r/  "PyShell.copy_with_prompts_callback  sx     yy::34**Z(2;#jj!;<G**8=k*r/   c                     Uq g rC   r   )rF   streams     r'   set_warning_streamPyShell.set_warning_stream	  s    r/   c                     [         $ rC   rr  r   s    r'   get_warning_streamPyShell.get_warning_stream  s    r/   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  rc   )	rY  r
   r   rK   set_debugger_indicatorru   rU  close_debuggeropen_debugger)rF   r~   dbs      r'   r-  PyShell.toggle_debugger  sb    >>  !2<yy" '')((*B##%""$r/   c                 d    U R                   R                  5       nU R                  SU(       5        g )Nr  )ru   rU  setvarrF   r}  s     r'   rz  PyShell.set_debugger_indicator  s%    [[$$&)2v6r/   c                     g rC   r   r   s     r'   r.  PyShell.toggle_jit_stack_viewer"  s    r/   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]
)ru   rU  r  rW  r>  r   close_remote_debuggerr  r6  r    r%  r'  r]  rz  r  s     r'   r{  PyShell.close_debugger%  s    [[$$&KK##D)HHJ{{!!001C1CDLL/,,DKOO##%r/   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]
)ru   r>  r   start_remote_debuggerr   Debuggerr  r_  r%  r'  r]  rz  )rF   dbg_guis     r'   r|  PyShell.open_debugger2  s    ;; 66t{{7I7I;?AG ''-G(  "$t||3##%r/   c                 T    U R                   (       a  SOSnU R                  SSU5        g )Nr  r  rw   z*tack*iewer)rY  r?  )rF   states     r'   debug_menu_postcommandPyShell.debug_menu_postcommand>  s!    "nn
(wu=r/   c                 2    U R                  5         SU l        g)Helper for ModifiedInterpreterTN)r  rY  r   s    r'   r  PyShell.beginexecutingB  s    r/   c                 @    SU l         SU l        U R                  5         g)r  FN)rY  r  r]  r   s    r'   r  PyShell.endexecutingG  s    r/   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)	rY  r
   askokcancelrK   rZ  r  r  r   rW  )rF   r  s     r'   rW  PyShell.closeM  sa    >>!--Jyy	"H
 5 !!$''r/   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  ru   rt  r4  r  r7  r5  r8  r6  r   r6  rO   rt   r<  r   r   r   s    r'   r   PyShell._close\  sw    >KK'')%%
%%
OO	!

D!r/   c                     g)z8Override EditorWindow method: never remove the colorizerTr   r  s     r'   ispythonsourcePyShell.ispythonsourcel  s    r/   c                     U R                   $ rC   )shell_titler   s    r'   short_titlePyShell.short_titlep  s    r/   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   rz   rd   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)rK   r[  r  r  ru   rO  rW  r   displayhookr  r    versionplatform
SPLASHLINEfocus_forcer]  tkinter_support_default_root_default_root)rF   nosubclientr  s       r'   r   PyShell.beginu  s    		8X.>E[[113F

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

KKtG 	H		(,% $r/   c                 j    U R                   (       d  g SU l        U R                  R                  5         g NT)reading_stop_readline_flagr   quitr   s    r'   rZ  PyShell.stop_readline  s!    ||#' r/   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)NTFrd   r   rR  r   r   )r  r   mainloopr  rK   r^  r   r  r  r  r  	endoffile)rF   r9   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    r/   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!=ri  zKeyboardInterrupt
rc   FT)rK   r   rY  r  r  ru   r    r]  r  r  r>  rU  ra  ro  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==rz   rR  FTrc   )
rY  r  rK   r   r  rW  r  r  r   r  r   s     r'   r,  PyShell.eof_callback  s    >>$,,		!!(D(;;		!!(D(;;~~JJL
  "DM!DNHHMMOr/   c                     U R                   (       a8  U R                  R                  SS5        U R                  R                  S5        gU R	                  U5        g)Nrz   r   rc   )r  rK   rz   seenewline_and_indent_eventr   s     r'   r*  PyShell.linefeed_callback  sE    <<IIXt,IIMM(#  ))%0r/   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  ri  z<=r   rc   rz   r   iomark linestartr   r   r6  z>=r   z+1czinsert lineendr   rR  zend-1c linestartr   )rY  r  rK   r^  r   recalltag_prevrange	tag_namestag_nextrangerq   r[  stripr   r  rz   r  update_idletasksr   r  runit)	rF   r~   selprev	prev_cons	next_consnextindicesr/  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*\nrd   z\n\s*$r   r  r   r   rz   rR  r   :r   r   z	^([ \t]*))resubr  rK   undo_block_startr   r[  r^  rstripendswithr  rz   r  user_input_insert_tagsr   searchgroupr   r  undo_block_stop)rF   r/  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   rR  rd   r   )rK   rq   r^  _last_newline_rer  ru   r  r   r  r!  update_sidebar)rF   index_beforer   input_is_completes       r'   r  PyShell.runitI  s    yyx0yy}}Xx0 $$((T2 KK11$7 yy}}\*d2		$$T%@%@,O--/ !r/   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  )ru   r>  r  idlelib.stackviewerr  r   r  last_excrO   r
   r   rK   )rF   r~   r  s      r'   r  PyShell.open_stack_viewerU  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   rS  )rK   r  r   s     r'   r0  PyShell.view_restart_markc  s"    		h		i r/   c                 6    U R                   R                  SS9  g)z&Callback for Run/Restart Shell Cntl-F6Tr9  N)ru   ra  r   s     r'   r1  PyShell.restart_shellg  s    &&&5r/   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 )Nr6  z	iomark-1crz   rR  )r  r'  r%  r  r   rK   rp   r6  r    r!  r  r[  set_line_and_columnrV   
reset_undo)rF   r'  s     r'   r]  PyShell.showpromptk  s    <<FOODLL99/c$,,//0F		)[16"))+		8X.  "r/   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  r8  )
ru   r  r  r   rS   r  r  r=  bottomrz   )rF   r  r  wrapperwrapped_msgs        r'   show_warningPyShell.show_warningy  sr    %%++E1$GiiS 12##D))4K1;Ir/   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   rR  r  r   )	rK   r^  r<  storerz   r[  r  ctipremove_calltip_window)rF   r  s     r'   r  PyShell.resetoutput  s    x2<<LLv&99=="d*IIXt,		8X.  "		'')r/   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   rightrT  F)rK   r\  r   r    r  r  r  )rF   r/  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  )rK   r   r   r   r]   rE  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       $ )Nrz   r   r   r  )rK   r   r   ra   rE  s    r'   ra   PyShell.rmenu_check_paste  s-    99Xc(33w(**r/   c                 l    U R                   R                  5         U R                  R                  5         g rC   )r2  squeeze_current_textr!  r  r   s     r'   r3  "PyShell.squeeze_current_text_event  s$    **,))+r/   c                 8    U R                   R                  5         g rC   )r!  r  )rF   rq   rK   r   s       r'   on_squeezed_expandPyShell.on_squeezed_expand  s    ))+r/   )r  r  r  r6  r  rY  r<  r#  ru   r  r'  r&  r  r5  r6  r4  r!  r2  r8  r   r7  r%  r"  rC   )r   )Pr   r   r   r   idlelib.squeezerr  r  r   r   r   r   r  r   r   r   r5   	itertools	takewhile_idxrz   allow_line_numbersr  idlelib.historyr  idlelib.sidebarr  rJ   rC  rH  rQ  rV  rf  r/  r  rY  r  r  r  r  rt  rw  r-  rz  r.  r{  r|  r  r  r  rW  r   r  r  r  r   rZ  r  r  r+  r,  r*  r)  r  r  r  r  r  r  r0  r1  r]  r  r  r    r]   ra   r3  r  r   r   r   s   @r'   r   r   H  s   )K ,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*)+
,, ,r/   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:; . &r/   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-rd   r%  r&  zeditor-on-startupr'  )r)  Idle)	className)fix_scalingIconsWindowszidle.ico)r(  g333333!@z.png)       0      z.gif)r0  r1  r2  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_msgr8  exitr7  r    rQ   rR   r   r   r  r   r  r   r   r  rs   dirnamerz   getcwdr   r-  NoDefaultRootr  r   r   idlelib.runr-  rS   __file__wm_iconbitmapisAquaTk	TkVersion
PhotoImagewm_iconphotor   r%  r   rO   setupAppr   r   newrP   r  r   lowerrt   r|  r  r^  ru   r  r|  r}  r  r  preferTabsPreferenceWarningr  inversedictr  destroy)r7  r'  r(  r)  enable_shellenable_editrw   cmdscriptstartupoptsrZ   r  oarN  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)Mr  r   r  r  ImportErrorr  r  r  r  idlelib.utilr	   r
   r  r   r  r3   rQ   os.pathr  rC  r  textwrapr   rk  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   r/   r'   <module>rn     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  u4  	 9?B~~O
Q-`  		s   F' G
 ' G
GG