Uname:Linux ip-10-0-5-176 6.8.0-1057-aws #60~22.04.1-Ubuntu SMP Wed May 27 08:16:59 UTC 2026 x86_64

403WebShell
403Webshell
Server IP : 3.111.61.48  /  Your IP : 216.73.216.67
Web Server : Apache
System : Linux ip-10-0-5-176 6.8.0-1057-aws #60~22.04.1-Ubuntu SMP Wed May 27 08:16:59 UTC 2026 x86_64
User : ubuntu ( 1000)
PHP Version : 8.2.31
Disable Function : exec,passthru,shell_exec,system
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : OFF  |  Sudo : ON  |  Pkexec : ON
Directory :  /lib/python3.10/idlelib/__pycache__/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /lib/python3.10/idlelib/__pycache__/pyshell.cpython-310.pyc
o

�9j���
@s,ddlZedkrejdejd<zddlTWney(edejd�ed��wejdkrKzddl	Z	dZ
e	�d	��e
�Wnee
efyJYnwdd
lmZedkrte�at��ddlmZet�ejd
detd�ed��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;ddl<m=Z=da>d Z?dZ@z
d!ZAeAeB_AeAeC_AWn
eD�yYnwejaE	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?�ZWedk�r�eW�eHd�dS)A�N�__main__zidlelib.pyshell)�*zJ** IDLE can't import Tkinter.
Your Python may not be configured for Tk. **��file��win32�shcore)�
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*�&/usr/lib/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,)�capturer*r*r+�capture_warningses
��r1TcCsXtj}i}t|�D]}|dd�|dd�dkr |�|�||<q	||�|�|�dS)aoExtend linecache.checkcache to preserve the <pyshell#...> entries

    Rather than repeating the linecache code, patch it to save the
    <pyshell#...> 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(�orig_checkcacher5�save�keyr*r*r+�extended_linecache_checkcachets�r<c@sveZdZdZdd�Zgd�Zddd�Zdd	�Zddd�Zdd
d�Z	dd�Z
dd�Zdd�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�<<set-breakpoint-here>>�<<clear-breakpoint-here>>z<<open-python-shell>>zbreakpoints.lstcSs|��|�dS�N)�restore_file_breaks)�old_hook�selfr*r*r+�filename_changed_hook��
z;PyShellEditorWindow.__init__.<locals>.filename_changed_hook)�breakpointsr�__init__�text�bind�set_breakpoint_here�clear_breakpoint_here�flist�
open_shell�os�path�joinr�userdir�breakpointPath�io�filename_change_hook�set_filename_change_hookr(rA�color_breakpoint_text)rC�argsrDr*r*r+rG�s�
�zPyShellEditorWindow.__init__))�Cutz<<cut>>�rmenu_check_cut)�Copyz<<copy>>�rmenu_check_copy)�Pastez	<<paste>>�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)rSr�CurrentTheme�GetHighlightrH�
tag_config)rC�color�theme�cfgr*r*r+rV�s

