o ­=?höã @s,ddlZedkrejdejd<zddlTWney(edejdedƒ‚wejdkrKzddl Z dZ e   d ¡  e ¡Wn ee efyJYnwdd lmZed krteƒat ¡dd lmZetƒejd detdedƒ‚ddlmZddlZddlZddlZddlZddlmZddlZddlZddl Z ddl!m"Z"ddl#Z#ddl$Z$ddl%Z%ddl&Z&ddl'm(Z(ddl)m*Z*ddl+m,Z,ddl-m.Z.ddl-m/Z/ddl0m1Z1m2Z2ddl3m4Z4ddl5m6Z6ddl-m7Z7ddl-m8Z8ddlm9Z9m:Z:m;Z;ddld Z?dZ@z d!ZAeAeB_AeAeC_AWn eDyYnwejaE d@d"d#„ZFdaGd$d%„ZHeHd&ƒdejIfd'd(„ZJeJe_IGd)d*„d*e1ƒZKGd+d,„d,e4ƒZLGd-d.„d.e(ƒZMGd/d0„d0e=ƒZNGd1d2„d2e,ƒZOGd3d4„d4e8jPƒZQd5d6„ZRGd7d8„d8eƒZSGd9d:„d:e6ƒZTd;d<„ZUd=ZVd>d?„ZWedkreWƒeHdƒdS)AéNÚ__main__zidlelib.pyshell)Ú*zJ** IDLE can't import Tkinter. Your Python may not be configured for Tk. **©ÚfileéZwin32Zshcore)Ú messageboxg!@©Ú fix_scalingzIdle Cannot Startz"Idle requires tcl/tk 8.5+, not %s.©Úparent)ÚInteractiveInterpreter)Úpython_version)Ú TextWrapper)ÚColorDelegator)ÚidleConf)Ú Delegator©Údebugger)Ú debugger_r)Ú EditorWindowÚ fixwordbreaks)ÚFileList)Ú OutputWindow)Úreplace)Úrpc)Úidle_formatwarningÚ StdInputFileÚ StdOutputFile)Ú UndoDelegatorFz 127.0.0.1zCtrl-D (end-of-file)c CsN|durt}z| t|||||d¡| d¡WdSttfy&YdSw)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_streamÚwriterÚAttributeErrorÚOSError)ÚmessageÚcategoryÚfilenameÚlinenorr©r(ú6/opt/alt/python310/lib64/python3.10/idlelib/pyshell.pyÚidle_showwarningRs ÿÿr*cCs:|rtdurtjatt_dSdStdurtt_dadSdS)z>Replace warning.showwarning with idle_showwarning, or reverse.N)Ú_warnings_showwarningÚwarningsÚ showwarningr*)Zcapturer(r(r)Úcapture_warningses þþr.TcCsXtj}i}t|ƒD]}|dd…|dd…dkr | |¡||<q ||ƒ| |¡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éÿÿÿÿú<>)Ú linecacheÚcacheÚlistÚpopÚupdate)r&Zorig_checkcacher2ÚsaveÚkeyr(r(r)Úextended_linecache_checkcachets  €r8c@sveZdZdZdd„Zgd¢Zddd„Zdd „Zdd d „Zdd d„Z dd„Z dd„Z dd„Z dd„Z dd„Zdd„Zd S)ÚPyShellEditorWindowz6Regular text edit window in IDLE, supports breakpointscGs–g|_tj|g|¢RŽ|j d|j¡|j d|j¡|j d|jj¡t j   t j d¡|_|jj|fdd„}|j |¡|jjrE| ¡| ¡dS)Nú<>ú<>z<>zbreakpoints.lstcSs| ¡|ƒdS©N)Úrestore_file_breaks)Zold_hookÚselfr(r(r)Úfilename_changed_hook™ó z;PyShellEditorWindow.__init__..filename_changed_hook)Ú breakpointsrÚ__init__ÚtextÚbindÚset_breakpoint_hereÚclear_breakpoint_hereÚflistÚ open_shellÚosÚpathÚjoinrZuserdirÚbreakpointPathÚioZfilename_change_hookZset_filename_change_hookr&r=Úcolor_breakpoint_text)r>Úargsr?r(r(r)rBŽsÿ ÿ  zPyShellEditorWindow.__init__))ZCutz<>Úrmenu_check_cut)ÚCopyz<>Úrmenu_check_copy)ZPastez <>Úrmenu_check_paste)NNN)zSet Breakpointr:N)zClear Breakpointr;NTcCsD|jdurdS|rt ¡}t |d¡}ndddœ}|j d|¡dS)z,Turn colorizing of breakpoint text on or offNÚbreakÚ)Ú foregroundÚ backgroundÚBREAK)rMrÚ CurrentThemeÚ GetHighlightrCZ tag_config)r>ZcolorÚthemeZcfgr(r(r)rN«s  z)PyShellEditorWindow.color_breakpoint_textcCs„|j}|jj}| dd|d|d¡z|j |¡Wnty+|j |¡Ynwz|jj j j }|  ||¡WdSYdS)NrXz%d.0r) rCrMr&Útag_addrAÚindexÚ ValueErrorÚappendrGÚpyshellÚinterprrE)r>r'rCr&Údebugr(r(r)Úset_breakpoint·s ÿ z"PyShellEditorWindow.set_breakpointNcCs>|j}|jj}|s| ¡dStt| d¡ƒƒ}| |¡dS)NÚinsert)rCrMr&ÚbellÚintÚfloatr]rc)r>ÚeventrCr&r'r(r(r)rEÅsz'PyShellEditorWindow.set_breakpoint_herecCs„|j}|jj}|s| ¡dStt| d¡ƒƒ}z|j |¡WnY|  ddd¡z|j j j j }| ||¡WdSYdS)NrdrXúinsert linestartzinsert lineend +1char)rCrMr&rerfrgr]rAÚremoveÚ tag_removerGr`rarrF)r>rhrCr&r'rbr(r(r)rFÎs$ÿ z)PyShellEditorWindow.clear_breakpoint_herecCsf|jr1|j}|jj}|s| ¡dSg|_| ddt¡z|jjj j }|  |¡WdSYdSdS)NrXú1.0) rArCrMr&rerkZENDrGr`rarÚclear_file_breaks)r>rCr&rbr(r(r)rmás ôz%PyShellEditorWindow.clear_file_breaksc CsZ|j}|jj}zt|jdƒ }| ¡}Wdƒn1swYWn ty.g}YnwzKt|jdƒ:}|D]}| |d¡sG| |¡q9|  ¡|j}|rg| |dt |ƒd¡WdƒWdSWdƒWdS1sswYWdSty¬}z&t |j ddƒs¡d|j _ tjd d t |ƒ|jd WYd}~dSWYd}~dSd}~ww) z#Save breakpoints when file is savedÚrNÚwú=Ú Úbreakpoint_error_displayedFTz IDLE Errorz$Unable to update breakpoint list: %s)Útitler$r )rArMr&ÚopenrLÚ readlinesr#Ú startswithr!Úupdate_breakpointsÚstrÚgetattrÚrootrrrÚ showerrorrC)r>Zbreaksr&ÚfpÚlinesZnew_filerÚerrr(r(r)Ústore_file_breaksðsF ÿ€ ÿ €ù&úÿýþ€ÿz%PyShellEditorWindow.store_file_breakscCsº|j ¡|jdur dS|jj}|durdStj |j¡rYt|jdƒ }|  ¡}Wdƒn1s2wY|D]!}|  |d¡rXt |t |ƒdd…ƒ}|D]}|  |¡qPq9dSdS)Nrnrpr)rCr5rMr&rIrJÚisfilerLrtrurvÚevalÚlenrc)r>r&r|r}rZbreakpoint_linenumbersZbreakpoint_linenumberr(r(r)r=s$   ÿ €ùz'PyShellEditorWindow.restore_file_breakscCs$|j}| d¡}| |¡}||_dS)z3Retrieves all the breakpoints in the current windowrXN)rCZ tag_rangesÚranges_to_linenumbersrA)r>rCÚrangesZlinenumber_listr(r(r)rw+s   z&PyShellEditorWindow.update_breakpointscCshg}tdt|ƒdƒD]'}tt||jƒƒ}tt||djƒƒ}||kr1| |¡|d7}||ks$q |S)Nrér)Úranger‚rfrgÚstringr_)r>r„r}r]r'Úendr(r(r)rƒ2s þ€z)PyShellEditorWindow.ranges_to_linenumberscCs| ¡t |¡dS)z7Extend base method - clear breaks when module is closedN)rmrÚ_close©r>r(r(r)r‰CszPyShellEditorWindow._close)Tr<)Ú__name__Ú __module__Ú __qualname__Ú__doc__rBÚ rmenu_specsrNrcrErFrmrr=rwrƒr‰r(r(r(r)r9‹s   * r9c@s"eZdZdZeZdZddd„ZdS)ÚPyShellFileListz8Extend base class: IDLE supports a shell and breakpointsNcCs<|jr |jj ¡|jSt|ƒ|_|jr|j ¡sdS|jSr<)r`ÚtopÚwakeupÚPyShellÚbegin©r>rhr(r(r)rHRs  ü zPyShellFileList.open_shellr<)r‹rŒrrŽr9rr`rHr(r(r(r)rIs rc@s eZdZdZdd„Zdd„ZdS)ÚModifiedColorDelegatorz8Extend base class: colorizer for the shell window itselfcCs*| ddd¡| ddd¡t |¡dS)NZTODOrlÚiomarkZSYNC)rkr\rÚrecolorize_mainrŠr(r(r)r˜_sz&ModifiedColorDelegator.recolorize_maincCs|jD] }| |dd¡qdS)Nr—rˆ)Ztagdefsrk)r>Útagr(r(r)Ú removecolorsds ÿz#ModifiedColorDelegator.removecolorsN)r‹rŒrrŽr˜ršr(r(r(r)r–]s r–cs4eZdZdZd dd„Zd dd„Z‡fdd„Z‡ZS) ÚModifiedUndoDelegatorz;Extend base class: forbid insert/delete before the I/O markNcCsLz|j |dd¡r|j ¡WdSWn tyYnwt ||||¡dS©Núr]ÚcharsÚtagsr(r(r)rdls þ ÿzModifiedUndoDelegator.insertcCsJz|j |dd¡r|j ¡WdSWn tyYnwt |||¡dSrœ)ržrŸrer rÚdelete)r>Zindex1Zindex2r(r(r)r¤us þ ÿzModifiedUndoDelegator.deletecs>|jj‰‡fdd„|j_z tƒ |¡Wˆ|j_dSˆ|j_w)Ncs ˆ||dƒS©NÚstdinr()r]r¢©Z orig_insertr(r)Ú…ó z2ModifiedUndoDelegator.undo_event..)ržrdÚsuperÚ undo_eventr•©Ú __class__r§r)r«~s  ÿz ModifiedUndoDelegator.undo_eventr<)r‹rŒrrŽrdr¤r«Ú __classcell__r(r(r¬r)r›js    r›c@seZdZdZddd„ZdS)ÚUserInputTaggingDelegatorz.Delegator used to tag user input with "stdin".NcCs |durd}|j |||¡dSr¥)ržrdr¡r(r(r)rdŽsz UserInputTaggingDelegator.insertr<)r‹rŒrrŽrdr(r(r(r)r¯Œsr¯c@seZdZdd„ZdS)Ú MyRPCClientcCst‚)z0Override the base class - just re-raise EOFError)ÚEOFErrorrŠr(r(r)Ú handle_EOF–ózMyRPCClient.handle_EOFN)r‹rŒrr²r(r(r(r)r°”s r°cCsZd|pd›d}|t|ƒkr't|t|ƒdƒ\}}||d›|›|d›S|dd…S)z¹Return 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: ZShellz =r…rpNéþÿÿÿ)r‚Údivmod)Úwidthr&r™ZdivÚmodr(r(r)Ú restart_linešs   r¸c@seZdZdd„ZdZdZdZdd„Zdd„Zdd „Z d?d d „Z dd„Z dd„Z dd„Z dd„Zd@dd„ZdZdd„ZdZdd„Zdd„Zdd„Zd d!„Zd"Zd#d$„ZdAd%d&„Zd'd(„Zd)d*„Zd+d,„ZdAd-d.„Zd/d0„Zd1d2„Zd3d4„Z d5d6„Z!d7d8„Z"d9d:„Z#d;d<„Z$d=d>„Z%dS)BÚModifiedInterpretercCsB||_tjdj}tj||dd|_d|_t|_ |j j j |_ dS)Nr)ÚlocalsF)Ú tkconsoleÚsysÚmodulesÚ__dict__r rBÚ restartingÚsubprocess_arglistÚPORTÚportÚcompileÚcompilerÚflagsÚoriginal_compiler_flags)r>r»rºr(r(r)rBªs zModifiedInterpreter.__init__NcCs&|jdur | ¡|_t |j¡|_dSr<)rÀÚbuild_subprocess_arglistÚ subprocessÚPopenÚ rpcsubprocrŠr(r(r)Úspawn_subprocess·s  z$ModifiedInterpreter.spawn_subprocesscCs\|jdks Jdƒ‚dd„tjDƒ}tjddddd d }d |f}tjg|d |t|jƒgS) Nrz/Socket should have been assigned a port number.cSsg|]}d|‘qS)z-Wr()Ú.0Úsr(r(r)Ú ¿sz@ModifiedInterpreter.build_subprocess_arglist..ÚmainÚGeneralzdelete-exitfuncFÚbool)ÚdefaultÚtypez&__import__('idlelib.run').run.main(%r)ú-c)rÂr¼Ú warnoptionsrÚ GetOptionÚ executablerx)r>roZ del_exitfZcommandr(r(r)rǼs ÿ ÿ z,ModifiedInterpreter.build_subprocess_arglistc CsPt|jf}tdƒD]}t |¡zt|ƒ|_Wnty!Yq w| ¡dS|jj   ¡d|_t dkr@|jj   t jt jd¡| ¡|jj  d¡z|j ¡Wnty`| ¡YdSw|j d|j¡|j d|jj¡|j d|jj¡|j d|jj¡|j d |jj¡|j d t¡|j d |¡|jd d | ¡|jS)Nérré Úconsoler¦ÚstdoutÚstderrrGr1raT©Úwith_cwd)ÚHOSTrÂr†ÚtimeÚsleepr°Úrpccltr#Údisplay_port_binding_errorÚlistening_sockZ getsocknamerÁZ setsockoptÚsocketZ SOL_SOCKETZ SO_REUSEADDRrËZ settimeoutÚacceptÚ TimeoutErrorÚdisplay_no_subprocess_errorÚregisterr»r¦rÛrÜrGr1Ú transfer_pathÚpoll_subprocess)r>ZaddrÚir(r(r)Ústart_subprocessÈsD     ÿ ÿ þ z$ModifiedInterpreter.start_subprocessFrUcCs&|jr|jSd|_| ¡}|rzt |j¡WnY|j ¡| ¡|j}|j}d|_|  ¡z|j  ¡Wnt yG|  ¡YdSw|j |d| ¡|j dd¡| d¡| t|j|ƒ¡|j dd¡|j dd¡|s{| ¡|r‡t |j¡| ¡|j|jj_d|_|jS) NTFrÝr—úend-1crqÚrestartÚleft)r¿râÚ getdebuggerrZclose_subprocess_debuggerÚcloseÚterminate_subprocessr»Ú executingrËrærçrèrêÚ stop_readlinerCr¤r!r¸r¶Úmark_setÚ mark_gravityÚ showpromptZrestart_subprocess_debuggerÚload_breakpointsrÆrÃrÄrÅ)r>rÞr&rbrÚZ was_executingr(r(r)Úrestart_subprocessósH  þ    z&ModifiedInterpreter.restart_subprocesscCs|j dddi¡dS)NÚexecZinterrupt_the_serverr()râZ remotecallrŠr(r(r)Z__request_interruptóz'ModifiedInterpreter.__request_interruptcCstj|jd ¡dS)N)Útarget)Ú threadingZThreadÚ'_ModifiedInterpreter__request_interruptÚstartrŠr(r(r)Úinterrupt_subprocess"rüz(ModifiedInterpreter.interrupt_subprocesscCsz|jdur |jj |j¡z|jj ¡Wn tyYnwz|j ¡Wn ty/Ynw| ¡d|j_ d|_dS)NF) Ú_afteridr»rCZ after_cancelrâräròr"rórôrŠr(r(r)Úkill_subprocess%s  ÿ ÿ z#ModifiedInterpreter.kill_subprocesscCsJz|j ¡Wn tyYdSwz|j ¡WdSty$YdSw)z"Make sure subprocess is terminatedN)rÊÚkillr#ÚwaitrŠr(r(r)ró4s þ ÿz(ModifiedInterpreter.terminate_subprocesscCs2|r dg}| tj¡ntj}| d|f¡dS)NrUzRif 1: import sys as _sys _sys.path = %r del _sys )Úextendr¼rJÚ runcommand)r>rÞrJr(r(r)rêAs üz!ModifiedInterpreter.transfer_pathc Cs2|j}|dur dSz |j|jdd}Wntttfy,|jjr$YdSd}| ¡Ynw|r…|j  ¡d|_|\}}|jj }|dkrP|durOt t |ƒ|dn$|dkr_|j  d¡r^| ¡n|dkrtd}t ||tjdt |||dz|j ¡Wn ty„Ynw|jjs—|jj |jj|j¡|_dSdS) Ngš™™™™™©?)rZOKrZ EXCEPTIONú<>ÚERRORz/pyshell.ModifiedInterpreter: Subprocess ERROR: )râZ pollresponseÚ active_seqr±r#ÚKeyboardInterruptr»ÚclosingrúÚ resetoutputrÚÚprintÚreprÚgetvarÚremote_stack_viewerr¼Ú __stderr__Ú endexecutingr"rCÚafterÚ pollintervalrër)r>ZcltÚresponseZhowZwhatrÚÚerrmsgr(r(r)rëPsL ú € € ÿ  ÿÿz#ModifiedInterpreter.poll_subprocesscCs ||_dSr<r)r>rr(r(r)Ú setdebuggerxs zModifiedInterpreter.setdebuggercCó|jSr<rrŠr(r(r)rñ{ózModifiedInterpreter.getdebuggercCs|jj d|j¡dS)a’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»rCrrrŠr(r(r)Úopen_remote_stack_viewer~s z,ModifiedInterpreter.open_remote_stack_viewerc Cs°ddlm}|j dddi¡}|dur|jj ¡dS| |j|¡}ddlm }m }t |jjƒ}t   ¡}t  |d¡d}|||dd } | jjd d d || jd|ƒ} |  ¡dS) Nr)Ú debugobj_rrûZ stackviewer)rG)ÚScrolledCanvasÚTreeNodeÚnormalrW)ZbgZhighlightthicknessrZboth)ÚexpandZfill)ÚidlelibrrâÚ remotequeuer»rzreZStubObjectTreeItemZ idlelib.treerrZToplevelrrYrZÚframeZpackZcanvasr ) r>rZoidÚitemrrr‘r[rWZscZnoder(r(r)r‹s    z'ModifiedInterpreter.remote_stack_viewerrcCs| |¡}| ||¡dS)z1Like runsource() but assumes complete exec sourceN)Ú stuffsourceÚexecfile©r>Úsourcer&r(r(r)Ú execsourcežs zModifiedInterpreter.execsourcec CsÂ|dur-t |¡}| ¡}trdtj |¡›d|d}Wdƒn1s(wYzt||dƒ}Wn$tt fyY|j   ¡t d|j j dt ||¡|j  ¡YdSw| |¡dS)zExecute an existing fileNz__file__ = r'''z''' z del __file__rûzB*** Error in script or command! Traceback (most recent call last):r)ÚtokenizertÚreadÚuse_subprocessrIrJÚabspathrÃÚ OverflowErrorÚ SyntaxErrorr»r rrÜr ÚshowsyntaxerrorrøÚruncode)r>r&r(r|Úcoder(r(r)r&£s, ÿÿ€ý þ úzModifiedInterpreter.execfilecCs&| |¡}t|tƒs J‚t |||¡S)zBExtend base class method: Stuff the source in the line cache first)r%Ú isinstancerxr Ú runsourcer'r(r(r)r4·s zModifiedInterpreter.runsourcecCs>d|j}|jd|_| d¡}t|ƒdd||ftj|<|S)z"Stuff source in the filename cachez rrqr)ÚgidÚsplitr‚r1r2)r>r(r&r}r(r(r)r%Às   zModifiedInterpreter.stuffsourcecCs| d|f¡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)r©r>r&r(r(r)Úprepend_syspathÈs øz#ModifiedInterpreter.prepend_syspathc CsÄ|j}|j}| ddd¡t ¡\}}}t|ddƒp|pd}t|ddƒp%d}t|d dƒp-d } | d kr6|d7}|dkrAd | d} n d |d| df} | || ¡| ¡| d |¡|  ¡dS)z§Override Interactive Interpreter method: Use Colorizing Color the offending position instead of printing it and pointing at it with a caret. r rlrˆÚmsgrUzr'rÚoffsetrziomark + %d charsz&iomark linestart + %d lines + %d charszSyntaxError: %s N) r»rCrkr¼Úexc_inforyZcolorize_syntax_errorr r!rø) r>r&r»rCrÓÚvalueÚtbr9r'r:Úposr(r(r)r0Ôs$ÿ  z#ModifiedInterpreter.showsyntaxerrorcCs:|j ¡| ¡t |¡|j d¡r|j ¡dSdS)z1Extend base class method to reset output properlyrN)r»r Úchecklinecacher Ú showtracebackrÚopen_stack_viewerrŠr(r(r)r@îs   ÿz!ModifiedInterpreter.showtracebackcCs>tj}t| ¡ƒD]}|dd…|dd…dkr||=q dS)Nrr/r0)r1r2r3Úkeys)r>Úcr7r(r(r)r?ös €þz"ModifiedInterpreter.checklinecachecCsB|jjr | ¡dS|jr|j dd|fi¡dSt||jƒdS)z*Run the code without invoking the debuggerrrûr1r)r»rôÚdisplay_executing_dialogrâr"rûrº)r>r2r(r(r)rüs ÿzModifiedInterpreter.runcommandcCsd|jjr| ¡| ¡|j}zŽz*|j ¡|s)|jdur)|j dd|fi¡|_n|r3|  ||j ¡nt ||j ƒWnKt yY|jj sVtjddd|jjdrQ‚| ¡n‚Yn-trptd|jjd | ¡|j ¡n|jjrd |j_td |jjd n| ¡YWtsœz|j ¡WdSty›YdSwdSts±z|j ¡Wwty°Ywww) úOverride base class methodNrûr1zExit?zDo you want to exit altogether?Zyes©rÒr z IDLE internal error in runcode()rFr )r»rôrúr?rÚbeginexecutingrâZ asyncqueuer ÚrunrºrûÚ SystemExitr rZaskyesnorCr@r,rrÜrÚcanceledr")r>r2rr(r(r)r1sf  ÿ € ü þÿ € ÿý ÿýzModifiedInterpreter.runcodecCs|jj |¡S)rE)r»rÜr!)r>rÍr(r(r)r!6szModifiedInterpreter.writecCótjdd|jjddS)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.r ©rr{r»rCrŠr(r(r)rã:s  øz.ModifiedInterpreter.display_port_binding_errorcCrK)NzSubprocess Connection Errorz¢IDLE'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 rLrŠr(r(r)rèEs  ûz/ModifiedInterpreter.display_no_subprocess_errorcCrK)NzAlready executingzYThe Python Shell window is already executing a command; please wait until it is finished.r rLrŠr(r(r)rDMs  üz,ModifiedInterpreter.display_executing_dialog)FrU)Fr<)&r‹rŒrrBrrârÊrËrÇrírúrÿrrrórêr rërrrñrrr5r)r&r4r%r8r0r@r?rr1r!rãrèrDr(r(r(r)r¹¨sH  +,  &     . r¹cs&eZdZddlmZdeƒZeZe Z gd¢Z e j dgZ deee dd„e ¡ƒƒZe  ed ¡[d Zd Zdd lmZdd lmZdfdd„Z‡fdd„Z‡fdd„Zdd„Zdd„Zdd„Zdfdd„Z d Z!d Z"d Z#d Z$d Z%d Z&dd„Z'dd „Z(dfd!d"„Z)d#d$„Z*dfd%d&„Z+d'd(„Z,d)d*„Z-d+d,„Z.d-d.„Z/d/d0„Z0d1d2„Z1d3d4„Z2d5d6„Z3d7d8„Z4d9Z5d:d;„Z6dd?„Z8d@dA„Z9dfdBdC„Z:dDdE„Z;dFdG„Ze? @dL¡ZAdMdN„ZBdfdOdP„ZCdfdQdR„ZDdfdSdT„ZEdUdV„ZFdWdX„ZGdYdZ„ZHdgd\d]„ZI‡fd^d_„ZJ‡fd`da„ZKdfdbdc„ZLddde„ZM‡ZNS)hr“r)ÚSqueezerz IDLE Shell ))rZ_File)ZeditZ_Edit)rbZ_Debug)ZoptionsZ_Options)ZwindowZ_Window)ÚhelpZ_Help)ZSqueezeú<>rcCs |ddkS)NrrQr()Z rmenu_itemr(r(r)r¨mr©zPyShell.)zCopy with promptsú<>rRFr¦)ÚHistory)Ú ShellSidebarNcCsXtr|j}|dddkr| dd¡t|ƒ|_|dur+tƒ}t|ƒ| ¡t|ƒ}d|_ t   ||dd¡d|_ d|_ ttdƒrDtjnd|_|j d ¡d |_|j|_|j}|jd d | d |j¡| d|j¡| d|j¡| d|j¡| d|j¡| d|j¡| d|j¡| d|j¡tr¥| d|j ¡| d|j!¡| "|¡|_#| d|j$¡tj%|_&tj'|_(tj)|_*ddl+m,}t-|d|j.|j/ƒ|_)t0|d|j.|j/ƒ|_%t0|d|j.dƒ|_'t0|d|j.|j/ƒ|_1tsù|j%t_%|j't_'|j)t_)z ddl2}|j3|_4Wntj5t_'‚| 6|j¡|_7d|_8| 9|¡|_ |j:j;j|j_|j: >> rqr/Úchar)Úwrapz<>z<>z<>z<>z<>ú<>rrPz<>z<>rO)Úiomenur¦rÛrÜÚbackslashreplacerÚé2)>r,Ú menu_specsrdr¹raÚTkrÚwithdrawrÚ shell_sidebarrrBZusetabsZ indentwidthÚhasattrr¼rUÚsys_ps1r6Zprompt_last_lineÚpromptrCZ configurerDÚenter_callbackÚlinefeed_callbackÚcancel_callbackÚ eof_callbackrAÚtoggle_debuggerÚtoggle_jit_stack_viewerÚcopy_with_prompts_callbackÚview_restart_markÚ restart_shellrMÚsqueezerÚsqueeze_current_text_eventrÛÚ save_stdoutrÜÚ save_stderrr¦Ú save_stdinr!rYrÚencodingÚerrorsrrÚÚpydocZ plainpagerZpagerrrQÚhistoryrrRÚperr‘Z insertfilterr¯)r>rGZmsrzrCrYrsr(r(r)rB{s‚    ÿ ÿÿÿÿ  zPyShell.__init__cs&tƒ ¡|jdur|j ¡dSdSr<)rªÚ ResetFontr_Z update_fontrŠr¬r(r)rvÉs  ÿzPyShell.ResetFontcs€tƒ ¡t ¡}dddœt |d¡t |d¡t |d¡dœ}| ¡D]\}}|jj|fi|¤Žq#|jdur>|j  ¡dSdS)N)rWrVrÛrÜr)r¦rÛrÜrÚ) rªÚResetColorizerrrYrZÚitemsrCZ tag_configurer_Z update_colors)r>r[Z tag_colorsr™Ztag_colors_configr¬r(r)rwÏs    ü ÿzPyShell.ResetColorizercCstj|jdddS)Nr¦)Z insert_tagsrT)rrCr•r(r(r)Ú replace_eventßszPyShell.replace_eventcCs tjddS)NT)Z shell_only)rZ GetExtensionsrŠr(r(r)Úget_standard_extension_namesãs z$PyShell.get_standard_extension_namescs\ˆj ||¡}ttt|ƒƒtt|ƒƒƒ}‡fdd„|Dƒ}d dd„t|| ¡ƒDƒ¡dS)z6Return text between first and last with prompts added.csg|] }ˆjj |¡‘qSr()r_Z line_promptsÚget)rÌr'rŠr(r)rÎís ÿÿz+PyShell.get_prompt_text..rqcss.|]\}}|dur |n|›d|›VqdS)Nú r()rÌrbrr(r(r)Ú ñs €ÿ ÿz*PyShell.get_prompt_text..)rCr{r†rfrgrKÚzipÚ splitlines)r>ÚfirstZlastrCZ lineno_rangeZpromptsr(rŠr)Úget_prompt_textæs  þ þ  þýzPyShell.get_prompt_textcCs^|j}| d¡}|durdS| 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 linestartNúsel.lastr/Ú0zsel.last+1line linestart)rCr]Zclipboard_clearrZclipboard_append)r>rhrCZselfirstZsellastZ prompt_textr(r(r)ri÷s     z"PyShell.copy_with_prompts_callbackcCs|adSr<©r )r>Ústreamr(r(r)Úset_warning_streamszPyShell.set_warning_streamcCstSr<r„rŠr(r(r)Úget_warning_streamózPyShell.get_warning_streamcCsJ|jrtjdd|jd| ¡dS|j ¡}|r| ¡dS| ¡dS)NzDon't debug nowz*You can only toggle the debugger when idler rT) rôrr{rCÚset_debugger_indicatorrarñÚclose_debuggerÚ open_debugger)r>rhÚdbr(r(r)rgsþ   zPyShell.toggle_debuggercCs|j ¡}| d| ¡dS)NrX)rarñZsetvar©r>rŒr(r(r)r‰'s zPyShell.set_debugger_indicatorcCsdSr<r(r•r(r(r)rh+rˆzPyShell.toggle_jit_stack_viewercCsh|j ¡}|r.|j d¡| ¡|jjrt |jj¡| ¡|j  d¡|j |_ |  ¡|  ¡dS)Nz [DEBUG OFF] )rarñrròrârZclose_remote_debuggerr rÚr!rarbrør‰rr(r(r)rŠ.s    zPyShell.close_debuggercCsX|jjr t |jj|¡}nt |¡}|j |¡| ¡d|j|_ |  ¡|  ¡dS)Nz [DEBUG ON] ) rarârZstart_remote_debuggerrZDebuggerrrùrarbrør‰)r>Zdbg_guir(r(r)r‹;s ÿ    zPyShell.open_debuggercCs |jrdnd}| dd|¡dS)NÚdisabledrrbz *tack*iewer)rôZupdate_menu_state)r>Ústater(r(r)Údebug_menu_postcommandGszPyShell.debug_menu_postcommandcCs| ¡d|_dS)úHelper for ModifiedInterpreterTN)r rôrŠr(r(r)rGKr@zPyShell.beginexecutingcCsd|_d|_| ¡dS)r‘FN)rôrJrørŠr(r(r)rPs zPyShell.endexecutingcCsD|jrtjddd|jd}|durdS| ¡d|_d|_t |¡S)zExtend EditorWindow.close()zKill?z7Your program is still running! Do you want to kill it?ÚokrFFZcancelT) rôrZ askokcancelrCrõrJr rrò)r>rr(r(r)ròVsü z PyShell.closecCsV| ¡tr |j ¡|jt_|jt_|j t_ d|_d|_ d|j _ d|_t |¡dS)zEExtend EditorWindow._close(), shut down debugger and execution serverN)rŠr,rarrnr¼rÛrorÜrpr¦rÚrGr`rtrr‰rŠr(r(r)r‰es zPyShell._closecCódS)z8Override EditorWindow method: never remove the colorizerTr(r7r(r(r)Úispythonsourceur³zPyShell.ispythonsourcecCrr<)Ú shell_titlerŠr(r(r)Ú short_titleyrzPyShell.short_titlezHType "help", "copyright", "credits" or "license()" for more information.cCsŒ|j dd¡| ¡trd}|j ¡}|s| ¡dSnd}tjt _|  dt j t j |j |f¡|j ¡| ¡ddl}d|_d|_dS) Nr—rdrUFz›==== 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 %s on %s %s %srT)rCrör r,raríròrÚ displayhookr¼r!ÚversionÚplatformÚ COPYRIGHTZ focus_forcerøÚtkinterZ_support_default_rootZ _default_root)r>ZnosubZclientr›r(r(r)r”s( þÿ z PyShell.begincCs|jsdSd|_|j ¡dS©NT)ÚreadingÚ_stop_readline_flagr‘ÚquitrŠr(r(r)rõ™szPyShell.stop_readlinecCsˆ|j}z d|_|j ¡W||_n||_w|jrd|_dS|j dd¡}t|ƒdkr,d}| ¡|jr:d|_t s:t ‚|j rBd|_ d}|S)NTFrUr—rîrrq) rr‘ÚmainloopržrCr{r‚r rJr,r Ú endoffile)r>r6rr(r(r)ÚreadlineŸs(  zPyShell.readlinecCr“rœr(rŠr(r(r)Úisatty¶rˆzPyShell.isattycCsžz |j ddd¡r WdSWnY|js(|js(| ¡|j d¡| ¡dSd|_d|_ |jrE|jj rE|j  ¡r@|j  ¡n|j  ¡|jrM|j ¡dS)Nú sel.firstz!=r‚zKeyboardInterrupt rTFT)rCrŸrôrr rar!rør¡rJrârñrúrr‘rŸr•r(r(r)re¹s(ÿ      zPyShell.cancel_callbackcCsh|jr|jsdS|j ddd¡r|j ddd¡sdS|js'| ¡| ¡dSd|_d|_|j  ¡dS)Nr—z==rdrîFTrT) rôrrCrŸr ròrJr¡r‘rŸr•r(r(r)rfÏs ÿý zPyShell.eof_callbackcCs2|jr|j dd¡|j d¡dS| |¡dS)NrdrqrT)rrCrdÚseeÚnewline_and_indent_eventr•r(r(r)rdÞs   ÿzPyShell.linefeed_callbackc Cs|jr|jsdSz|j dd¡}|r#|j ddd¡r#| ||¡WdSWnY|j ddd¡r|j d d¡}|rž|j dd|d ¡ržd |j d¡vrž|j d d¡}|rj|j |d d |d ¡rj|d |d f}|j d d¡}|r|j |d d|d ¡r|d |j  |d d¡f}| |j |d |d ¡|¡dS|j d d¡}|rå|j dd |d ¡rå|j d d¡}|rÔ|j |d d|d ¡rÔ|d |j  |d d¡f}| |j |d |d ¡|¡dS|j d d¡}|r |j |d dd¡r | |j |d d¡|¡dS| |j dd¡|¡dS|j ddd¡r&|j  dd¡|j dd¡}|r<|  ¡s<|j  dd¡|j ddd¡rL|  |¡dS|j  dd¡|jre|j dd¡|j d¡n|  |¡|j ¡|jrz|j ¡dS| ¡dS)Nr¤r‚z<=r—rTrdrúiomark linestartr¦rrÚz>=rz+1czinsert lineendrirîzend-1c linestartrq)rôrrCr{rŸÚrecallZ tag_prevrangeZ tag_namesZ tag_nextranger]röÚstripr¤r¦rdr¥Zupdate_idletasksr‘rŸÚrunit) r>rhÚselÚprevZ prev_consZ next_consÚnextÚindicesrÍr(r(r)rcçsx  €ÿþÿÿ    ÿzPyShell.enter_callbackc Cslt dd|¡}t dd|¡}| d¡}|j ¡z‘|j ddd¡|j dd ¡|j d d¡}| ¡  d ¡rB|  |¡|j d d¡}|j  d|d   ¡|j ¡t|ƒd krŽt d|d ¡ d ¡}t d|¡ d ¡}|d d…D],}| |¡r€||t|ƒd…}|j  dd| ¡|j ¡qoW|j d¡|j ¡dSW|j d¡|j ¡dS|j d¡|j ¡w)Nz^\s*\nrUz\n\s*$rqr«rlrˆrdrîriú:rrz ^([ \t]*))ÚreÚsubr6rCZundo_block_startrkrör{ÚrstripÚendswithr¦rdr©Úuser_input_insert_tagsr‚ÚsearchÚgrouprvr¥Zundo_block_stop)r>rÍrhr}ÚprefixZorig_base_indentZnew_base_indentrr(r(r)r¨6s>   ÿ  ÿù ø  ÿ zPyShell.recallz[ \t]*(\n[ \t]*)?\ZcCsj|j d¡}|j dd¡}|j d|¡}|j |¡}|s3|j |¡dkr,|j |j|¡|j   ¡dSdS)Núend-2cr—rîrUrq) rCr]r{Ú_last_newline_rer±rar4rkr´r_Úupdate_sidebar)r>Z index_beforerZinput_is_completer(r(r)rªSs  ýz PyShell.runitcCsZ|jjr |j ¡SztjWntjdd|jdYdSddlm }||j |j ƒdS)NzNo stack tracez@There is no stack trace yet. (sys.last_traceback is not defined)r r)Ú StackBrowser) rarârr¼Úlast_tracebackrr{rCZidlelib.stackviewerr»rzrG)r>rhr»r(r(r)rA_s  ý zPyShell.open_stack_viewercCs|j d¡|j d¡dS)Nr—rï)rCr¥r•r(r(r)rjms zPyShell.view_restart_markcCs|jjdddS)z&Callback for Run/Restart Shell Cntl-F6TrÝN)rarúr•r(r(r)rkqszPyShell.restart_shellcCs|| ¡|j}|jr| |j¡r|dt|jƒ …}|j dd¡|j |¡|j   ¡|j  dd¡|  ¡|j  ¡dS)NrÚz iomark-1crdrî)r rbrar³r‚rCr\rÚr!r_rºröÚset_line_and_columnrMZ reset_undo)r>rbr(r(r)røus  zPyShell.showpromptcCsP|jjj}t|ddd}d | |¡¡}| d¡s|d7}|jj  d|d¡dS)NéT)r¶ÚtabsizeZ expand_tabsrqr§rÜ) rar»r¶rrKrWr³ruZbottomrd)r>r9r¶ÚwrapperZ wrapped_msgr(r(r)Ú show_warningƒs  zPyShell.show_warningcCsb|j dd¡}|jr|j |¡|j d¡dkr|j dd¡|j dd¡| ¡|j ¡dS)Nr—rîr¸rq) rCr{rtZstorerdrör½ZctipZremove_calltip_window)r>r(r(r(r)r ‹s zPyShell.resetoutputr(cCsRz|j dd¡t |||d¡}|j dd¡Wn‚|jr'd|_ts't‚|S)Nr—ÚrightrðF)rCr÷rr!rJr,r )r>rÍr£Úcountr(r(r)r!•sz PyShell.writecs:z |j ddd¡r WdSWn tyYdSwtƒ ¡S)Nr¤rr—rŽ)rCrŸr rªrPrŠr¬r(r)rP£sÿ ÿ zPyShell.rmenu_check_cutcs|j ddd¡r dStƒ ¡S)Nrdrr—rŽ)rCrŸrªrSrŠr¬r(r)rS«s zPyShell.rmenu_check_pastecCs|j ¡|j ¡dSr<)rlZsqueeze_current_textr_rºr•r(r(r)rm°s z"PyShell.squeeze_current_text_eventcCs|j ¡dSr<)r_rº)r>r]rCr£r(r(r)Úon_squeezed_expand´szPyShell.on_squeezed_expandr<)r()Or‹rŒrZidlelib.squeezerrMr r•r–rr›rr\rrr‚r3Ú itertoolsÚ takewhileZ_idxrdZallow_line_numbersr´Zidlelib.historyrQZidlelib.sidebarrRrBrvrwryrzrrirrôrJr¡r ržr†r‡rgr‰rhrŠr‹rrGrròr‰r”r–ršr”rõr¢r£rerfrdrcr¨r°rÃr¹rªrArjrkrørÁr r!rPrSrmrÄr®r(r(r¬r)r“UsŠ   ÿ  ÿ     N      ÿ  O      r“c Cs6|jdkrdD]}| |dd| |d¡¡qdSdS)z6Make paste replace selection on x11. See issue #5124.Zx11)ZTextZEntryZSpinboxz <>z%catch {%W delete sel.first sel.last} N)Z_windowingsystemZ bind_class)rzÚclsr(r(r)Ú fix_x11_paste¸s  ÿýþ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 sJddl}ddlm}ddlm}ddlm}tdƒdad}d}d}d}d}d} z| tj dd…d¡\} } Wn#|j yZ} zt d | t ftj d t d ¡WYd} ~ nd} ~ ww| D]d\} }| d kri|}d}| d krqd}d}| dkrwd}| dkr…tj t ¡t ¡| dkr‹d}| dkr˜t dtj d da| dkr°|}tj |¡r¥n t d|ƒt ¡d}| dkr¸d} d}| dkrÁ|t_d}q]| rÑ| ddkrÑtj ¡}d}tttjƒƒD]}tj tj|¡tj|<qØ| rú| ddkrúdg| dd…t_ nU|rd g| t_ nK|r|g| t_ nA| r>d}g}| D] }| tj |¡¡q|D]}tj |¡}|tjvr;tj d|¡q&nt ¡}|tjvrOtj d|¡tj ddddd}|p\|}|pb| }trl|slt!ƒt"dda#t# $¡dd l%m&}|t#ƒtj 'tj t(¡d!¡‰|ƒd"kržtj 'ˆd#¡}t#j)|d$n-| *¡sËt+d%kr­d&‰d'}nd(‰d)}‡‡fd*d+„|Dƒ}d,d+„|Dƒ}t#j,dg|¢RŽt-t#ƒt.t#ƒt/t#ƒa0| 1t#t0¡|r|s|s| dd…D]}t0 2|¡durû|  3|¡qì| st0 4¡|rt0 5¡}|sdS| *¡rt0j6r|j7 8¡nt0j9}|r)| :¡| rItj; |¡|sO|rs|j= ?d/tj f¡|rc|j= @|¡n,|rr|j= A|¡|j= >|¡n|r| Bt#¡}|rƒ| C|¡| D¡}|r| C|¡t0jEr›t# F¡t0jEs“t# G¡tdƒdS)0Nr)Úsystem)Útesting)ÚmacosxTFrz c:deihnr:st:z Error: %s %srr…rÔz-dz-ez-hz-iz-nz: Warning: running IDLE without a subprocess is deprecated.z-rzNo script file: z-sz-tú-rUrÏrÐzeditor-on-startuprÑ)rÓZIdle)Z classNamerZIconsZWindowszidle.ico)rÒg333333!@z.png)éé é0éz.gif)rÍrÎrÏcs"g|] }tj ˆd|ˆf¡‘qS)z idle_%d%s)rIrJrK)rÌÚsize©ZextZicondirr(r)rÎbsÿzmain..cSsg|]}tt|d‘qS))Zmasterr)Z PhotoImagerz)rÌÚiconfiler(r(r)rÎdsÿZ IDLESTARTUPZ PYTHONSTARTUPzbif 1: import sys as _sys _sys.argv = %r del _sys )HÚgetoptr™rÉr!rÊrËr.r,r¼ÚargvÚerrorrÚ usage_msgrÜÚexitrÛr!rIrJr€r“r•r¦r+r†r‚r-r_ÚdirnamerdÚgetcwdrrÖZ NoDefaultRootr]rzr^Ú idlelib.runr rKÚ__file__Z wm_iconbitmapZisAquaTkÚ TkVersionZ wm_iconphotorrÈrrGZsetupApprtrjÚnewrHÚdictr‘Úlowerr`r‹Úenvironr{rar&rr)r8ZtkVersionWarningrÁZpreferTabsPreferenceWarningZ inversedictr Zdestroy)rÔrÉrÊrËZ enable_shellZ enable_editrbÚcmdZscriptZstartupZoptsrOr9ÚoÚarìZpathxr&ÚdirZ edit_startr rÓZsizesZ iconfilesZiconsrSZtkversionwarningZprefer_tabs_preference_warningr(rÒr)rÏùs6   €þ  ÿ  €   €ý ÿ         ÿÿ   € € ÿ  ü  €   ÿ rÏ)NN)Xr¼r‹r½r›Ú ImportErrorrrrIr™ZctypesZPROCESS_SYSTEM_DPI_AWAREZOleDLLZSetProcessDpiAwarenessr"r#rrÝr]rzr^rÛr r{r2r rÅr1rIZos.pathr r°rårÈÚtextwraprrþràr*r,Zidlelib.colorizerrZidlelib.configrZidlelib.delegatorrr!rrZidlelib.editorrrZidlelib.filelistrZidlelib.outwinrrrrrrZ idlelib.undorr,rßrÁÚeofrØrŸÚ NameErrorr r*r+r.Ú checkcacher8r9rr–r›r¯Z RPCClientr°r¸r¹r“rÈr×rÏr(r(r(r)ÚsÈ  ÿý ÿ  þ              ÿ ÿ  ÿ? "0g 6 6