\d ddlZedkrejdejd< ddlTn&#e$redejedwxYwejdkr9 ddl Z dZ e j d  e n#ee ef$rYnwxYwdd lmZdd lmZddlZddlZddlZddlZdd lmZddlZddlZddlZdd lmZddlZddlZddlZddlZddl m!Z!ddl"m#Z#ddl$m%Z%ddl&m'Z'ddl&m(Z(ddl)m*Z*m+Z+ddl,m-Z-ddl.m/Z/ddl&m0Z0ddl&m1Z1ddl2m3Z3m4Z4m5Z5ddl6m7Z7da8dZ9dZ: dZ;e;e<_;e;e=_;n #e>$rYnwxYweja? d5dZ@daAdZBeBddejCfd ZDeDe_CGd!d"e*ZEGd#d$e-ZFGd%d&e!ZGGd'd(e7ZHGd)d*e%ZIGd+d,e1jJZKd-ZLGd.d/eZMGd0d1e/ZNd2ZOd3ZPd4ZQedkr eQeBddS)6N__main__zidlelib.pyshell)*zJ** IDLE can't import Tkinter. Your Python may not be configured for Tk. **filewin32shcore) messagebox)InteractiveInterpreter)python_version) TextWrapper)ColorDelegator)idleConf) Delegatordebugger) debugger_r) EditorWindow fixwordbreaks)FileList) OutputWindow)replace)rpc)idle_formatwarning StdInputFile StdOutputFile) UndoDelegatorFz 127.0.0.1zCtrl-D (end-of-file)c |t} |t||||||ddS#ttf$rYdSwxYw)aShow 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_streamwriterAttributeErrorOSError)messagecategoryfilenamelinenorrs ..\python\lib\idlelib\pyshell.pyidle_showwarningr)Is |  %8V$@@@ A A A 6 G $     sReplace warning.showwarning with idle_showwarning, or reverse.N)_warnings_showwarningwarnings showwarningr))captures r(capture_warningsr/\sU) ($,$8 !#3H  ) ( ! ,#8H $( ! ! ! - ,Tctj}i}t|D]3}|dd|ddzdkr||||<4||||dS)aoExtend linecache.checkcache to preserve the entries Rather than repeating the linecache code, patch it to save the 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<>) linecachecachelistpopupdate)r&orig_checkcacher5savekeys r(extended_linecache_checkcacher<ks OE DE{{'' rr7SX  % % #DIOH LLr0cbeZdZdZdZgdZddZdZddZdd Z d Z d Z d Z d Z dZdZdS)PyShellEditorWindowz6Regular text edit window in IDLE, supports breakpointscg|_tj|g|R|jd|j|jd|j|jd|jjtj tj d|_|jj|fd}|j||jjr||dS)N<><>z<>zbreakpoints.lstcB||dSN)restore_file_breaks)old_hookselfs r(filename_changed_hookz;PyShellEditorWindow.__init__..filename_changed_hooks#  $ $ & & & HJJJJJr0) breakpointsr__init__textbindset_breakpoint_hereclear_breakpoint_hereflist open_shellospathjoinruserdirbreakpointPathiofilename_change_hookset_filename_change_hookr&rDcolor_breakpoint_text)rFargsrGs r(rIzPyShellEditorWindow.__init__sd*T**** 0$2JKKK 2D4NOOO . 0EFFF!gll "355,07+G'+     (()>??? 7  '  $ $ & & & ""$$$$$r0))Cutz<>rmenu_check_cut)Copyz<>rmenu_check_copy)Pastez <>rmenu_check_paste)NNN)zSet Breakpointr@N)zClear BreakpointrANTc|jdS|r)tj}tj|d}nddd}|jd|dS)z,Turn colorizing of breakpoint text on or offNbreak) foreground backgroundBREAK)rUr CurrentTheme GetHighlightrJ tag_config)rFcolorthemecfgs r(rXz)PyShellEditorWindow.color_breakpoint_textsc 7? F  7)++E'w77CC!#266C Wc*****r0cb|j}|jj}|dd|zd|dzz |j|n*#t $r|j|YnwxYw |jj j j }| ||dS#YdSxYw)Nrez%d.0r) rJrUr&tag_addrHindex ValueErrorappendrNpyshellinterprrL)rFr'rJr&debugs r(set_breakpointz"PyShellEditorWindow.set_breakpointsy7# Wfvov/BCCC ,   " "6 * * * * , , ,   # #F + + + + + , J&-6E  % %h 7 7 7 7 7  DDsA$A76A7;,B))B.Nc|j}|jj}|s|dSt t |d}||dS)Ninsert)rJrUr&bellintfloatrnrt)rFeventrJr&r's r(rLz'PyShellEditorWindow.set_breakpoint_hereshy7#  IIKKK FU4::h//0011 F#####r0c|j}|jj}|s|dSt t |d} |j|n#YnxYw| ddd |j j j j }|||dS#YdSxYw)Nrvreinsert linestartzinsert lineend +1char)rJrUr&rwrxryrnrHremove tag_removerNrqrrrrM)rFrzrJr&r'rss r(rMz)PyShellEditorWindow.clear_breakpoint_heresy7#  IIKKK FU4::h//0011    # #F + + + +  D !3/ 1 1 1 J&-6E  ' '& 9 9 9 9 9  DDsA77A;,CC c|jr|j}|jj}|s|dSg|_|ddt  |jjj j }| |dS#YdSxYwdS)Nre1.0) rHrJrUr&rwr~ENDrNrqrrrclear_file_breaks)rFrJr&rss r(rz%PyShellEditorWindow.clear_file_breakss   9Dw'H  !D  OOGUC 0 0 0  *1:''11111   s +BB c|j}|jj} t|j5}|}dddn #1swxYwYn#t $rg}YnwxYw t|jd5}|D]/}||dzs||0| |j}|r+||dzt|zdzddddS#1swxYwYdS#t $r_}t|j dds>d|j _ tjdd t|z|j Yd}~dSYd}~dSd}~wwxYw) z#Save breakpoints when file is savedNw= breakpoint_error_displayedFTz IDLE Errorz$Unable to update breakpoint list: %s)titler$parent)rHrUr&openrT readlinesr# startswithr!update_breakpointsstrgetattrrootrr showerrorrJ)rFbreaksr&fplinesnew_filererrs r(store_file_breaksz%PyShellEditorWindow.store_file_breaksso$!7# d)** 'b  ' ' ' ' ' ' ' ' ' ' ' ' ' ' '   EEE  &d)3// H8!--D??8c>::- t,,,''))))HNN8c>CKK#?$#FGGG H H H H H H H H H H H H H H H H H H & & &49&BEJJ &7; 4$<Cc((#9&&&&&&&&&& & & & & & & &sqAA  A AAAA A%$A%)D>A;D9 DD  D D D E<AE77E<c|j|jdS|jj}|dStj|jrt|j5}| }dddn #1swxYwY|D]]}| |dzrAt|t|dzd}|D]}| |\dSdS)Nrr)rJr8rUr&rPrQisfilerTrrrevallenrt)rFr&rrrbreakpoint_linenumbersbreakpoint_linenumbers r(rDz'PyShellEditorWindow.restore_file_breakssQ  7? F7#   F 7>>$- . . Cd)** 'b  ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' C C??8c>22C-1$s8}}Q7G7G2H-I-I*1GCC-++,ABBBB C C C Cs+B  BBcv|j}|d}||}||_dS)z3Retrieves all the breakpoints in the current windowreN)rJ tag_rangesranges_to_linenumbersrH)rFrJrangeslinenumber_lists r(rz&PyShellEditorWindow.update_breakpoints"s;y))44V<<*r0c:g}tdt|dD]y}tt||j}tt||dzj}||kr |||dz }||k z|S)Nrr)rangerrxrystringrp)rFrrrnr'ends r(rz)PyShellEditorWindow.ranges_to_linenumbers)s1c&kk1--  Eve}34455FeF57O23344C3,, V$$$! 3,, r0cV|tj|dS)z7Extend base method - clear breaks when module is closedN)rr_closerFs r(rzPyShellEditorWindow._close:s+    D!!!!!r0)TrC)__name__ __module__ __qualname____doc__rI rmenu_specsrXrtrLrMrrrDrrrr0r(r>r>s<<%%%(K + + + +   $$$$&   (&(&(&TCCC"+++""""""r0r>c"eZdZdZeZdZddZdS)PyShellFileListz8Extend base class: IDLE supports a shell and breakpointsNc|jr|jjn6t||_|jr|jsdS|jSrC)rqtopwakeupPyShellbeginrFrzs r(rOzPyShellFileList.open_shellIs` < L  # # % % % %"4==DL| |))++ 4|r0rC)rrrrr>rrqrOrr0r(rr@s:>>'LGr0rceZdZdZdZdZdS)ModifiedColorDelegatorz8Extend base class: colorizer for the shell window itselfc|ddd|dddtj|dS)NTODOriomarkSYNC)r~rmrrecolorize_mainrs r(rz&ModifiedColorDelegator.recolorize_mainVsE x000 VUH---&t,,,,,r0cH|jD]}||dddS)Nrr)tagdefsr~)rFtags r( removecolorsz#ModifiedColorDelegator.removecolors[s6< 2 2C OOC5 1 1 1 1 2 2r0N)rrrrrrrr0r(rrTs8>>--- 22222r0rc2eZdZdZddZddZfdZxZS)ModifiedUndoDelegatorz;Extend base class: forbid insert/delete before the I/O markNc |j|ddr|jdSn#t$rYnwxYwt j||||dSNz2ModifiedUndoDelegator.undo_event..|sUE7!C!Cr0)rrvsuper undo_event)rFrzr __class__s @r(rz ModifiedUndoDelegator.undo_eventusi m* C C C C  / GG  u % % %#.DM ;DM . . . .s !AArC)rrrrrvrr __classcell__rs@r(rrasfAA77773333 / / / / / / / / /r0rceZdZdZddZdS)UserInputTaggingDelegatorz.Delegator used to tag user input with "stdin".NcF|d}|j|||dSr)rrvrs r(rvz UserInputTaggingDelegator.inserts, <D UE400000r0rC)rrrrrvrr0r(rrs.88111111r0rceZdZdZdS) MyRPCClientct)z0Override the base class - just re-raise EOFError)EOFErrorrs r( handle_EOFzMyRPCClient.handle_EOFsr0N)rrrrrr0r(rrs#r0rcd|pdd}|t|kr4t|t|z d\}}||zdz||dzS|ddS)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 =rrN)rdivmod)widthr&rdivmods r( restart_linersv 0+G / / /C C5#c((?Q//Ss7C-//c#g///3B3xr0ceZdZdZdZdZdZdZdZdZ d"dZ d Z d Z d Z d Zd#d ZdZdZdZdZdZdZdZdZdZd$dZdZdZdZd$dZdZdZdZ dZ!dZ"dZ#d Z$d!Z%dS)%ModifiedInterpreterc||_tjdj}t j||d|_d|_t|_ |j j j |_ dS)Nr)localsF) tkconsolesysmodules__dict__r rI restartingsubprocess_arglistPORTportcompilecompilerflagsoriginal_compiler_flags)rFrrs r(rIzModifiedInterpreter.__init__sZ"Z(1'V<<<<"& '+|'<'B$$$r0Nc|j||_tj|j|_dSrC)rbuild_subprocess_arglist subprocessPopen rpcsubprocrs r(spawn_subprocessz$ModifiedInterpreter.spawn_subprocesss8  " *&*&C&C&E&ED #$*4+BCCr0c|jdks JddtjD}tjddddd }d |d }tjg|zd |t |jgzS) Nrz/Socket should have been assigned a port number.cg|]}d|zS)z-Wr).0ss r( z@ModifiedInterpreter.build_subprocess_arglist..s / / /!TAX / / /r0mainGeneralzdelete-exitfuncFbool)defaulttypez#__import__('idlelib.run').run.main()-c)rr warnoptionsr GetOption executabler)rFr del_exitfcommands r(rz,ModifiedInterpreter.build_subprocess_arglists 1 = / /s / / /&vy:K/46CCC F FFF!#tWc$)nn&EEEr0ct|jf}tdD]<}tj| t ||_n&#t$rY9wxYw|dS|jj d|_tdkr5|jj tjtjd||jj d |jn%#t&$r|YdSwxYw|jd|j|jd|jj|jd|jj|jd|jj|jd |jj|jd t6|jd ||d ||jS)Nrr consolerstdoutstderrrNr4rrTwith_cwd)HOSTrrtimesleeprrpccltr#display_port_binding_errorlistening_sock getsocknamer setsockoptsocket SOL_SOCKET SO_REUSEADDRr settimeoutaccept TimeoutErrordisplay_no_subprocess_errorregisterrrrrrNr4 transfer_pathpoll_subprocess)rFaddris r(start_subprocessz$ModifiedInterpreter.start_subprocesssEdi q  A JqMMM )$//       + + - - -4K.::< C C C  "--b111  K        , , . . .44  Y777 Wdn&:;;; Xt~'<=== Xt~'<=== Wdn&:;;; [)444 Xt,,, D))) {s#A  AAD((E  E Frbc |jr|jSd|_|}|r" tj|jn#YnxYw|j||j}|j}d|_|  |j n%#t$r| YdSwxYw| |||jdd|d|t%|j||jdd|jdd|s||r-tj|j||j|jj_d|_|jS) NTFrrend-1crrestartleft)rr! getdebuggerrclose_subprocess_debuggercloseterminate_subprocessr executingrr*r+r,r. stop_readlinerJrr!rrmark_set mark_gravity showpromptrestart_subprocess_debuggerload_breakpointsrrrr)rFrr&rsr was_executings r(restart_subprocessz&ModifiedInterpreter.restart_subprocesss ? ;   ""   4T[AAAA   !!###.) !   K        , , . . .44  H--- Hh/// d l7=(;;<<< i222 !!)V444 !     %  24; ? ? ?  " " $ $ $&*&B #{sAA %B??C! C!c@|jdddidS)Nexecinterrupt_the_serverr)r! remotecallrs r(__request_interruptz'ModifiedInterpreter.__request_interrupts% v'=r2FFFFFr0c^tj|jdS)N)target) threadingThread'_ModifiedInterpreter__request_interruptstartrs r(interrupt_subprocessz(ModifiedInterpreter.interrupt_subprocesss+ 8999??AAAAAr0c`|j$|jj|j |jjn#t$rYnwxYw |jn#t$rYnwxYw|d|j_ d|_dS)NF) _afteridrrJ after_cancelr!r#r9r"r:r;rs r(kill_subprocessz#ModifiedInterpreter.kill_subprocesss = $ N  , ,T] ; ; ;  K & , , . . . .    D   K          D  !!####(  s#A AAA77 BBc |j |jdS#t$rYdSwxYw#t$rYdSwxYw)z"Make sure subprocess is terminatedN)rkillwaitr#rs r(r:z(ModifiedInterpreter.terminate_subprocess+s  O " " "  $$&&&&&         FF s A7 AA AAc|r#dg}|tjn tj}|d|dS)NrbzTif 1: import sys as _sys _sys.path = {!r} del _sys )extendrrQ runcommandformat)rFrrQs r(r.z!ModifiedInterpreter.transfer_path8sa  4D KK ! ! ! !8D fTll      r0c@|j}|dS ||jd}nB#ttt f$r(|jjrYdSd}|YnwxYw|r|j d|_|\}}|jj }|dkr!|tt||nk|dkr/|j dr|n6|dkr0d}t||tjt||| |jn#t$$rYnwxYw|jjs6|jj|jj|j|_dSdS) Ng?)rVOKr EXCEPTION<>ERRORz/pyshell.ModifiedInterpreter: Subprocess ERROR: )r! pollresponse active_seqrr#KeyboardInterruptrclosingrC resetoutputrprintreprgetvarremote_stack_viewerr __stderr__ endexecutingr"rJafter pollintervalr/rQ)rFcltresponsehowwhatrerrmsgs r(r/z#ModifiedInterpreter.poll_subprocessGsk ; F &''d'CCHH'#45 & & &~% H  # # % % % % %  &   N & & ( ( ("DO ICn,Gd{{#$t**73333 ##>(()FGG/,,...Kfd8888fd1111 ++----!    ~% C N/55+T-ACCDMMM C Cs'*#A)A)(A)2E EEc||_dSrCr)rFrs r( setdebuggerzModifiedInterpreter.setdebuggeros   r0c|jSrCrrs r(r7zModifiedInterpreter.getdebuggerrs }r0cP|jjd|jdS)aInitiate 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)rrJrkrhrs r(open_remote_stack_viewerz,ModifiedInterpreter.open_remote_stack_viewerus' !!#t'?@@@r0cddlm}|jdddi}| |jjdS||j|}ddlm }m }t|jj}tj }tj|dd}|||d } | jd d || jd|} | dS) Nr) debugobj_rrE stackviewer)rN)ScrolledCanvasTreeNodenormalrd)bghighlightthicknessrboth)expandfill)idlelibrxr! remotequeuerrrwStubObjectTreeItem idlelib.treerzr{Toplevelrrfrgframepackcanvasr) rFrxoiditemrzr{rrjrdscnodes r(rhz'ModifiedInterpreter.remote_stack_viewers &&&&&&k%%fmZLL ; N  $ $ & & & F,,T[#>>99999999t~*++%''*5(;;LI ^CJ1 E E E  QV ,,,x 4.. r0rc\||}|||dS)z1Like runsource() but assumes complete exec sourceN) stuffsourceexecfilerFsourcer&s r( execsourcezModifiedInterpreter.execsources/##F++ h'''''r0c,|ptj|5}|}tr)dtj|d|zdz}dddn #1swxYwY t||d}||dS#ttf$rf|j td|j jtj|||j YdSwxYw)zExecute an existing fileNz__file__ = r'''z''' z del __file__rEzB*** Error in script or command! Traceback (most recent call last):r)tokenizerreaduse_subprocessrPrQabspathrruncode OverflowError SyntaxErrorrrdrerr showsyntaxerrorr?)rFr&rrcodes r(rzModifiedInterpreter.execfilesh >x(( ;B!;P0I0IPPP &')9:F ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; 68V44D LL     {+ ( ( ( N & & ( ( ( 6~, . . . . # 24 B B B N % % ' ' ' ' ' '  (s%AA((A,/A,4BA3DDc||}t|tsJtj|||S)zBExtend base class method: Stuff the source in the line cache first)r isinstancerr runsourcers r(rzModifiedInterpreter.runsourcesB##F++&#&&&&&&/fhGGGr0cd|jz}|jdz|_|d}t|dzd||ftj|<|S)z"Stuff source in the filename cachez rrr)gidsplitrr4r5)rFrr&rs r(rzModifiedInterpreter.stuffsourcesP!DH,8a< T""$'KKM1eX$E !r0cV|d|dS)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)rYrZrFr&s r(prepend_syspathz#ModifiedInterpreter.prepend_syspaths6 &"" $ $ $ $ $r0c|j}|j}|dddtj\}}}t |ddp|pd}t |ddpd}t |d dpd } | d kr|dz }|dkr d | dz z} n d |dz | dz fz} ||| ||d |z| dS)zOverride Interactive Interpreter method: Use Colorizing Color the offending position instead of printing it and pointing at it with a caret. r_rrmsgrbzr'roffsetrziomark + %d charsz&iomark linestart + %d lines + %d charszSyntaxError: %s N) rrJr~rexc_inforcolorize_syntax_errorrdr!r?) rFr&rrJrvaluetbrr'rposs r(rz#ModifiedInterpreter.showsyntaxerrorsN ~ ...,..eReUB''K5K4K"--2"--2 Q;; aKF Q;;%2CC:!8VAX&'C''c222 &,---r0c|j|tj||jdr|jdSdS)z1Extend base class method to reset output properlyr^N)rrdchecklinecacher showtracebackrgopen_stack_viewerrs r(rz!ModifiedInterpreter.showtracebacksv ""$$$ ,T222 > !> ? ? / N , , . . . . . / /r0ctj}t|D]}|dd|ddzdkr||=dS)Nrr2r3)r4r5r6keys)rFcr;s r(rz"ModifiedInterpreter.checklinecachesX O>>  C2A2wRSS!T))cF  r0c|jjr|dS|jr|jdd|fint ||jdS)z*Run the code without invoking the debuggerrrErr)rr;display_executing_dialogr!rrEr)rFrs r(rYzModifiedInterpreter.runcommandsj > #   ) ) + + +1 ; $ K # #FIw C C C C t{ # # #qr0c|jjr|||j} |j|s+|j$|jdd|fi|_n.|r|j ||j nt||j n#t$rH|jj s8tjddd|jjr|nYnt$rIt'd|jj ||jnH|jjr(d |j_t'd |jj n|YnxYwt$s- |jdS#t.$rYdSwxYwdS#t$s+ |jw#t.$rYwwxYwwxYw) Override base class methodNrErzExit?zDo you want to exit altogether?yesr rz IDLE internal error in runcode()rFrb)rr;rCrrbeginexecutingr! asyncqueuerarunrrE SystemExitrcr askyesnorJrrrerrjcanceledr")rFrrs r(rzModifiedInterpreter.runcodeso > # &  # # % % % =&  N ) ) + + + ( 7"&+"8"89=#E#E ( T4;////T4;'''   >) &5!>. 000) &&(((()( ) )8>02222""$$$++---->*).3DN+-DN4IJJJJJ&&(((! N//11111%DD  > N//1111%D sbA4B21G2AFGBFG)G GGH  G:9H : HH HH c@|jj|S)r)rrr!)rFrs r(r!zModifiedInterpreter.write-s~$**1---r0cHtjdd|jjdS)NzPort Binding ErroraAIDLE 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.rr rrrJrs r(r"z.ModifiedInterpreter.display_port_binding_error1s8  / >& ( ( ( ( ( (r0cHtjdd|jjdS)NzSubprocess 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-failurerrrs r(r,z/ModifiedInterpreter.display_no_subprocess_error<s9 ) J>&  ( ( ( ( ( (r0cHtjdd|jjdS)NzAlready executingzYThe Python Shell window is already executing a command; please wait until it is finished.rrrs r(rz,ModifiedInterpreter.display_executing_dialogDs6  0>&  ( ( ( ( ( (r0)Frb)FrC)&rrrrIrQr!rrrr2rCrMrOrSr:r.rar/rrsr7rvrhrrrrrrrrrrYrr!r"r,rrr0r(rrsCCCH FJDDD F F F)))V****XGGGBBB          J$C$C$CLH!!!   " C((( (HHH $ $ $4///   ,,,\... ( ( (((((((((r0rc XeZdZddlmZdezZeZe Z gdZ e j dgzZ deeejde zZe ed[d Zd Zdd lmZdd lmZd;dZfdZfdZdZdZdZd;dZ d Z!d Z"d Z#d Z$d Z%d Z&dZ'dZ(d;dZ)dZ*d;dZ+dZ,dZ-dZ.dZ/dZ0dZ1d Z2d!Z3d"Z4d#Z5d$Z6d%Z7d&Z8d'Z9d;d(Z:d)Z;d*Ze?j@d-ZAd.ZBd;d/ZCd;d0ZDd;d1ZEd2ZFd3ZGd4ZHd>rc|ddkS)Nrr\r) rmenu_items r(rzPyShell.ds:a=F2r0)zCopy with prompts<>r]Fr)History) ShellSidebarNc8tr/|j}|dddkr|ddt||_|@t }t ||t|}d|_ tj ||ddd|_ d|_ ttdr tjnd|_|jd d |_|j|_|j}|d |d |j|d|j|d|j|d|j|d|j|d|j|d|j|d|jtr6|d|j |d|j!|"||_#|d|j$tj%|_&tj'|_(tj)|_*ddl+m,}t[|d|j.|j/|_)ta|d|j.|j/|_%ta|d|j.d|_'ta|d|j.|j/|_1ts3|j%t_%|j't_'|j)t_) ddl2}|j3|_4n#tj5t_'xYw|6|j|_7d|_8|9||_ |j:j;j|j_|j:<t{dS)Nrrshell)rShe_llFps1z>>> rr2char)wrapz<>z<>z<>z<>z<><>r^rz<>z<>r)iomenurrrbackslashreplacer2)>r menu_specsrvrrrTkrwithdrawr shell_sidebarrrIusetabs indentwidthhasattrrrsys_ps1rprompt_last_linepromptrJ configurerKenter_callbacklinefeed_callbackcancel_callback eof_callbackrtoggle_debuggertoggle_jit_stack_viewercopy_with_prompts_callbackview_restart_mark restart_shellrsqueezersqueeze_current_text_eventr save_stdoutr save_stderrr save_stdinrrrencodingerrorsrrpydoc plainpagerpagerrirhistoryrlrperr insertfilterr)rFrNmsrrJrrs r(rIzPyShell.__init__rs  2B!uQx7"" !0111)$// =44D $    MMOOO#D))E!dE4666 ")#u"5"5Bsww7 $ 2 24 8 8 <l y F### *D,?@@@ 0$2HIII +T-ABBB #T%6777 )4+ABBB ')=>>> /1MNNN )4+JKKK  ? II($*@ A A A II)4+= > > > d++  ,1 3 3 3::)""""""!$"(/6=BB #D($*OV]DD #D($*O5GII $T9%+_fmEE  #CJCJ CI  LLL*EKK CJ ||DI.. !..t44  8<.  799:::::s ,M==Nct|j|jdSdSrC)r ResetFontr update_fontrFrs r(r zPyShell.ResetFontsE    )   * * , , , , , * )r0cttj}dddtj|dtj|dtj|dd}|D]\}}|jj|fi||j|j dSdS)N)rdrcrrr|)rrrr) rResetColorizerrrfrgitemsrJ tag_configurer update_colors)rFrj tag_colorsrtag_colors_configrs r(r zPyShell.ResetColorizers    %''"&d;;)%::)%::*5(;;   '1&6&6&8&8 > > "C" #DI #C = =+< = = = =   )   , , . . . . . * )r0c<tj|jddS)Nr) insert_tagsra)rrJrs r( replace_eventzPyShell.replace_events w7777wr0c,tjdS)NT) shell_only)r GetExtensionsrs r(get_standard_extension_namesz$PyShell.get_standard_extension_namess%6666r0cbj||}ttt |tt |}fd|D}ddt ||DdzS)z6Return text between first and last with prompts added.cNg|]!}jj|"Sr)r line_promptsget)rr'rFs r(r z+PyShell.get_prompt_text..s=      + / / 7 7   r0rc32K|]\}}||n|d|VdS)N r)rrrs r( z*PyShell.get_prompt_text..sP  NDD6(:(:D(:(:      r0)rJrrrxryrRzip splitlines)rFfirstlastrJ lineno_rangepromptss` r(get_prompt_textzPyShell.get_prompt_textsy}}UD)) e   d        &   yy  #GT__->-> ? ?       r0c0|j}|d}|dS|d}|ddkr|d}||||}||dS)aCopy 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. zsel.first linestartNsel.lastr20zsel.last+1line linestart)rJrnclipboard_clearr'clipboard_append)rFrzrJselfirstsellast prompt_texts r(rz"PyShell.copy_with_prompts_callbacksy::344   F**Z(( 2;#  jj!;< %  !2<y " " " "  ' ' ) ) )7((**B %##%%%%%""$$$$$r0ch|j}|d| dS)Nr)rrr7setvarrFr:s r(r7zPyShell.set_debugger_indicators4 [ $ $ & & )2v:66666r0cdSrCrrs r(rzPyShell.toggle_jit_stack_viewer"s r0c|j}|r|jd||jjrt j|jj||j d|j |_ | | dS)Nz [DEBUG OFF] )rrr7rsr9r!rclose_remote_debuggerrdrr!rrr?r7r=s r(r8zPyShell.close_debugger%s [ $ $ & &   K # #D ) ) ) HHJJJ{! E01CDDD       L   / / /,DK OO    ##%%%%%r0cP|jjr tj|jj|}nt j|}|j||d|jz|_ | | dS)Nz [DEBUG ON] ) rrr!rstart_remote_debuggerrDebuggerrsrArrr?r7)rFdbg_guis r(r9zPyShell.open_debugger2s ;  . 6t{7I;?AAGG'--G (((  """$t|3   ##%%%%%r0cJ|jrdnd}|dd|dS)Ndisabledr|rsz *tack*iewer)r;update_menu_state)rFstates r(debug_menu_postcommandzPyShell.debug_menu_postcommand>s0"n: ( w u=====r0c<|d|_dS)Helper for ModifiedInterpreterTN)rdr;rs r(rzPyShell.beginexecutingBs r0cJd|_d|_|dS)rKFN)r;rr?rs r(rjzPyShell.endexecutingGs&  r0c|jr#tjddd|j}|durdS|d|_d|_tj|S)zExtend EditorWindow.close()zKill?z7Your program is still running! Do you want to kill it?okrFcancelT) r;r askokcancelrJr<rrcrr9)rFrns r(r9z PyShell.closeMst > !-Jy """H 5  x   !$'''r0c>|tr|j|jt _|jt _|j t _ d|_d|_ d|j _ d|_tj|dS)zEExtend EditorWindow._close(), shut down debugger and execution serverN)r8rrrrSrrrrrrrrrNrqrrrrs r(rzPyShell._close\s   * K ' ' ) ) )% % O   !  D!!!!!r0cdS)z8Override EditorWindow method: never remove the colorizerTrrs r(ispythonsourcezPyShell.ispythonsourcelstr0c|jSrC) shell_titlers r( short_titlezPyShell.short_titleps r0zHType "help", "copyright", "credits" or "license()" for more information.c |jdd|tr4d}|j}|s|dSnd}tjt_| dtj dtj d|j d||j|d dl}d |_d|_d S) NrrvrbFz==== No Subprocess ==== WARNING: Running IDLE without a Subprocess is deprecated and will be removed in a later version. See Help/IDLE Help for details. zPython z on rrT)rJr=rdrrrr2r9r displayhookrr!versionplatform COPYRIGHT focus_forcer?tkinter_support_default_root _default_root)rFnosubclientr]s r(rz PyShell.beginvs 8X...   .E[1133F  u 'E"oCO KKKt~~~uuF G G G  (,% $tr0cX|jsdSd|_|jdSNT)reading_stop_readline_flagrquitrs r(r<zPyShell.stop_readlines,|  F#'   r0c~|j} d|_|j||_n #||_wxYw|jr d|_dS|jdd}t |dkrd}||jrd|_tst|j r d|_ d}|S)NTFrbrr4rr) rdrmainlooprerJrrrdrrrb endoffile)rFr:rs r(readlinezPyShell.readlines| DL H     DLL4DL      # ',D $2y}}Xx00 t99>>D  = (!DM! ('' > "DND s 1 :cdSrcrrs r(isattyzPyShell.isattystr0c |jdddrdSn#YnxYw|jsK|jsD||jd|dSd|_d|_ |jrX|jj rL|j r|j n|j |jr|jdS)N sel.firstz!=r)zKeyboardInterrupt raFT)rJrr;rdrdrrr!r?rirr!r7rCrOrrfrs r(rzPyShell.cancel_callbacks y  dJ??    D $,        K  3 4 4 4 OO   7 N 3t{1 3{&&(( 3 ..0000 00222 <  HMMOOOws!%cH|jr |jsdS|jdddr|jdddsdS|js)||n'd|_d|_|j dS)Nrz==rvr4FTra) r;rdrJrrdr9rrirrfrs r(rzPyShell.eof_callbacks > $,  F !!(D(;;  !!(D(;;  F~        JJLLLL!DM!DN HMMOOOwr0c|jr6|jdd|jdn||dS)Nrvrra)rdrJrvseenewline_and_indent_eventrs r(rzPyShell.linefeed_callbacksT < 1 I  Xt , , , IMM( # # # #  ) )% 0 0 0wr0c |jr |jsdS |jdd}|r4|jdddr|||dSn#YnxYw|jdddr|jd d}|rB|jdd|d rd |jdvr|jd d}|r8|j|d d |d r|d |d f}|jd d}|rS|j|d d|d r+|d |j |d dzf}||j|d |d |dS|jd d}|r|jdd |d r|jd d}|rS|j|d d|d r+|d |j |d dzf}||j|d |d |dS|jd d}|rX|j|d ddr6||j|d d|n/||jdd|dS|jdddr|j dd|jdd}|r/| s|j dd|jdddr| |dS|j dd|jr6|jdd|jdn| ||j|jr|jn|dS)Nrnr)z<=rrarvriomark linestartrrrz>=rz+1czinsert lineendr|r4zend-1c linestartr)r;rdrJrrrecall tag_prevrange tag_names tag_nextrangernr=striprrrrvrqupdate_idletasksrrfrunit) rFrzselprev prev_cons next_consnextindicesrs r(rzPyShell.enter_callbacks > $,  F )-- Z88C #9$$Zx@@#KKU+++"7  D 9  Xs,> ? ?"  9**7H==D I%%hT!W== TY%8%8%B%BBB I33IxHH 3!2!29Q<tAw!O!O3%aL$q'2D I33IxHH L!2!29Q<d1g!N!NL GTY__Yq\E5I%J%JKD DIMM$q'47;;UCCCw9**7H==D  ))*:D$q'JJ  I33I?OPP L!2!29Q<d1g!N!NL GTY__Yq\E5I%J%JKD DIMM$q'47;;UCCCwi--i9KLLG Xy  T3EFF X DIMM'!*6FGGOOOO DIMM*<>NOOQVWWW7 9  XsH 5 5 3 I  x 2 2 2 IMM(H - -  1QWWYY 1 I  Xx 0 0 0 9  Xs,> ? ?   ) )% 0 0 07 8X... < 1 I  Xt , , , IMM( # # # #  ) )% 0 0 0 ""$$$ <  HMMOOOO JJLLLws AA$$A(c tjdd|}tjdd|}|d}|j |jddd|jdd |jd d}| d r0| ||jd d}|j d|d  |j t|d krtjd|d d }tjd|d }|d dD]g}||r||t|dz}|j dd|z|j h|jd|jdS#|jd|jwxYw)Nz^\s*\nrbz\n\s*$rr|rrrvr4r|:rrz ^([ \t]*))resubrrJundo_block_startr~r=rrstripendswithrrrvryuser_input_insert_tagsrsearchgrouprrqundo_block_stop)rFrrzrprefixorig_base_indentnew_base_indentrs r(ruzPyShell.recall-sM F9b! $ $ F9b! $ $  ""$$$ ( I u 5 5 5 I  x 2 2 2Y]]#5x@@F}}'',, E--e444'98DD I  XuQx~~'7'7!8 : : :5zzA~~#%9\58#D#D#J#J1#M#M #%9\6#B#B#H#H#K#K!!""IBBD'788N.c:J6K6K6L6L1MMI$$Xtdkkmm/C%)%@BBBB IMM( # # # I % % ' ' ' ' ' IMM( # # # I % % ' ' ' 's F=I5Jz[ \t]*(\n[ \t]*)?\Zc|jd}|jdd}|jd|}|j|}|sY|j|dkr |j|j||j dSdS)Nend-2crr4rbr) rJrnr_last_newline_rerrrrr~rrupdate_sidebar)rF index_beforerinput_is_completes r(r{z PyShell.runitJsyx00 y}}Xx00$((T22 K11$77  0y}}\**d22 $$T%@,OOO   - - / / / / / 0 0r0c|jjr|jS tjn$#t jdd|jYdSxYwddlm }||j |j dS)NzNo stack tracez@There is no stack trace yet. (sys.last_traceback is not defined)rr) StackBrowser) rrr!rhrlast_tracebackr rrJidlelib.stackviewerrrrN)rFrzrs r(rzPyShell.open_stack_viewerVs ;  5;2244 4        !16y " " " " FF444444 TY +++++s 4Acn|jd|jddS)Nrr5)rJrqrs r(rzPyShell.view_restart_markds0 h i     r0c<|jddS)z&Callback for Run/Restart Shell Cntl-F6TrN)rrrCrs r(rzPyShell.restart_shellhs! &&&55555r0c||j}|jr7||jr|dt |j }|jdd|j||j |j dd| |j dS)Nrz iomark-1crvr4)rdrrrrrJrmrr!rrr=set_line_and_columnrU reset_undo)rFrs r(r?zPyShell.showpromptls  < 1FOODL99 1/c$,////0F )[111 6""" ))+++ 8X...   """ r0c|jjj}t|dd}d||}|ds|dz }|jj d|ddS)NT)rtabsize expand_tabsrrtr) rrrrr rRrrrbottomrv)rFrrwrapper wrapped_msgs r( show_warningzPyShell.show_warningzs %+E1$GGGii S 1 122 ##D)) 4 K 1;IIIIIr0c|jdd}|jr|j||jddkr|jdd|jdd||jdS)Nrr4rr) rJrrstorervr=rctipremove_calltip_window)rFrs r(rdzPyShell.resetoutputsx22 < ' L  v & & & 9== " "d * * I  Xt , , , 8X...   """ '')))))r0rc |jddtj|||d}|jddn#xYw|jrd|_t st |S)Nrrightr6F)rJr>rr!rrrb)rFrrcounts r(r!z PyShell.writes  I " "8W 5 5 5 &tQh??E I " "8V 4 4 4 4   = (!DM! ('' s A AAc |jdddrdSn#t$rYdSwxYwtS)NrnrrrF)rJrrrr[r s r(r[zPyShell.rmenu_check_cutsf y  c8<< "!z "   :: ww&&(((s " 00c|jdddrdStS)NrvrrrF)rJrrr_r s r(r_zPyShell.rmenu_check_pastes: 9  Xc( 3 3 :ww((***r0cj|j|jdSrC)rsqueeze_current_textrrrs r(rz"PyShell.squeeze_current_text_events1 **,,, ))+++++r0c8|jdSrC)rr)rFrnrJrs r(on_squeezed_expandzPyShell.on_squeezed_expands ))+++++r0rC)r)Orrridlelib.squeezerrr rUrrrrrrrrr6 itertools takewhile_idxrvallow_line_numbersridlelib.historyridlelib.sidebarrrIr r rrr'rrdr;rrircrer3r5rr7rr8r9rIrrjr9rrSrVr[rr<rjrlrrrrrurrrr{rrrr?rrdr!r[r_rrrrs@r(rrLs0)))))).."2"22K,N)MJ*/.K ss44+ +22KAA Dt2333 $(''''',,,,,,L;L;L;L;\----- ///// 777"++++(GIHIG    % % % %777     & & & & & &>>>  ( ( ("""     U4 .,   MMM^(((8"rz"899 0 0 0 , , , ,!!!!6666   JJJ***    )))))+++++ ,,,,,,,,,,,r0rc |jdkr3dD]2}||dd||dz1dSdS)z6Make paste replace selection on x11. See issue #5124.x11)TextEntrySpinboxz <>z%catch {%W delete sel.first sel.last} N)_windowingsystem bind_class)rclss r( fix_x11_pastersk %%- ; ;C OO8[99: ; ; ; ;&% ; ;r0a 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]. cddl}ddlm}ddlm}ddlm}t ddad}d}d}d}d}d} |tj ddd\} } nQ#|j $rD} td | d ttj tjd Yd} ~ nd} ~ wwxYw| D]\} }| d kr|}d}| dkrd}d}| dkrd}| dkr7tjttj| dkrd}| dkrtdtj da| dkrG|}t"j|rn#td|tjd}| dkrd} d}| dkr|t(_d}| r,| ddkr tj}d}t1t3tjD]>}t"jtj|tj|<?| r%| ddkrdg| ddzt_ n|rd g| zt_ n|r|g| zt_ n| rd}g}| D]4}|t"j|5|D]O}t"j|}|tjvr tjd|PnAt#j}|tjvr tjd|t?j dddd}|p|}|p| }tr|stCtEd a#tF$dd!l%m&}|tFt"j't"jtPd"|d#kr||s|r|j=?d/@tj |r|j=A|nd|r4|j=B||j=>|n-|r+|C}|r|D|t`jEr%tFFt`jE%tFGt ddS)0Nr)system)testing)macosxTFrz c:deihnr:st:zError: rrrrz-dz-ez-hz-iz-nz: Warning: running IDLE without a subprocess is deprecated.z-rzNo script file: z-sz-t-rbr r zeditor-on-startupr )rIdle) className) fix_scalingIconsWindowszidle.ico)r g333333!@z.png) 0z.gif)rrrcZg|]'}tjd|fz(S)z idle_%d%s)rPrQrR)rsizeexticondirs r(r zmain..YsB(((W\\';$+DEE(((r0c:g|]}tt|S))masterr) PhotoImager)riconfiles r(r zmain..[s5,,,4h777,,,r0 IDLESTARTUP PYTHONSTARTUPzdif 1: import sys as _sys _sys.argv = {!r} del _sys )HgetoptrZrrrrr/rrargverrorre usage_msgrexitrr!rPrQrrrUrrrrrrpdirnamervgetcwdrr NoDefaultRootrrr idlelib.runrrR__file__ wm_iconbitmapisAquaTk TkVersion wm_iconphotorrrrNsetupApprr}newrOdictrlowerrqr9environrrrrrYrZrrpreferTabsPreferenceWarningr inversedictrhdestroy)rrrr enable_shell enable_editrscmdscriptstartupoptsrYroar1pathxr&dir edit_startrrsizes iconfilesiconsrprefer_tabs_preference_warningrrs @@r(r r sMMMTNLK E C FG]]38ABB<@@ dd < ***y**<<<<    1 99CL 99EL 99K 99 J  Y ' ' ' HJJJ 99L 99 Nz # # # #"N 99Fw~~f%% (&111 L 99GL 99"#G L Q3inn 3sx== ! !33goochqk22  $Q34$qrr(? $6D= $8d? $  4 4H LL22 3 3 3 3 ( (C'//#&&C#(??3''' ( ikk ch   HOOAs # # ##FI$7fFFFJ+K2{?Lg    DMMOOO''''''Kgll27??844g>>G vxx97<<44 8,,,, __   (   C%EEC E(((((!&((( ,,!*,,, $'''''$$ D ! !E OOD%    v  G * *::h''/KK)))     ""  F ??     IOO      ,:>>-003:>>/22   ,x00 , L ! !( + + + ?f? !&""  $ $ $  * L # #C ( ( ( (  * L ( ( 0 0 0 L ! !& ) ) )  ?*0)K)K)M)M& ) ?   = > > >     LLNNNUs+A## B1-:B,,B1)NN)Rrrrr] ImportErrorrerirrZctypesPROCESS_SYSTEM_DPI_AWAREOleDLLSetProcessDpiAwarenessr"r#r rr rr4rPos.pathr rr&rtextwrapr rKrrr,idlelib.colorizerridlelib.configridlelib.delegatorrrrridlelib.editorrridlelib.filelistridlelib.outwinrrrrrrr idlelib.undorrrreofrrf NameErrorr r)r+r/ checkcacher<r>rrrr RPCClientrrrrrrr rr0r(rs:  z%([%B    " ) ) )+/2;2F(5 {"{"{"{"{",{"{"{"|h( 2 2 2 2 2^ 2 2 2/////M///D11111 111#-   j(j(j(j(j(0j(j(j(Z ` ,` ,` ,` ,` ,l` ,` ,` ,F;;;4  lnnn` zDFFFs-&#A )BB  B )D::EE