z)PyShellEditorWindow.color_breakpoint_textcCs�|j}|jj}|�dd|d|d�z|j�|�Wnty+|j�|�Ynwz|jj	j
j}|�||�WdSYdS)Nrbz%d.0r)
rHrSr(�tag_addrF�index�
ValueError�appendrL�pyshell�interprrJ)rCr)rHr(�debugr*r*r+�set_breakpoint�s�z"PyShellEditorWindow.set_breakpointNcCs>|j}|jj}|s|��dStt|�d���}|�|�dS)N�insert)rHrSr(�bell�int�floatrjrp)rC�eventrHr(r)r*r*r+rJ�sz'PyShellEditorWindow.set_breakpoint_herecCs�|j}|jj}|s|��dStt|�d���}z|j�|�WnY|�	ddd�z|j
jjj
}|�||�WdSYdS)Nrqrb�insert linestartzinsert lineend +1char)rHrSr(rrrsrtrjrF�remove�
tag_removerLrmrnrrK)rCrurHr(r)ror*r*r+rK�s$�z)PyShellEditorWindow.clear_breakpoint_herecCsf|jr1|j}|jj}|s|��dSg|_|�ddt�z|jjj	j
}|�|�WdSYdSdS)Nrb�1.0)rFrHrSr(rrrx�ENDrLrmrnr�clear_file_breaks)rCrHr(ror*r*r+r{�s�z%PyShellEditorWindow.clear_file_breaksc
CsZ|j}|jj}zt|jd��}|��}Wd�n1swYWnty.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
)rFrSr(�openrR�	readlinesr%�
startswithr#�update_breakpoints�str�getattr�rootr�r	�	showerrorrH)rC�breaksr(�fp�lines�new_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)Nr|r~r)rHr8rSr(rNrO�isfilerRr�r�r��eval�lenrp)rCr(r�r�r!�breakpoint_linenumbers�breakpoint_linenumberr*r*r+rAs$


���z'PyShellEditorWindow.restore_file_breakscCs$|j}|�d�}|�|�}||_dS)z3Retrieves all the breakpoints in the current windowrbN)rH�
tag_ranges�ranges_to_linenumbersrF)rCrH�ranges�linenumber_listr*r*r+r�+s


z&PyShellEditorWindow.update_breakpointscCshg}tdt|�d�D]'}tt||j��}tt||dj��}||kr1|�|�|d7}||ks$q
|S)Nr�r)�ranger�rsrt�stringrl)rCr�r�rjr)�endr*r*r+r�2s
��z)PyShellEditorWindow.ranges_to_linenumberscCs|��t�|�dS)z7Extend base method - clear breaks when module is closedN)r{r�_close�rCr*r*r+r�CszPyShellEditorWindow._close)Tr@)�__name__�
__module__�__qualname__�__doc__rG�rmenu_specsrVrprJrKr{r�rAr�r�r�r*r*r*r+r=�s
	

	*r=c@s"eZdZdZeZdZddd�ZdS)�PyShellFileListz8Extend base class: IDLE supports a shell and breakpointsNcCs<|jr|jj��|jSt|�|_|jr|j��sdS|jSr@)rm�top�wakeup�PyShell�begin�rCrur*r*r+rMRs
�
zPyShellFileList.open_shellr@)r�r�r�r�r=rrmrMr*r*r*r+r�Is
r�c@s eZdZdZdd�Zdd�ZdS)�ModifiedColorDelegatorz8Extend base class: colorizer for the shell window itselfcCs*|�ddd�|�ddd�t�|�dS)N�TODOry�iomark�SYNC)rxrir�recolorize_mainr�r*r*r+r�_sz&ModifiedColorDelegator.recolorize_maincCs|jD]	}|�|dd�qdS)Nr�r�)�tagdefsrx)rC�tagr*r*r+�removecolorsds
�z#ModifiedColorDelegator.removecolorsN)r�r�r�r�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�)�delegate�comparerr�TclErrorr rq�rCrj�chars�tagsr*r*r+rqls
��zModifiedUndoDelegator.insertcCsJz|j�|dd�r|j��WdSWn	tyYnwt�|||�dSr�)r�r�rrr�r �delete)rC�index1�index2r*r*r+r�us
��zModifiedUndoDelegator.deletecs>|jj��fdd�|j_z
t��|�W�|j_dS�|j_w)Ncs�||d�S�N�stdinr*)rjr���orig_insertr*r+�<lambda>��z2ModifiedUndoDelegator.undo_event.<locals>.<lambda>)r�rq�super�
undo_eventr���	__class__r�r+r�~s
�z ModifiedUndoDelegator.undo_eventr@)r�r�r�r�rqr�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�rqr�r*r*r+rq�sz UserInputTaggingDelegator.insertr@)r�r�r�r�rqr*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�r�r�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: �Shellz =r�r~N���)r��divmod)�widthr(r��div�modr*r*r+�restart_line�s
r�c@seZdZdd�ZdZdZdZdd�Zdd�Zdd	�Z	d?dd
�Z
dd�Zdd�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||d�d|_d|_t|_	|j
jj|_
dS)Nr)�localsF)�	tkconsole�sys�modules�__dict__rrG�
restarting�subprocess_arglist�PORT�port�compile�compiler�flags�original_compiler_flags)rCr�r�r*r*r+rG�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+�
<listcomp>�sz@ModifiedInterpreter.build_subprocess_arglist.<locals>.<listcomp>�main�Generalzdelete-exitfuncF�bool)�default�typez&__import__('idlelib.run').run.main(%r)�-c)r�r��warnoptionsr�	GetOption�
executabler�)rCr}�	del_exitf�commandr*r*r+r��s�
�
z,ModifiedInterpreter.build_subprocess_arglistc	CsPt|jf}td�D]}t�|�zt|�|_Wnty!Yq	w|��dS|jj	�
�d|_tdkr@|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�stderrrLr4rnT��with_cwd)�HOSTr�r��time�sleepr��rpccltr%�display_port_binding_error�listening_sock�getsocknamer��
setsockopt�socket�
SOL_SOCKET�SO_REUSEADDRr��
settimeout�accept�TimeoutError�display_no_subprocess_error�registerr�r�r�r�rLr4�
transfer_path�poll_subprocess)rC�addr�ir*r*r+�start_subprocess�sD


