a  zemR@shddlZddlZddlZddlZddlZddlZddlZddlZddlZ ddl Z ddl Z ddl Z ddl m Z ddl mZddl mZddl mZddl mZddl mZddl mZddlZddlZeejd d sd D]Zeeeejd e=qd ejd _dZzdZee_ee_Wney.Yn0dAddZ dBddZ!da"ddZ#e#de$Z%e%fddZ&d a'd a(d a)dCddZ*ddZ+ddZ,dd Z-d!d"Z.d#d$Z/d%d&Zd'd(Z0d)d*Z1d+Z2d,d-Z3d.d/Z4Gd0d1d1ej5Z6Gd2d3d3ej7Z8Gd4d5d5e8Z9Gd6d7d7e8Z:Gd8d9d9ej;Zdd?d@e#d dS)DN) autocomplete)calltip) debugger_r) debugobj_r)iomenu)rpc) stackviewerz idlelib.runfirstrun)Z simpledialogZ messageboxfontZdialogZ filedialogZ commondialogttkztkinter.Fz 127.0.0.1zCtrl-D (end-of-file)cCsVd}|d||f7}|dur(t||}|}|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/bitninja-python-dojo/embedded/lib/python3.9/idlelib/run.pyidle_formatwarning2s  rcCs@|durtj}z|t|||||Wnty:Yn0dSN)sysstderrwriterOSError)rrrrfilerrrridle_showwarning_subproc?s  rcCs0|rtdur,tjatt_ntdur,tt_dadSr)_warnings_showwarningwarnings showwarningr)capturerrrcapture_warningsOsr$TcCs|ddS)Nupdate)eval)tclrrrhandle_tk_events_sr(c Cs|azttjd}WntdtjdYdS0tddgtjdd<tjt dt |ffd}d|_ | zt rz tWntyYWqpYn0ztjjddd }Wntjyd}Yn0|r|\}\}}}||i|}tj||fntWqpty$trda YqpYqpty@td Yqpt\} } } zttj|dfWn&tj| | | tjdtYn0YqpYqp0qpdS) Nz/IDLE Subprocess: no IP port passed in sys.argv.rTZ SockThread)targetnameargs皙?)blocktimeoutF) no_exitfuncintrargvprint __stderr__r$ threadingThread manage_socket LOCALHOSTdaemonstartexit_nowexitKeyboardInterruptrZ request_queuegetqueueEmptyZresponse_queueputr(quitting SystemExitexc_infoprint_exception traceback) Z del_exitfuncportZ sockthreadrequestseqmethodr.kwargsrettypevaluetbrrrmainms^      rRc CstdD]h}t|zt|t}WqWqtyn}z,td|jddtj d|}WYd}~qd}~00qtdtj dt ||da dS| dS)NzIDLE Subprocess: OSError: z, retrying....r*z8IDLE Subprocess: Connection to IDLE GUI failed, exiting.T) rangetimesleep MyRPCServer MyHandlerrr5r.rr6show_socket_errorr=Zhandle_request)addressiZservererrZ socket_errorrrrr9s&     r9c Cslddl}ddlm}|}t|||dd|dd|dd|jd|jd |d |dS) Nr) showerrorzSubprocess Connection Errorz#IDLE's subprocess can't connect to :rTz. Fatal OSError #z: zz. See the 'Startup failure' section of the IDLE doc, online at https://docs.python.org/3/library/idle.html#startup-failure)parent) tkinterZtkinter.messageboxr^ZTk fix_scalingZwithdrawerrnostrerrorZdestroy)r]r[rar^rootrrrrZs rZcsdddl}|ttjt\}}}}|\t_t_t_t fdd|||dS)Nrc st||j}|j}|durNt|vrNt|||jtddn8|dur|jst|vrt|||jtdd|rt |}tddd}t ||tj |dt ||}|D]}t|ddqdS)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):)zrun.pyzrpc.pyz threading.pyzqueue.pyz debugger_r.pyzbdb.pyr+)endr) addid __context__ __cause__rO __traceback__r5__suppress_context__rH extract_tbcleanup_traceback print_listformat_exception_only) typexcrQcontextcauseZtbeexcludelinesrZefile print_excseenrrrxs4     z"print_exception..print_exc) r checkcache flush_stdoutrrrF last_type last_valuelast_tracebackset)r rqvalrQexcinforrwrrGsrGc Cs|dd}|r:|D]}|dd|rq2qq:|d=q |rh|D]}|dd|rBq`qBqh|d=q:t|dkr|dd|dd<tdtjdtjdj}tt|D]R}||\}}}} |dkrd}| s| dr| d d ||fi} |||| f||<qdS) Nrr)z** IDLE Internal Exception: r*exec?z -toplevel-z )rrrrr>#s r>cCsnddl}t|jdd}|dkrj|j|D]:}|jj||dd}t|d}|dkr.td||d<q.dS) Nrtkscalinggffffff?T)rer-existssizeg) Z tkinter.fontfloatrcallr namesZFontr3round)rerarr-r rrrrrb2s rbcCs2|jdur|jdnd}|tt||_dS)Nz r+)__doc__textwrapfilldedent)ZfuntextZtemrrrfixdoc>srcs|ttjfddtdtdttjfddtdtdtd tttt_t_dS) Ncs\|r tdz |\}Wn&ty<tdt|dYn0|dksNtd|tS)Nz.setrecursionlimit() takes no keyword argumentsz0setrecursionlimit() takes exactly one argument (z given)rz/recursion limit must be greater or equal than 1) TypeError ValueErrorr __wrapped__RECURSIONLIMIT_DELTA)r.rMlimit)setrecursionlimitrrrHs  z:install_recursionlimit_wrappers..setrecursionlimitz# This IDLE wrapper adds z7 to prevent possible uninterruptible loops.cs tSr)rrr)getrecursionlimitrrr]sz:install_recursionlimit_wrappers..getrecursionlimitz( This IDLE wrapper subtracts z# to compensate for the z" IDLE adds when setting the limit.) functoolswrapsrrrrrrr)rrrinstall_recursionlimit_wrappersDs    rcCsFttjddrBttjddrBtjjt_tjjt_tttdS)Nr)getattrrrrrrrrrr!uninstall_recursionlimit_wrappersls    rc@seZdZddZdS)rXcCszWntyYnty6datYnvtj}tt dddt j d|d|d |dt jd|d tt d d|ddatYn0dS) NTz z(----------------------------------------zU Unhandled exception in user code execution server!' Thread: z" IDLE Client Address: z Request: r*i)rra *** Unrecoverable, server exiting! Users should never see this message; it is likely transient. If this recurs, report this with a copy of the message and an explanation of how to make it repeat. )rEEOFErrorr=threadinterrupt_mainrr6r5rrr7current_threadr-rHrxrD)selfrJZclient_addresserfrrr handle_error}s8   zMyRPCServer.handle_errorN)r __module__ __qualname__rrrrrrX{srXc@sBeZdZdddZeddZeddZed d Zd d Zd S) StdioFileutf-8strictcCs||_||_||_||_dSr)shelltags _encoding_errors)rrrencodingerrorsrrr__init__szStdioFile.__init__cCs|jSr)rrrrrrszStdioFile.encodingcCs|jSr)rrrrrrszStdioFile.errorscCs d|jS)Nz<%s>)rrrrrr-szStdioFile.namecCsdSNTrrrrrisattyszStdioFile.isattyN)rr) rrrrpropertyrrr-rrrrrrs    rc@seZdZddZddZdS) StdOutputFilecCsdSrrrrrrwritableszStdOutputFile.writablecCs<|jrtdt||j|j|j|j}|j||j S)Nzwrite to closed file) closedrstrencoderrdecoderrr)rrrrrrszStdOutputFile.writeN)rrrrrrrrrrsrc@s4eZdZdZddZd ddZd ddZd d Zd S) StdInputFiler+cCsdSrrrrrrreadableszStdInputFile.readabler)cCs|jrtd|durd}nt|ts8tdt|j|j}d|_|dkrh|j }|s\q||7}qLn@t ||kr|j }|sq||7}qh||d|_|d|}|S)Nread from closed filer)must be int, not r+r) rr isinstancer3rrOr _line_bufferrreadliner)rrresultrrrrreads&       zStdInputFile.readcCs|jrtd|durd}nt|ts8tdt|j|jpF|j }|dkrXt |}| dd|}|dkrv|d}||d|_|d|S)Nrr)rr rT) rrrr3rrOrrrrrfind)rrrZeolrrrrs zStdInputFile.readlinecCs|jdSr)rcloserrrrrszStdInputFile.closeN)r))r))rrrrrrrrrrrrrs   rc@s,eZdZddZddZddZddZd S) rYcCst|}|d||d|_t|jdtjtjt_ t |jdtjtjt_ t |jdtjdt_ t jt_ddl}|j|_tj |_t|d|_t jj|dd d dS) Nrconsolestdinstdoutrbackslashreplacerinterpr/)Zmyseqwait) Executiveregisterget_remote_proxyrrrrrrrrrrr displayhookpydocZ plainpagerZpagerZ _keep_stdinrr RPCHandlerZ getresponse)rZ executiverrrrhandles&   zMyHandler.handlecCstddS)N )rVrWrrrrexithookszMyHandler.exithookcCsdatdSrrDrrrrrrEOFhookszMyHandler.EOFhookcCsdatdSrrrrrrdecode_interrupthookszMyHandler.decode_interrupthookN)rrrrrrrrrrrrYsrYc@sNeZdZddZddZddZddZd d Zd d Zd dZ dddZ dS)rcCs8||_tjdur.tj|_t|_t |_ni|_dS)NF) ridlelibZtesting__main____dict__localsrZCalltiprZ AutoComplete)rrrrrr's    zExecutive.__init__c Csz*d|_dazt||jWdanda0Wnty}zD|jrr|jd}t|tdtfsrt dt |t j dWYd}~nd}~0t |_trtt jt jurtn.zt j|jWnt |_tYn0|jjd}|r|jjYn0tdS)NTFrz SystemExit: r*z<>) user_exc_info interruptablerrrEr.rrOr3r5rrrrFrDr> excepthook__excepthook__rGrrZgetvarrZopen_remote_stack_viewerr{)rcodeeobZjitrrrruncode0s4 *    zExecutive.runcodecCstr tdSr)rrrrrrrinterrupt_the_serverQszExecutive.interrupt_the_servercCst|j|Sr)rZstart_debuggerr)rZ gui_adap_oidrrrstart_the_debuggerUszExecutive.start_the_debuggercCs|j|dSr)r unregister)rZ idb_adap_oidrrrstop_the_debuggerXszExecutive.stop_the_debuggercCs |j|Sr)rZ fetch_tip)rr-rrrget_the_calltip\szExecutive.get_the_calltipcCs|j||Sr)rZfetch_completions)rZwhatmoderrrget_the_completion_list_sz!Executive.get_the_completion_listNcCsn|jr|j\}}}ndSd}|dur0|j|}|rL|jjddvrL|j}q0|t_|t_t ||}t |S)Nr)rrun) rrrtb_frame f_globalstb_nextrr|r}rZ StackTreeItemrZremote_object_tree_item)rZ flist_oidrqrrQflistitemrrrrbs  zExecutive.stackviewer)N) rrrrrrrrrrrrrrrr%s !rr)rRzidlelib.idle_test.test_run) verbosity)N)NN)F)@rior rArrrVrH_threadrr7r!rrrrrrrrrrahasattrmodulesmoddelattrr r:eofr>quit NameErrorrrr r$ZTclr'r(r=rDrrRr9rZrGrnr{rbrrrrZ RPCServerrX TextIOBaserrrrrYrrZunittestrrrrs               M$ (( 1-M