3 Õì2axCã@sÐddlZddlZddlZddlZddlZddlZddlZddlZddl Z ddl Z ddl m Z ddl m Z ddl mZddl mZddl mZddl mZddl mZddlZx"d8D]Zee eƒejde=q²WdZd9dd„Zd:dd„Zdadd„Zedƒe jƒZefdd„Zdada da!d;dd„Z"dd„Z#d d!„Z$d"d#„Z%d$d%„Z&d&d'„Z'd(d)„Z(d*d+„Z)Gd,d-„d-ej*ƒZ+Gd.d/„d/ej,ƒZ-Gd0d1„d1e-ƒZ.Gd2d3„d3e-ƒZ/Gd4d5„d5ej0ƒZ1Gd6d7„d7e2ƒZ3edƒdS)<éN)Ú autocomplete)Úcalltip)Ú debugger_r)Ú debugobj_r)Úiomenu)Úrpc)Ú stackviewerÚ simpledialogÚ messageboxÚfontÚdialogÚ filedialogÚ commondialogÚttkztkinter.z 127.0.0.1cCsVd}|d||f7}|dkr(tj||ƒ}|jƒ}|r@|d|7}|d|j|f7}|S)Nz! Warning (from warnings module): z File "%s", line %s z %s z%s: %s )Ú linecacheÚgetlineÚstripÚ__name__)ÚmessageÚcategoryÚfilenameÚlinenoÚlineÚs©rú(/opt/alt/python36/lib64/python3.6/run.pyÚidle_formatwarnings  rc CsB|dkrtj}y|jt|||||ƒƒWntk r<YnXdS)N)ÚsysÚstderrÚwriterÚOSError)rrrrÚfilerrrrÚidle_showwarning_subproc,sr"cCs0|rtdkr,tjatt_ntdk r,tt_dadS)N)Ú_warnings_showwarningÚwarningsÚ showwarningr")ZcapturerrrÚcapture_warnings<sr&TcCs|jdƒdS)NÚupdate)Úeval)ÚtclrrrÚhandle_tk_eventsLsr*Fc Cs¤|ayttjd ƒ}Wntdtjd�dStdƒdgtjdd…<tjt dt |ffd�}d|_ |j ƒ�x0yŽt r˜y tƒWntk r–wpYnXytjjddd �}Wntjk rÆd}YnX|rö|\}\}}}|||Ž}tjj||fƒntƒWqptk �r t�rda wpYqptk �r>td ƒ‚Yqptjƒ\} } } ytƒtjj|dfƒWn&tj| | | tjd�tƒYnXwpYqpXqpWdS) Néz/IDLE Subprocess: no IP port passed in sys.argv.)r!TÚZ SockThread)ÚtargetÚnameÚargsgš™™™™™©?)ÚblockZtimeoutFéÿÿÿÿ)Ú no_exitfuncÚintrÚargvÚprintÚ __stderr__r&Ú threadingZThreadÚ manage_socketÚ LOCALHOSTZdaemonÚstartÚexit_nowÚexitÚKeyboardInterruptrZ request_queueÚgetÚqueueZEmptyZresponse_queueZputr*ÚquittingÚ SystemExitÚexc_infoÚprint_exceptionÚ traceback) Z del_exitfuncZportZ sockthreadÚrequestÚseqÚmethodr/ÚkwargsÚretÚtypeÚvalueÚtbrrrÚmainZs\      rMcCsœxŽtdƒD]b}tj|ƒyt|tƒ}PWq tk rj}z&td|jddtj d�|}WYdd}~Xq Xq Wtdtj d�t ||ƒda dS|j ƒdS)NézIDLE Subprocess: OSError: r+z, retrying....)r!z8IDLE Subprocess: Connection to IDLE GUI failed, exiting.T) ÚrangeÚtimeÚsleepÚ MyRPCServerÚ MyHandlerr r5r/rr6Úshow_socket_errorr;Zhandle_request)ÚaddressÚiZserverÚerrZ socket_errorrrrr8§s    r8c Cspddl}ddlm}|jƒ}t|ƒ|jƒd|d›d|d›d|j›d|j›d� }|d ||d �|jƒdS) Nr)Ú showerrorz#IDLE's subprocess can't connect to ú:r+z. Fatal OSError #z: zz. See the 'Startup failure' section of the IDLE doc, online at https://docs.python.org/3/library/idle.html#startup-failurezIDLE Subprocess Error)Úparent) ÚtkinterZtkinter.messageboxrXZTkÚ fix_scalingZwithdrawÚerrnoÚstrerrorZdestroy)rWrUr[rXÚrootÚmsgrrrrTºs *rTcsdddl}|jƒtƒtj‰tjƒ\}}}}|\t_t_t_t ƒ‰‡‡‡fdd„‰ˆ|||ƒdS)Nrc sêˆjt|ƒƒ|j}|j}|dk rNt|ƒˆkrNˆt|ƒ||jƒtdˆd�n:|dk rˆ|j rˆt|ƒˆkrˆˆt|ƒ||jƒtdˆd�|r¾tj |ƒ}tdˆd�d }t ||ƒtj |ˆd�tj ||ƒ}x|D]}t|d ˆd �qÐWdS)NzF The above exception was the direct cause of the following exception: )r!zE During handling of the above exception, another exception occurred: z"Traceback (most recent call last):úrun.pyúrpc.pyú threading.pyúqueue.pyú debugger_r.pyúbdb.pyr,)Úendr!)rarbrcrdrerf) ÚaddÚidÚ __context__Ú __cause__rJÚ __traceback__r5Ú__suppress_context__rDÚ extract_tbÚcleanup_tracebackÚ print_listÚformat_exception_only) ÚtypÚexcrLÚcontextÚcauseZtbeÚexcludeÚlinesr)ÚefileÚ print_excÚseenrrryÑs.       z"print_exception..print_exc) rÚ checkcacheÚ flush_stdoutrrrBÚ last_typeÚ last_valueÚlast_tracebackÚset)rrrÚvalrLZexcinfor)rxryrzrrCÈsrCc Cs|dd…}x2|r>x"|D]}|ddj|ƒrPqWP|d=qWx2|rrx"|D]}|d dj|ƒrLPqLWP|d =qBWt|ƒdkr¢|dd…|dd…<tdtjd�tjdj}xftt|ƒƒD]V}||\}}}} |dkrÜd}| oê|j dƒ�r|j d d ||fiƒ} |||| f||<q¼WdS) Nrr+z** IDLE Internal Exception: )r!Úexecú?z -toplevel-z )rŸ)r™rrrr.UszPseudoFile.namecCsdS)NTr)r™rrrÚisattyYszPseudoFile.isatty)N)rr›rœr¢Úpropertyr¡r.r£rrrrr�Js   r�c@seZdZdd„Zdd„ZdS)ÚPseudoOutputFilecCsdS)NTr)r™rrrÚwritable_szPseudoOutputFile.writablecCsP|jrtdƒ‚t|ƒtk r@t|tƒs6tdt|ƒjƒ‚tj|ƒ}|jj ||j ƒS)Nzwrite to closed filezmust be str, not ) ÚclosedÚ ValueErrorrJÚstrÚ isinstanceÚ TypeErrorrÚ__str__ržrrŸ)r™rrrrrbs   zPseudoOutputFile.writeN)rr›rœr¦rrrrrr¥]sr¥c@s:eZdZd dd„Zdd„Zddd„Zdd d „Zd d „ZdS)ÚPseudoInputFileNcCstj||||ƒd|_dS)Nr,)r�r¢Ú _line_buffer)r™ržrŸr¡rrrr¢oszPseudoInputFile.__init__cCsdS)NTr)r™rrrÚreadablesszPseudoInputFile.readabler+cCs´|jrtdƒ‚|dkrd}nt|tƒs8tdt|ƒjƒ‚|j}d|_|dkrlxb|jj ƒ}|s^P||7}qNWnDx(t |ƒ|kr”|jj ƒ}|sŠP||7}qnW||d…|_|d|…}|S)Nzread from closed filer+zmust be int, not r,rr1) r§r¨rªr3r«rJrr®ržÚreadliner…)r™rŽÚresultrrrrÚreadvs,     zPseudoInputFile.readcCs�|jrtdƒ‚|dkrd}nt|tƒs8tdt|ƒjƒ‚|jpF|jj ƒ}|dkrXt |ƒ}|j dd|ƒ}|dkrv|d}||d…|_|d|…S)Nzread from closed filer+zmust be int, not rr’r1) r§r¨rªr3r«rJrr®ržr°r…Úfind)r™rŽrZeolrrrr°�s zPseudoInputFile.readlinecCs|jjƒdS)N)ržÚclose)r™rrrr´�szPseudoInputFile.close)Nr1)r1r1)r1)rr›rœr¢r¯r²r°r´rrrrr­ms    r­c@s,eZdZdd„Zdd„Zdd„Zdd„Zd S) rScCs˜t|ƒ}|jd|ƒ|jdƒ|_t|jdtjƒt_t |jdtjƒt_ t |jdtjƒt_ t j t_ ddl}|j|_tj|_|jdƒ|_t jj|ddd �dS) Nr‚ÚconsoleÚstdinÚstdoutrrÚinterpgš™™™™™©?)ZmyseqÚwait)Ú ExecutiveÚregisterÚget_remote_proxyrµr­rr¡rr¶r¥r·rrÚ displayhookÚpydocZ plainpagerZpagerZ _keep_stdinr¸Ú RPCHandlerZ getresponse)r™Z executiver¾rrrÚhandle£s      zMyHandler.handlecCstjdƒdS)Né )rPrQ)r™rrrÚexithook»szMyHandler.exithookcCsdatjƒdS)NT)r@r–r—)r™rrrÚEOFhook¿szMyHandler.EOFhookcCsdatjƒdS)NT)r@r–r—)r™rrrÚdecode_interrupthookÅszMyHandler.decode_interrupthookN)rr›rœrÀrÂrÃrÄrrrrrS¡srSc@sNeZdZdd„Zdd„Zdd„Zdd„Zd d „Zd d „Zd d„Z ddd„Z dS)rºcCs&||_tj|_tjƒ|_tjƒ|_dS)N)r†Ú__main__Ú__dict__ÚlocalsrZCalltiprZ AutoComplete)r™r†rrrr¢Îs zExecutive.__init__cCsˆy&d|_dazt||jƒWddaXWnVtk r:YnJtjƒ|_trTtƒt ƒ|j j j dƒ}|rx|j j jƒYnXtƒdS)NTFz<>)Ú usr_exc_infoÚ interruptabler‚rÇrArrBr@r<rCr†rµZgetvarr¸Zopen_remote_stack_viewerr|)r™ÚcodeZjitrrrÚruncodeÔs"  zExecutive.runcodecCstr tjƒdS)N)rÉr–r—)r™rrrÚinterrupt_the_serveríszExecutive.interrupt_the_servercCstj|j|ƒS)N)rZstart_debuggerr†)r™Z gui_adap_oidrrrÚstart_the_debuggerñszExecutive.start_the_debuggercCs|jj|ƒdS)N)r†Z unregister)r™Z idb_adap_oidrrrÚstop_the_debuggerôszExecutive.stop_the_debuggercCs |jj|ƒS)N)rZ fetch_tip)r™r.rrrÚget_the_calltipøszExecutive.get_the_calltipcCs|jj||ƒS)N)rZfetch_completions)r™ZwhatÚmoderrrÚget_the_completion_listûsz!Executive.get_the_completion_listNcCsr|jr|j\}}}ndSd}|dk r0|jj|ƒ}x|rN|jjddkrN|j}q2W|t_|t_t j ||ƒ}t j |ƒS)NrrÚrun)rrÒ) rÈr†r¼Útb_frameÚ f_globalsÚtb_nextrr}r~rZ StackTreeItemrZremote_object_tree_item)r™Z flist_oidrrr�rLÚflistÚitemrrrrþs   zExecutive.stackviewer)N) rr›rœr¢rËrÌrÍrÎrÏrÑrrrrrrºÌsrº)r r r r r rr)N)NN)F)4Úiorr?rrPrDÚ_threadr–r7r$r[ZidlelibrrrrrrrrÅÚmodÚdelattrÚmodulesr9rr"r#r&ZTclr)r*r;r@rÉrMr8rTrCror|r<r\Z RPCServerrRÚ TextIOBaser�r¥r­r¿rSÚobjectrºrrrrÚs`             M$ !4+A