���z$ModifiedInterpreter.start_subprocessFr_cCs&|jr|jSd|_|��}|rzt�|j�WnY|j��|��|j}|j}d|_|�	�z|j�
�WntyG|��YdSw|j
|d�|��|j�dd�|�d�|�t|j|��|j�dd�|j�dd�|s{|��|r�t�|j�|��|j|jj_d|_|jS)	NTFr�r��end-1cr�restart�left)r�r�getdebuggerr�close_subprocess_debugger�close�terminate_subprocessr��	executingr�r	r
rr
�
stop_readlinerHr�r#r�r��mark_set�mark_gravity�
showprompt�restart_subprocess_debugger�load_breakpointsr�r�r�r�)rCr�r(ror��
was_executingr*r*r+�restart_subprocess�sH
�
z&ModifiedInterpreter.restart_subprocesscCs|j�dddi�dS)N�exec�interrupt_the_serverr*)r�
remotecallr�r*r*r+�__request_interrupt�z'ModifiedInterpreter.__request_interruptcCstj|jd���dS)N)�target)�	threading�Thread�'_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�rH�after_cancelrrrr$rrr�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+r4s��z(ModifiedInterpreter.terminate_subprocesscCs2|rdg}|�tj�ntj}|�d|f�dS)Nr_zRif 1:
        import sys as _sys
        _sys.path = %r
        del _sys
        
)�extendr�rO�
runcommand)rCr�rOr*r*r+r
As
�z!ModifiedInterpreter.transfer_pathc
Cs2|j}|dur	dSz
|j|jdd�}Wntttfy,|jjr$YdSd}|��Ynw|r�|j�	�d|_|\}}|jj
}|dkrP|durOtt|�|d�n$|dkr_|j�
d�r^|��n|dkrtd}t||tjd�t|||d�z|j��Wn	ty�Ynw|jjs�|jj�|jj|j�|_dSdS)	Ng�������?)r1�OKr�	EXCEPTION�<<toggle-jit-stack-viewer>>�ERRORz/pyshell.ModifiedInterpreter: Subprocess ERROR:
)r�pollresponse�
active_seqr�r%�KeyboardInterruptr��closingr!�resetoutputr��print�repr�getvar�remote_stack_viewerr��
__stderr__�endexecutingr$rH�after�pollintervalrr-)rC�clt�response�how�whatr��errmsgr*r*r+rPsL�
���

