3 2axC@sddlZddlZddlZddlZddlZddlZddlZddlZddl Z ddl Z ddl m Z ddl m Z ddl mZddl mZddl mZddl mZddl mZddlZx"d8D]Zee eejde=qWdZd9ddZd:ddZdaddZede jZefddZdada da!d;ddZ"ddZ#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-Gd0d1d1e-Z.Gd2d3d3e-Z/Gd4d5d5ej0Z1Gd6d7d7e2Z3eddS)<N) autocomplete)calltip) debugger_r) debugobj_r)iomenu)rpc) stackviewer simpledialog messageboxfontdialog filedialog commondialogttkztkinter.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 ) linecachegetlinestrip__name__)messagecategoryfilenamelinenolinesr(/opt/alt/python36/lib64/python3.6/run.pyidle_formatwarnings  rc CsB|dkrtj}y|jt|||||Wntk r<YnXdS)N)sysstderrwriterOSError)rrrrfilerrrridle_showwarning_subproc,sr"cCs0|rtdkr,tjatt_ntdk r,tt_dadS)N)_warnings_showwarningwarnings showwarningr")Zcapturerrrcapture_warnings<sr&TcCs|jddS)Nupdate)eval)tclrrrhandle_tk_eventsLsr*Fc Cs|ayttjd }WntdtjddStddgtjdd<tjt dt |ffd}d|_ |j x0yt ry tWntk rwpYnXytjjddd }Wntjk rd}YnX|r|\}\}}}|||}tjj||fntWqptk r trda wpYqptk r>td Yqptj\} } } yttjj|dfWn&tj| | | tjdtYnXwpYqpXqpWdS) Nz/IDLE Subprocess: no IP port passed in sys.argv.)r!TZ SockThread)targetnameargsg?)blockZtimeoutF) no_exitfuncintrargvprint __stderr__r& threadingZThread manage_socket LOCALHOSTZdaemonstartexit_nowexitKeyboardInterruptrZ request_queuegetqueueZEmptyZresponse_queueZputr*quitting SystemExitexc_infoprint_exception traceback) Z del_exitfuncZportZ sockthreadrequestseqmethodr/kwargsrettypevaluetbrrrmainZs\      rMcCsxtdD]b}tj|yt|t}PWq tk rj}z&td|jddtj d|}WYdd}~Xq Xq Wtdtj dt ||da dS|j dS)NzIDLE Subprocess: OSError: r+z, retrying....)r!z8IDLE Subprocess: Connection to IDLE GUI failed, exiting.T) rangetimesleep MyRPCServer MyHandlerr r5r/rr6show_socket_errorr;Zhandle_request)addressiZservererrZ socket_errorrrrr8s    r8c Cspddl}ddlm}|j}t||jd|dd|dd|jd|jd }|d ||d |jdS) 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_scalingZwithdrawerrnostrerrorZdestroy)rWrUr[rXrootmsgrrrrTs *rTcsdddl}|jttjtj\}}}}|\t_t_t_t fdd|||dS)Nrc sjt||j}|j}|dk rNt|krNt|||jtddn:|dk r|j rt|krt|||jtdd|rtj |}tddd }t ||tj |dtj ||}x|D]}t|d d qWdS)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.pyrpc.py threading.pyqueue.py debugger_r.pybdb.pyr,)endr!)rarbrcrdrerf) addid __context__ __cause__rJ __traceback__r5__suppress_context__rD extract_tbcleanup_traceback print_listformat_exception_only) typexcrLcontextcauseZtbeexcludelinesr)efile print_excseenrrrys.       z"print_exception..print_exc) r checkcache flush_stdoutrrrB last_type last_valuelast_tracebackset)rrrvalrLZexcinfor)rxryrzrrCsrCc Cs|dd}x2|r>x"|D]}|ddj|rPqWP|d=qWx2|rrx"|D]}|d dj|rLPqLWP|d =qBWt|dkr|dd|dd<tdtjdtjdj}xftt|D]V}||\}}}} |dkrd}| o|j dr|j d d ||fi} |||| f||<qWdS) Nrr+z** IDLE Internal Exception: )r!exec?z -toplevel-z )r)rrrrr.UszPseudoFile.namecCsdS)NTr)rrrrisattyYszPseudoFile.isatty)N)rrrrpropertyrr.rrrrrrJs   rc@seZdZddZddZdS)PseudoOutputFilecCsdS)NTr)rrrrwritable_szPseudoOutputFile.writablecCsP|jrtdt|tk r@t|ts6tdt|jtj|}|jj ||j S)Nzwrite to closed filezmust be str, not ) closed ValueErrorrJstr isinstance TypeErrorr__str__rrr)rrrrrrbs   zPseudoOutputFile.writeN)rrrrrrrrrr]src@s:eZdZd ddZddZdddZdd d Zd d ZdS)PseudoInputFileNcCstj||||d|_dS)Nr,)rr _line_buffer)rrrrrrrroszPseudoInputFile.__init__cCsdS)NTr)rrrrreadablesszPseudoInputFile.readabler+cCs|jrtd|dkrd}nt|ts8tdt|j|j}d|_|dkrlxb|jj }|s^P||7}qNWnDx(t ||kr|jj }|sP||7}qnW||d|_|d|}|S)Nzread from closed filer+zmust be int, not r,rr1) rrrr3rrJrrrreadliner)rrresultrrrrreadvs,     zPseudoInputFile.readcCs|jrtd|dkrd}nt|ts8tdt|j|jpF|jj }|dkrXt |}|j dd|}|dkrv|d}||d|_|d|S)Nzread from closed filer+zmust be int, not rrr1) rrrr3rrJrrrrrfind)rrrZeolrrrrs zPseudoInputFile.readlinecCs|jjdS)N)rclose)rrrrrszPseudoInputFile.close)Nr1)r1r1)r1)rrrrrrrrrrrrrms    rc@s,eZdZddZddZddZddZd S) rScCst|}|jd||jd|_t|jdtjt_t |jdtjt_ t |jdtjt_ t j t_ ddl}|j|_tj|_|jd|_t jj|ddd dS) Nrconsolestdinstdoutrrinterpg?)Zmyseqwait) Executiveregisterget_remote_proxyrrrrrrrrrr displayhookpydocZ plainpagerZpagerZ _keep_stdinr RPCHandlerZ getresponse)rZ executiverrrrhandles      zMyHandler.handlecCstjddS)N )rPrQ)rrrrexithookszMyHandler.exithookcCsdatjdS)NT)r@rr)rrrrEOFhookszMyHandler.EOFhookcCsdatjdS)NT)r@rr)rrrrdecode_interrupthookszMyHandler.decode_interrupthookN)rrrrrrrrrrrrSsrSc@sNeZdZddZddZddZddZd d Zd d Zd dZ dddZ dS)rcCs&||_tj|_tj|_tj|_dS)N)r__main____dict__localsrZCalltiprZ AutoComplete)rrrrrrs zExecutive.__init__cCsy&d|_dazt||jWddaXWnVtk r:YnJtj|_trTtt |j j j d}|rx|j j jYnXtdS)NTFz<>) usr_exc_info interruptablerrrArrBr@r<rCrrZgetvarrZopen_remote_stack_viewerr|)rcodeZjitrrrruncodes"  zExecutive.runcodecCstr tjdS)N)rrr)rrrrinterrupt_the_serverszExecutive.interrupt_the_servercCstj|j|S)N)rZstart_debuggerr)rZ gui_adap_oidrrrstart_the_debuggerszExecutive.start_the_debuggercCs|jj|dS)N)rZ unregister)rZ idb_adap_oidrrrstop_the_debuggerszExecutive.stop_the_debuggercCs |jj|S)N)rZ fetch_tip)rr.rrrget_the_calltipszExecutive.get_the_calltipcCs|jj||S)N)rZfetch_completions)rZwhatmoderrrget_the_completion_listsz!Executive.get_the_completion_listNcCsr|jr|j\}}}ndSd}|dk r0|jj|}x|rN|jjddkrN|j}q2W|t_|t_t j ||}t j |S)Nrrrun)rr) rrrtb_frame f_globalstb_nextrr}r~rZ StackTreeItemrZremote_object_tree_item)rZ flist_oidrrrrLflistitemrrrrs   zExecutive.stackviewer)N) rrrrrrrrrrrrrrrrsr)r r r r r rr)N)NN)F)4iorr?rrPrD_threadrr7r$r[Zidlelibrrrrrrrrmoddelattrmodulesr9rr"r#r&ZTclr)r*r;r@rrMr8rTrCror|r<r\Z RPCServerrR TextIOBaserrrrrSobjectrrrrrs`             M$ !4+A