��z#ModifiedInterpreter.poll_subprocesscCs
||_dSr@r)rCrr*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�rHrCr@r�r*r*r+�open_remote_stack_viewer~s
z,ModifiedInterpreter.open_remote_stack_viewercCs�ddlm}|j�dddi�}|dur|jj��dS|�|j|�}ddlm	}m
}t|jj�}t�
�}t�|d�d}|||dd	�}	|	jjd
dd�||	jd|�}
|
��dS)
Nr)�
debugobj_rr"�stackviewer)rL)�ScrolledCanvas�TreeNode�normalra)�bg�highlightthicknessr�both)�expand�fill)�idlelibrNr�remotequeuer�r�rr�StubObjectTreeItem�idlelib.treerPrQ�Toplevelrrcrd�frame�pack�canvasrV)rCrN�oid�itemrPrQr�rgra�sc�noder*r*r+r@�sz'ModifiedInterpreter.remote_stack_viewerrcCs|�|�}|�||�dS)z1Like runsource() but assumes complete exec sourceN)�stuffsource�execfile�rC�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
d�t�||�|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)�tokenizer��read�use_subprocessrNrO�abspathr��
OverflowError�SyntaxErrorr�r<r=r�r�showsyntaxerrorr�runcode)rCr(rgr��coder*r*r+re�s,����
��zModifiedInterpreter.execfilecCs&|�|�}t|t�sJ�t�|||�S)zBExtend base class method: Stuff the source in the line cache first)rd�
isinstancer�r�	runsourcerfr*r*r+rs�s
zModifiedInterpreter.runsourcecCs>d|j}|jd|_|�d�}t|�dd||ftj|<|S)z"Stuff source in the filename cachez<pyshell#%d>rrr)�gid�splitr�r4r5)rCrgr(r�r*r*r+rd�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)r3�rCr(r*r*r+�prepend_syspath�s
�z#ModifiedInterpreter.prepend_syspathcCs�|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.

        r7ryr��msgr_z<no detail available>r)r�offsetrziomark + %d charsz&iomark linestart + %d lines + %d charszSyntaxError: %s
N)
r�rHrxr��exc_infor��colorize_syntax_errorr<r#r)rCr(r�rHr��value�tbrxr)ry�posr*r*r+ro�s$�z#ModifiedInterpreter.showsyntaxerrorcCs:|j��|��t�|�|j�d�r|j��dSdS)z1Extend base class method to reset output properlyr6N)r�r<�checklinecacher�
showtracebackr?�open_stack_viewerr�r*r*r+r��s

�z!ModifiedInterpreter.showtracebackcCs>tj}t|���D]}|dd�|dd�dkr||=q	dS)Nrr2r3)r4r5r6�keys)rC�cr;r*r*r+r�s��z"ModifiedInterpreter.checklinecachecCsB|jjr
|��dS|jr|j�dd|fi�dSt||j�dS)z*Run the code without invoking the debuggerrr"rpr)r�r�display_executing_dialogrrYr"r�)rCrqr*r*r+r3�s�zModifiedInterpreter.runcommandcCsd|jjr|��|��|j}z�z*|j��|s)|jdur)|j�dd|fi�|_n|r3|�	||j
�nt||j
�WnKtyY|jj
sVtjddd|jjd�rQ�|��n�Yn-trptd|jjd	�|��|j��n|jjr�d
|j_td|jjd	�n|��YWts�z|j��WdSty�YdSwdSts�z|j��Wwty�Ywww)�Override base class methodNr"rpzExit?zDo you want to exit altogether?�yes�r�r
z IDLE internal error in runcode()rFr:)r�rr!rr�beginexecutingr�
asyncqueuer9�runr�r"�
SystemExitr;r	�askyesnorHr�rkr=r�rB�canceledr$)rCrqrr*r*r+rpsf

���
�������zModifiedInterpreter.runcodecCs|jj�|�S)r�)r�r�r#)rCr�r*r*r+r#6szModifiedInterpreter.writecC�tjdd|jjd�dS)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�r	r�r�rHr�r*r*r+r:s

�z.ModifiedInterpreter.display_port_binding_errorcCr�)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r�r�r*r*r+rEs

�z/ModifiedInterpreter.display_no_subprocess_errorcCr�)NzAlready executingzYThe Python Shell window is already executing a command; please wait until it is finished.rr�r�r*r*r+r�Ms

�z,ModifiedInterpreter.display_executing_dialog)Fr_)Fr@)&r�r�r�rGr-rr�r�r�rr!r*r,r/rr
r9rrrJrrMr@rtrhrersrdrwror�rr3rpr#rrr�r*r*r*r+r��sH	
+,


&

	
.r�cs&eZdZddlmZde�ZeZe	Z
gd�Zej
dgZ
deee�dd�e
���Ze
�ed	�[d
ZdZdd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;�Z6d<d=�Z7d>d?�Z8d@dA�Z9dfdBdC�Z:dDdE�Z;dFdG�Z<dHdI�Z=dJdK�Z>e?�@dL�ZAdMdN�ZBdfdOdP�ZCdfdQdR�ZDdfdSdT�ZEdUdV�ZFdWdX�ZGdYdZ�ZHdgd\d]�ZI�fd^d_�ZJ�fd`da�ZKdfdbdc�ZLddde�ZM�ZNS)hr�r)�SqueezerzIDLE Shell ))r�_File)�edit�_Edit)ro�_Debug)�options�_Options)�window�_Window)�help�_Help)�Squeeze�<<squeeze-current-text>>rcCs|ddkS)NrrZr*)�
rmenu_itemr*r*r+r�mr�zPyShell.<lambda>)zCopy with prompts�<<copy-with-prompts>>r[Fr�)�History)�ShellSidebarNcCsXtr|j}|dddkr|�dd�t|�|_|dur+t�}t|�|��t|�}d|_	t
�||dd�d|_d|_
ttd�rDtjnd|_|j�d	�d
|_|j|_|j}|jdd�|�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:�<t=��dS)Nr�r�shell)r��She_llF��ps1z>>>
rr2�char)�wrapz<<newline-and-indent>>z<<plain-newline-and-indent>>z<<interrupt-execution>>z<<end-of-file>>z<<open-stack-viewer>>�<<toggle-debugger>>r6r�z<<view-restart>>z<<restart-shell>>r�)�iomenur�r�r��backslashreplacer��2)>rk�
menu_specsrqr�rn�Tkr�withdrawr��
shell_sidebarrrG�usetabs�indentwidth�hasattrr�r��sys_ps1ru�prompt_last_line�promptrH�	configurerI�enter_callback�linefeed_callback�cancel_callback�eof_callbackr��toggle_debugger�toggle_jit_stack_viewer�copy_with_prompts_callback�view_restart_mark�
restart_shellr��squeezer�squeeze_current_text_eventr��save_stdoutr��save_stderrr��
save_stdinrXr�r�encoding�errorsrr��pydoc�
plainpager�pagerrAr��historyrDr��perr��insertfilterr�)rCrL�msr�rHr�r�r*r*r+rG{s�
�����zPyShell.__init__cs&t���|jdur|j��dSdSr@)r��	ResetFontr��update_fontr�r�r*r+r��s

�zPyShell.ResetFontcs�t���t��}ddd�t�|d�t�|d�t�|d�d�}|��D]\}}|jj|fi|��q#|jdur>|j�	�dSdS)N)rar`r�r�rR)r�r�r�r�)
r��ResetColorizerrrcrd�itemsrH�
tag_configurer��
update_colors)rCrg�
tag_colorsr��tag_colors_configr�r*r+r��s



�
�zPyShell.ResetColorizercCstj|jdd�dS)Nr�)�insert_tagsr^)rrHr�r*r*r+�
replace_event�szPyShell.replace_eventcCstjdd�S)NT)�
shell_only)r�
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��line_prompts�get)r�r)r�r*r+r��s��z+PyShell.get_prompt_text.<locals>.<listcomp>rcss.�|]\}}|dur|n|�d|��VqdS)N� r*)r�r�r!r*r*r+�	<genexpr>�s
��
�z*PyShell.get_prompt_text.<locals>.<genexpr>)rHr�r�rsrtrP�zip�
splitlines)rC�first�lastrH�lineno_range�promptsr*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.lastr2�0zsel.last+1line linestart)rHrj�clipboard_clearr��clipboard_append)rCrurH�selfirst�sellast�prompt_textr*r*r+r��s	


z"PyShell.copy_with_prompts_callbackcCs|adSr@�r")rC�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r^)	rr	r�rH�set_debugger_indicatorrnr�close_debugger�
open_debugger)rCru�dbr*r*r+r�s�
zPyShell.toggle_debuggercCs|j��}|�d|�dS)Nr�)rnr�setvar�rCr�r*r*r+r�'s
zPyShell.set_debugger_indicatorcCsdSr@r*r�r*r*r+r�+r�zPyShell.toggle_jit_stack_viewercCsh|j��}|r.|j�d�|��|jjrt�|jj�|��|j�	d�|j
|_|��|�
�dS)Nz[DEBUG OFF]
)rnrrJrrr�close_remote_debuggerr<r�r#r�r�rr�r�r*r*r+r�.s
zPyShell.close_debuggercCsX|jjr
t�|jj|�}nt�|�}|j�|�|��d|j|_	|�
�|��dS)Nz[DEBUG ON]
)rnrr�start_remote_debuggerr�DebuggerrJrr�r�rr�)rC�dbg_guir*r*r+r�;s
�
zPyShell.open_debuggercCs |jrdnd}|�dd|�dS)N�disabledrRroz*tack*iewer)r�update_menu_state)rC�stater*r*r+�debug_menu_postcommandGszPyShell.debug_menu_postcommandcCs|��d|_dS)�Helper for ModifiedInterpreterTN)r<rr�r*r*r+r�KrEzPyShell.beginexecutingcCsd|_d|_|��dS)r�FN)rr�rr�r*r*r+rBPszPyShell.endexecutingcCsD|jrtjddd|jd�}|durdS|��d|_d|_t�|�S)zExtend EditorWindow.close()zKill?z7Your program is still running!
 Do you want to kill it?�okr�F�cancelT)	rr	�askokcancelrHrr�r;rr)rCrFr*r*r+rVs�
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�rkrnr/r�r�r�r�r�r�r�r�rLrmr�rr�r�r*r*r+r�es
zPyShell._closecC�dS)z8Override EditorWindow method: never remove the colorizerTr*rvr*r*r+�ispythonsourceur�zPyShell.ispythonsourcecCrKr@)�shell_titler�r*r*r+�short_titleyrLzPyShell.short_titlezHType "help", "copyright", "credits" or "license()" for more information.cCs�|j�dd�|��trd}|j��}|s|��dSnd}tjt	_|�
dt	jt	j|j
|f�|j��|��ddl}d|_d|_dS)	Nr�rqr_Fz�==== 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)rHrr<rkrnrrr�displayhookr�r#�version�platform�	COPYRIGHT�focus_forcer�tkinter�_support_default_root�
_default_root)rC�nosub�clientr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
�|jrBd|_d}|S)NTFr_r�rrr)rr��mainlooprrHr�r�r<r�rkr:�	endoffile)rCr:r!r*r*r+�readline�s(zPyShell.readlinecCrrr*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
r^FT)rHr�rrr<rnr#rrr�rrr!r,r�rr�r*r*r+r��s(�


zPyShell.cancel_callbackcCsh|jr|jsdS|j�ddd�r|j�ddd�sdS|js'|��|��dSd|_d|_|j�	�dS)Nr�z==rqrFTr^)
rrrHr�r<rr�rr�rr�r*r*r+r��s��
zPyShell.eof_callbackcCs2|jr|j�dd�|j�d�dS|�|�dS)Nrqrr^)rrHrq�see�newline_and_indent_eventr�r*r*r+r��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�dd�}|rj|j�|d
d|d
�rj|d
|d
f}|j�dd�}|r�|j�|d
d|d
�r�|d
|j�	|d
d�f}|�|j�|d
|d
�|�dS|j�d	d�}|r�|j�dd|d
�r�|j�dd�}|r�|j�|d
d|d
�r�|d
|j�	|d
d�f}|�|j�|d
|d
�|�dS|j�dd�}|�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�|j�re|j�dd�|j�d�n|�
|�|j��|j�rz|j��dS|��dS)Nrr�z<=r�r^rqr��iomark linestartr�rr�z>=rz+1czinsert lineendrvrzend-1c linestartr)rrrHr�r��recall�
tag_prevrange�	tag_names�
tag_nextrangerjr�stripr�rrqr�update_idletasksr�r�runit)	rCru�sel�prev�	prev_cons�	next_cons�next�indicesr�r*r*r+r��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*\nr_z\n\s*$rr$ryr�rqrrv�:rrz	^([ \t]*))�re�subrurH�undo_block_startrxrr��rstrip�endswithrrqr!�user_input_insert_tagsr��search�groupr�r�undo_block_stop)rCr�rur��prefix�orig_base_indent�new_base_indentr!r*r*r+r6s>


�
��
��zPyShell.recallz[ \t]*(\n[ \t]*)?\ZcCsj|j�d�}|j�dd�}|j�d|�}|j�|�}|s3|j�|�dkr,|j�|j|�|j	�
�dSdS)N�end-2cr�rr_r)rHrjr��_last_newline_rer,rnrsrxr0r��update_sidebar)rC�index_beforer!�input_is_completer*r*r+r#Ss�z
PyShell.runitcCsZ|jjr	|j��SztjWntjdd|jd�YdSddlm	}||j
|j�dS)NzNo stack tracez@There is no stack trace yet.
(sys.last_traceback is not defined)rr)�StackBrowser)rnrr@r��last_tracebackr	r�rH�idlelib.stackviewerr<r�rL)rCrur<r*r*r+r�_s

�zPyShell.open_stack_viewercCs|j�d�|j�d�dS)Nr�r)rHrr�r*r*r+r�mszPyShell.view_restart_markcCs|jjdd�dS)z&Callback for Run/Restart Shell Cntl-F6Tr�N)rnr!r�r*r*r+r�qszPyShell.restart_shellcCs||��|j}|jr|�|j�r|dt|j��}|j�dd�|j�|�|j	�
�|j�dd�|��|j
��dS)Nr�z	iomark-1crqr)r<r�r�r/r�rHrir�r#r�r9r�set_line_and_columnrS�
reset_undo)rCr�r*r*r+rus
zPyShell.showpromptcCsP|jjj}t|ddd�}d�|�|��}|�d�s|d7}|jj�	d|d�dS)N�T)r��tabsize�expand_tabsrrr�)
rnr�r�rrPr�r/r��bottomrq)rCrxr��wrapper�wrapped_msgr*r*r+�show_warning�s

zPyShell.show_warningcCsb|j�dd�}|jr|j�|�|j�d�dkr|j�dd�|j�dd�|��|j��dS)Nr�rr7r)	rHr�r��storerqrr?�ctip�remove_calltip_window)rCrgr*r*r+r<�szPyShell.resetoutputr*cCsRz|j�dd�t�|||d�}|j�dd�Wn�|jr'd|_ts't�|S)Nr��rightrF)rHrrr#r�rkr:)rCr�r��countr*r*r+r#�sz
PyShell.writecs:z
|j�ddd�rWdSWn
tyYdSwt���S)Nrr�r�r�)rHr�r�r�rYr�r�r*r+rY�s��
zPyShell.rmenu_check_cutcs|j�ddd�r
dSt���S)Nrqr�r�r�)rHr�r�r]r�r�r*r+r]�s
zPyShell.rmenu_check_pastecCs|j��|j��dSr@)r��squeeze_current_textr�r9r�r*r*r+r��s
z"PyShell.squeeze_current_text_eventcCs|j��dSr@)r�r9)rCrjrHr�r*r*r+�on_squeezed_expand�szPyShell.on_squeezed_expandr@)r*)Or�r�r��idlelib.squeezerr�rrr�rr�r r�rr�r�r6�	itertools�	takewhile�_idxrq�allow_line_numbersr0�idlelib.historyr��idlelib.sidebarr�rGr�r�r�r�r�r�rrr�rr;rr�r�r�r�r�r�r�r�r�rBrr�rrr
r�rrrr�r�r�r�rr+r�r8r#r�r�r�rrGr<r#rYr]r�rNr�r*r*r�r+r�Us�

�

�
N



�
	O






r�c
Cs6|jdkrdD]}|�|dd|�|d��qdSdS)z6Make paste replace selection on x11.  See issue #5124.�x11)�Text�Entry�Spinboxz	<<Paste>>z%catch {%W delete sel.first sel.last}
N)�_windowingsystem�
bind_class)r��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}ztd	|tftj
d
�t�d�WYd}~nd}~ww|
D]d\}
}|
dkri|}d}|
d
krqd}d}|
dkrwd}|
dkr�tj�t�t��|
dkr�d}|
dkr�tdtj
d
�da|
dkr�|}tj�|�r�n	td|�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�|�}|tjv�r;tj�d|��q&nt��}|tjv�rOtj�d|�tj ddddd�}|�p\|}|�pb|}t�rl|�slt!�t"dd�a#t#�$�dd l%m&}|t#�tj�'tj�t(�d!��|�d"k�r�tj�'�d#�}t#j)|d$�n-|�*��s�t+d%k�r�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|�du�r�|�3|��q�|�st0�4�|�rt0�5�}|�sdS|�*��rt0j6�r|j7�8�nt0j9}|�r)|�:�|	�rItj;�<d-��p8tj;�<d.�}|�rItj�|��rI|j=�>|�|�sO|�rs|j=�?d/tj	f�|�rc|j=�@|�n,|�rr|j=�A|�|j=�>|�n|�r�|�Bt#�}|�r�|�C|�|�D�}|�r�|�C|�t0jE�r�t#�F�t0jE�s�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�-r_r�r�zeditor-on-startupr�)r��Idle)�	classNamer
�Icons�Windowszidle.ico)r�g333333!@z.png)�� �0�z.gif)rfrgrhcs"g|]
}tj��d|�f��qS)z	idle_%d%s)rNrOrP)r��size��ext�icondirr*r+r�bs�zmain.<locals>.<listcomp>cSsg|]}tt|d��qS))�masterr)�
PhotoImager�)r��iconfiler*r*r+r�ds��IDLESTARTUP�
PYTHONSTARTUPzbif 1:
            import sys as _sys
            _sys.argv = %r
            del _sys
            
)H�getoptr	r^rXr_r`r1rkr��argv�errorr=�	usage_msgr��exitr�r#rNrOr�r�rr�rjr�r�rlrl�dirnamerq�getcwdrr��
NoDefaultRootr�r�r��idlelib.runrrP�__file__�
wm_iconbitmap�isAquaTk�	TkVersion�wm_iconphotorr]r�rL�setupAppr�rw�newrM�dictr��lowerrmr��environr�rnrer3rhrw�tkVersionWarningrG�preferTabsPreferenceWarning�inversedictr�destroy)rsr^r_r`�enable_shell�enable_editro�cmd�script�startup�optsrWrx�o�ar�pathxr(�dir�
edit_startrrp�sizes�	iconfiles�iconsr��tkversionwarning�prefer_tabs_preference_warningr*rkr+r��s6���
�
���



��
�
�
���


�r�)NN)Xr�r�r�r�ImportErrorr=rAr�r	�ctypes�PROCESS_SYSTEM_DPI_AWARE�OleDLL�SetProcessDpiAwarenessr$r%r	rr�r�r�r{rr�rqrrPr4rN�os.pathrr+rr��textwraprr(r�rir.�idlelib.colorizerr�idlelib.configr�idlelib.delegatorrrXrr�idlelib.editorrr�idlelib.filelistr�idlelib.outwinrrrrrr�idlelib.undor rkr�r��eofrwr�	NameErrorr"r,r-r1�
checkcacher<r=r�r�r�r��	RPCClientr�r�r�r�r]rvr�r*r*r*r+�<module>s���
��
�
�

�?
"0g6
6

Youez - 2016 - github.com/yon3zu
LinuXploit