Uname: Linux web3.us.cloudlogin.co 5.10.226-xeon-hst #2 SMP Fri Sep 13 12:28:44 UTC 2024 x86_64
Software: Apache
PHP version: 8.1.31 [ PHP INFO ] PHP os: Linux
Server Ip: 162.210.96.117
Your Ip: 18.117.184.57
User: edustar (269686) | Group: tty (888)
Safe Mode: OFF
Disable Function:
NONE

name : pyshell.cpython-311.pyc
�

TfI��� �ddlZedkrejdejd<	ddlTn&#e$redej���ed���wxYwejdkr9	ddl	Z	dZ
e	jd	���e
��n#ee
ef$rYnwxYwdd
lmZddlmZddlZddlZddlZddlZddlmZddlZddlZddlZdd
lmZddlZddlZddlZddlZddl m!Z!ddl"m#Z#ddl$m%Z%ddl&m'Z'ddl&m(Z(ddl)m*Z*m+Z+ddl,m-Z-ddl.m/Z/ddl&m0Z0ddl&m1Z1ddl2m3Z3m4Z4m5Z5ddl6m7Z7da8dZ9dZ:	dZ;e;e<_;e;e=_;n#e>$rYnwxYweja?	d5d�Z@daAd�ZBeBd��dejCfd �ZDeDe_CGd!�d"e*��ZEGd#�d$e-��ZFGd%�d&e!��ZGGd'�d(e7��ZHGd)�d*e%��ZIGd+�d,e1jJ��ZKd-�ZLGd.�d/e��ZMGd0�d1e/��ZNd2�ZOd3ZPd4�ZQedkr
eQ��eBd��dS)6�N�__main__zidlelib.pyshell)�*zJ** IDLE can't import Tkinter.
Your Python may not be configured for Tk. **��file��win32�shcore)�
messagebox)�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	���|�t}	|�t|||||�����|�d��dS#ttf$rYdSwxYw)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�linenorrs      �8/usr/local/python-3.11/lib/python3.11/idlelib/pyshell.py�idle_showwarningr)Is����|���
��
�
�%���8�V�$�@�@�@�	A�	A�	A��
�
�6��������G�$�
�
�
����
���s�<A	�	A�Ac��|r(t�tjatt_dSdSt�tt_dadSdS)z>Replace warning.showwarning with idle_showwarning, or reverse.N)�_warnings_showwarning�warnings�showwarningr))�captures r(�capture_warningsr/\sU���)� �(�$,�$8�!�#3�H� � � �)�(�!�,�#8�H� �$(�!�!�!�-�,�Tc���tj}i}t|��D]3}|dd�|dd�zdkr|�|��||<�4||��|�|��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�keys     r(�extended_linecache_checkcacher<ks���
�O�E�
�D��E�{�{�'�'���r��r�7�S����X���%�%��	�	�#���D��I���O�H����	�L�L������r0c�b�eZdZdZd�Zgd�Zdd�Zd�Zdd�Zdd	�Z	d
�Z
d�Zd�Zd
�Z
d�Zd�ZdS)�PyShellEditorWindowz6Regular text edit window in IDLE, supports breakpointsc��g|_tj|g|�R�|j�d|j��|j�d|j��|j�d|jj��tj
�tj
d��|_|jj|fd�}|j�|��|jjr|���|���dS)N�<<set-breakpoint>>�<<clear-breakpoint>>z<<open-python-shell>>zbreakpoints.lstc�B�|���|��dS�N)�restore_file_breaks)�old_hook�selfs  r(�filename_changed_hookz;PyShellEditorWindow.__init__.<locals>.filename_changed_hook�s#���$�$�&�&�&��H�J�J�J�J�Jr0)�breakpointsr�__init__�text�bind�set_breakpoint_event�clear_breakpoint_event�flist�
open_shell�os�path�joinr�userdir�breakpointPath�io�filename_change_hook�set_filename_change_hookr&rD�color_breakpoint_text)rF�argsrGs   r(rIzPyShellEditorWindow.__init__�s�������d�*�T�*�*�*�*��	���+�T�-F�G�G�G��	���-�t�/J�K�K�K��	���.��
�0E�F�F�F�!�g�l�l�� �"3�5�5���,0�7�+G�'+�	�	�	�	�	
��(�(�)>�?�?�?��7��	'��$�$�&�&�&��"�"�$�$�$�$�$r0))�Cutz<<cut>>�rmenu_check_cut)�Copyz<<copy>>�rmenu_check_copy)�Pastez	<<paste>>�rmenu_check_paste)NNN)zSet Breakpointr@N)zClear BreakpointrANTc��|j�dS|r)tj��}tj|d��}nddd�}|j�d|��dS)z,Turn colorizing of breakpoint text on or offN�break�)�
foreground�
background�BREAK)rUr�CurrentTheme�GetHighlightrJ�
tag_config)rF�color�theme�cfgs    r(rXz)PyShellEditorWindow.color_breakpoint_text�sc���7�?��F��	7��)�+�+�E��'��w�7�7�C�C�!#�2�6�6�C��	���W�c�*�*�*�*�*r0c�b�|j}|jj}|�dd|zd|dzz��	|j�|��n*#t$r|j�|��YnwxYw	|jj	j
j}|�||��dS#YdSxYw)Nrez%d.0r)
rJrUr&�tag_addrH�index�
ValueError�appendrN�pyshell�interpr�set_breakpoint)rFr'rJr&�debugs     r(rsz"PyShellEditorWindow.set_breakpoint�s����y���7�#�����W�f�v�o�v����/B�C�C�C�	,���"�"�6�*�*�*�*���	,�	,�	,���#�#�F�+�+�+�+�+�	,����	��J�&�-�6�E�� � ��6�2�2�2�2�2��	��D�D���s�A�$A7�6A7�;,B)�)B.Nc���|j}|jj}|s|���dSt	t|�d������}|�|��dS)N�insert)rJrUr&�bell�int�floatrnrs)rF�eventrJr&r's     r(rLz(PyShellEditorWindow.set_breakpoint_event�sh���y���7�#���	��I�I�K�K�K��F��U�4�:�:�h�/�/�0�0�1�1�����F�#�#�#�#�#r0c��|j}|jj}|s|���dSt	t|�d������}	|j�|��n#YnxYw|�	ddd��	|j
jjj
}|�||��dS#YdSxYw)Nrvre�insert linestartzinsert lineend +1char)rJrUr&rwrxryrnrH�remove�
tag_removerNrqrrr�clear_breakpoint)rFrzrJr&r'rts      r(rMz*PyShellEditorWindow.clear_breakpoint_event�s����y���7�#���	��I�I�K�K�K��F��U�4�:�:�h�/�/�0�0�1�1��	���#�#�F�+�+�+�+��	��D��������!3�/�	1�	1�	1�	��J�&�-�6�E��"�"�8�V�4�4�4�4�4��	��D�D���s�A7�7A;�,C�C	c��|jr�|j}|jj}|s|���dSg|_|�ddt��	|jjj	j
}|�|��dS#YdSxYwdS)Nre�1.0)rHrJrUr&rwr~�ENDrNrqrrr�clear_file_breaks)rFrJr&rts    r(r�z%PyShellEditorWindow.clear_file_breaks�s�����	��9�D��w�'�H��
��	�	������!�D���O�O�G�U�C�0�0�0�
��
�*�1�:���'�'��1�1�1�1�1��
�������	�	s�+B�B	c��|j}|jj}	t|j��5}|���}ddd��n#1swxYwYn#t$rg}YnwxYw	t|jd��5}|D]/}|�|dz��s|�|���0|�	��|j}|r+|�|dzt|��zdz��ddd��dS#1swxYwYdS#t$r_}t|jdd��s>d|j_
tjdd	t|��z|j�
��Yd}~dSYd}~dSd}~wwxYw)z#Save breakpoints when file is savedN�w�=�
�breakpoint_error_displayedFTz
IDLE Errorz$Unable to update breakpoint list:
%s)�titler$�parent)rHrUr&�openrT�	readlinesr#�
startswithr!�update_breakpoints�str�getattr�rootr�r
�	showerrorrJ)rF�breaksr&�fp�lines�new_filer�errs        r(�store_file_breaksz%PyShellEditorWindow.store_file_breaks�so��$�!���7�#��	��d�)�*�*�
'�b�������
'�
'�
'�
'�
'�
'�
'�
'�
'�
'�
'����
'�
'�
'�
'����	�	�	��E�E�E�	����	&��d�)�3�/�/�
H�8�!�-�-�D��?�?�8�c�>�:�:�-� ���t�,�,�,���'�'�)�)�)��)���H��N�N�8�c�>�C��K�K�#?�$�#F�G�G�G�
H�
H�
H�
H�
H�
H�
H�
H�
H�
H�
H�
H����
H�
H�
H�
H�
H�
H���	&�	&�	&��4�9�&B�E�J�J�
&�7;��	�4��$�<�C��c�(�(�#��9�&�&�&�&�&�&�&�&�&�&�
&�
&�
&�
&�
&�
&�����	&���sq�A�A
�A�
A�A�A�A�A%�$A%�)D�>A;D�9D�D
�
D�
D
�D�
E<�AE7�7E<c���|j���|j�dS|jj}|�dStj�|j��r�t|j��5}|�	��}ddd��n#1swxYwY|D]]}|�
|dz��rAt|t|��dzd���}|D]}|�
|����\dSdS)Nr�r)rJr8rUr&rPrQ�isfilerTr�r�r��eval�lenrs)rFr&r�r�r�breakpoint_linenumbers�breakpoint_linenumbers       r(rDz'PyShellEditorWindow.restore_file_breakssQ���	�������7�?��F��7�#�����F�
�7�>�>�$�-�.�.�	C��d�)�*�*�
'�b�������
'�
'�
'�
'�
'�
'�
'�
'�
'�
'�
'����
'�
'�
'�
'��
C�
C���?�?�8�c�>�2�2�C�-1�$�s�8�}�}�Q��7G�7G�2H�-I�-I�*�1G�C�C�-��+�+�,A�B�B�B�B��	C�	C�
C�
Cs�+B�B�Bc�v�|j}|�d��}|�|��}||_dS)z3Retrieves all the breakpoints in the current windowreN)rJ�
tag_ranges�ranges_to_linenumbersrH)rFrJ�ranges�linenumber_lists    r(r�z&PyShellEditorWindow.update_breakpoints"s;���y������)�)���4�4�V�<�<��*����r0c�:�g}tdt|��d��D]y}tt||j����}tt||dzj����}||kr |�|��|dz
}||k� �z|S)Nr�r)�ranger�rxry�stringrp)rFr�r�rnr'�ends      r(r�z)PyShellEditorWindow.ranges_to_linenumbers)s������1�c�&�k�k�1�-�-�	�	�E���v�e�}�3�4�4�5�5�F��e�F�5��7�O�2�3�3�4�4�C��3�,�,����V�$�$�$��!����3�,�,���r0c�V�|���tj|��dS)z7Extend base method - clear breaks when module is closedN)r�r�_close�rFs r(r�zPyShellEditorWindow._close:s+����� � � ���D�!�!�!�!�!r0)TrC)�__name__�
__module__�__qualname__�__doc__rI�rmenu_specsrXrsrLrMr�r�rDr�r�r��r0r(r>r>�s�������<�<�%�%�%�(���K�
+�
+�
+�
+����$�$�$�$�����&
�
�
�(&�(&�(&�TC�C�C�"+�+�+����""�"�"�"�"r0r>c�"�eZdZdZeZdZdd�ZdS)�PyShellFileListz8Extend base class: IDLE supports a shell and breakpointsNc���|jr|jj���n6t|��|_|jr|j���sdS|jSrC)rq�top�wakeup�PyShell�begin�rFrzs  r(rOzPyShellFileList.open_shellIs`���<�	 ��L��#�#�%�%�%�%�"�4�=�=�D�L��|�
 ��|�)�)�+�+� ��4��|�r0rC)r�r�r�r�r>rrqrOr�r0r(r�r�@s:������>�>�'�L��G������r0r�c��eZdZdZd�Zd�ZdS)�ModifiedColorDelegatorz8Extend base class: colorizer for the shell window itselfc��|�ddd��|�ddd��tj|��dS)N�TODOr��iomark�SYNC)r~rmr�recolorize_mainr�s r(r�z&ModifiedColorDelegator.recolorize_mainVsE�������x�0�0�0����V�U�H�-�-�-��&�t�,�,�,�,�,r0c�H�|jD]}|�|dd���dS)Nr�r�)�tagdefsr~)rF�tags  r(�removecolorsz#ModifiedColorDelegator.removecolors[s6���<�	2�	2�C��O�O�C��5�1�1�1�1�	2�	2r0N)r�r�r�r�r�r�r�r0r(r�r�Ts8������>�>�-�-�-�
2�2�2�2�2r0r�c�2��eZdZdZdd�Zdd�Z�fd�Z�xZS)�ModifiedUndoDelegatorz;Extend base class: forbid insert/delete before the I/O markNc���	|j�|dd��r|j���dSn#t$rYnwxYwt	j||||��dS�N�<r�)�delegate�comparerw�TclErrorrrv�rFrn�chars�tagss    r(rvzModifiedUndoDelegator.insertcs���	��}�$�$�U�C��:�:�
��
�"�"�$�$�$���
���	�	�	��D�	������T�5�%��6�6�6�6�6��5:�
A�Ac���	|j�|dd��r|j���dSn#t$rYnwxYwt	j|||��dSr�)r�r�rwr�r�delete)rF�index1�index2s   r(r�zModifiedUndoDelegator.deletels~��	��}�$�$�V�S�(�;�;�
��
�"�"�$�$�$���
���	�	�	��D�	������T�6�6�2�2�2�2�2r�c����|jj��fd�|j_	t���|���|j_dS#�|j_wxYw)Nc����||d��S�N�stdinr�)rnr��orig_inserts  �r(�<lambda>z2ModifiedUndoDelegator.undo_event.<locals>.<lambda>|s�����U�E�7�!C�!C�r0)r�rv�super�
undo_event)rFrzr��	__class__s  @�r(r�z ModifiedUndoDelegator.undo_eventusi����
�m�*��C�C�C�C�	
�
��	/��G�G���u�%�%�%�#.�D�M� � � ��;�D�M� �.�.�.�.s�!A�ArC)r�r�r�r�rvr�r��
__classcell__�r�s@r(r�r�asf�������A�A�7�7�7�7�3�3�3�3�/�/�/�/�/�/�/�/�/r0r�c��eZdZdZdd�ZdS)�UserInputTaggingDelegatorz.Delegator used to tag user input with "stdin".Nc�F�|�d}|j�|||��dSr�)r�rvr�s    r(rvz UserInputTaggingDelegator.insert�s,���<��D��
���U�E�4�0�0�0�0�0r0rC)r�r�r�r�rvr�r0r(r�r��s.������8�8�1�1�1�1�1�1r0r�c��eZdZd�ZdS)�MyRPCClientc��t�)z0Override the base class - just re-raise EOFError)�EOFErrorr�s r(�
handle_EOFzMyRPCClient.handle_EOF�s���r0N)r�r�r�r�r�r0r(r�r��s#����������r0r�c��d|pd�d�}|t|��kr4t|t|��z
d��\}}||zdz�|�|dz��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�mods     r(�restart_liner��sv��0��+�G�
/�
/�
/�C���C������5�#�c�(�(�?�Q�/�/���S��s�7�C�-�/��/�c�#�g�/�/�/��3�B�3�x�r0c���eZdZd�ZdZdZdZd�Zd�Zd�Z	d"d�Z
d	�Zd
�Zd�Z
d�Zd#d
�ZdZd�ZdZd�Zd�Zd�Zd�ZdZd�Zd$d�Zd�Zd�Zd�Zd$d�Zd�Zd�Zd�Z d�Z!d�Z"d�Z#d �Z$d!�Z%dS)%�ModifiedInterpreterc���||_tjdj}t	j||���d|_d|_t|_	|j
jj|_
dS)Nr)�localsF)�	tkconsole�sys�modules�__dict__rrI�
restarting�subprocess_arglist�PORT�port�compile�compiler�flags�original_compiler_flags)rFr�r�s   r(rIzModifiedInterpreter.__init__�sZ��"�����Z�(�1���'��V�<�<�<�<����"&�����	�'+�|�'<�'B��$�$�$r0Nc��|j�|���|_tj|j��|_dSrC)r��build_subprocess_arglist�
subprocess�Popen�
rpcsubprocr�s r(�spawn_subprocessz$ModifiedInterpreter.spawn_subprocess�s8���"�*�&*�&C�&C�&E�&E�D�#�$�*�4�+B�C�C����r0c���|jdks
Jd���d�tjD��}tjddddd�	��}d
|�d�}tjg|zd|t
|j��gzS)
Nrz/Socket should have been assigned a port number.c��g|]}d|z��S)z-Wr�)�.0�ss  r(�
<listcomp>z@ModifiedInterpreter.build_subprocess_arglist.<locals>.<listcomp>�s��/�/�/�!�T�A�X�/�/�/r0�main�Generalzdelete-exitfuncF�bool)�default�typez#__import__('idlelib.run').run.main(�)�-c)r�r��warnoptionsr�	GetOption�
executabler�)rFr��	del_exitf�commands    r(rz,ModifiedInterpreter.build_subprocess_arglist�s����	�1����=����/�/�s��/�/�/���&�v�y�:K�/4�6�C�C�C�	�F�	�F�F�F�����!�#�t�W�c�$�)�n�n�&E�E�Er0c���t|jf}td��D]<}tj|��	t|��|_n&#t$rY�9wxYw|���dS|jj	�
��d|_tdkr5|jj	�tjtjd��|���|jj	�d��	|j���n%#t&$r|���YdSwxYw|j�d|j��|j�d|jj��|j�d|jj��|j�d|jj��|j�d	|jj��|j�d
t6��|j�d|��|�d�
��|���|jS)N�rr�
�consoler��stdout�stderrrNr4rrT��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�rrrNr4�
transfer_path�poll_subprocess)rF�addr�is   r(�start_subprocessz$ModifiedInterpreter.start_subprocess�sE���d�i� ���q���		�		�A��J�q�M�M�M�
�)�$�/�/�������
�
�
���
����
�+�+�-�-�-��4��K�.�:�:�<�<�Q�?��	��1�9�9�

�K�&�1�1�&�2C�+1�+>��
C�
C�
C�������	
��"�-�-�b�1�1�1�	��K��� � � � ���	�	�	��,�,�.�.�.��4�4�	����	
����Y���7�7�7�����W�d�n�&:�;�;�;�����X�t�~�'<�=�=�=�����X�t�~�'<�=�=�=�����W�d�n�&:�;�;�;�����[�)�4�4�4�����X�t�,�,�,����D��)�)�)��������{�s#�A�
A�A�D(�(E
�	E
Frbc�
�|jr|jSd|_|���}|r"	tj|j��n#YnxYw|j���|���|j}|j}d|_|�	��	|j�
��n%#t$r|���YdSwxYw|�
|���|���|j�dd��|�d��|�t%|j|����|j�dd��|j�dd��|s|���|r-tj|j��|���|j|jj_d|_|jS)	NTFrr��end-1cr��restart�left)r�r"�getdebuggerr�close_subprocess_debugger�close�terminate_subprocessr��	executingrr+r,r-r/�
stop_readlinerJr�r!r�r��mark_set�mark_gravity�
showprompt�restart_subprocess_debugger�load_breakpointsr�r�r�r�)rFrr&rtr�
was_executings      r(�restart_subprocessz&ModifiedInterpreter.restart_subprocess�s���?�	��;������ � �"�"���	�
��4�T�[�A�A�A�A��
��������������!�!�#�#�#��.���)�
�!���������	��K��� � � � ���	�	�	��,�,�.�.�.��4�4�	����	
���H��-�-�-�����������H�h�/�/�/��
�
�d�����
�
�l�7�=�(�;�;�<�<�<�����i��2�2�2���!�!�)�V�4�4�4��	!���� � � ��	%��2�4�;�?�?�?��"�"�$�$�$�&*�&B����#�����{�s�A�A�%B?�?C!� C!c�@�|j�dddi��dS)N�exec�interrupt_the_serverr�)r"�
remotecallr�s r(�__request_interruptz'ModifiedInterpreter.__request_interrupts%������v�'=�r�2�F�F�F�F�Fr0c�^�tj|j������dS)N)�target)�	threading�Thread�'_ModifiedInterpreter__request_interrupt�startr�s r(�interrupt_subprocessz(ModifiedInterpreter.interrupt_subprocesss+����� 8�9�9�9�?�?�A�A�A�A�Ar0c�`�|j�$|jj�|j��	|jj���n#t$rYnwxYw	|j���n#t$rYnwxYw|���d|j_	d|_dS)NF)
�_afteridr�rJ�after_cancelr"r$r:r"r;r<r�s r(�kill_subprocessz#ModifiedInterpreter.kill_subprocesss����=�$��N��,�,�T�]�;�;�;�	��K�&�,�,�.�.�.�.���	�	�	��D�	����	��K���������	�	�	��D�	�����!�!�#�#�#�#(��� �����s#�A�
A�A�A7�7
B�Bc��	|j���	|j���dS#t$rYdSwxYw#t$rYdSwxYw)z"Make sure subprocess is terminatedN)r�kill�waitr#r�s r(r;z(ModifiedInterpreter.terminate_subprocess+s���		��O� � �"�"�"�

���$�$�&�&�&�&�&���
�
�
����
�����
�	�	�	��F�F�	���s �A�7�
A�A�
A�Ac��|r#dg}|�tj��ntj}|�d�|����dS)NrbzTif 1:
        import sys as _sys
        _sys.path = {!r}
        del _sys
        
)�extendr�rQ�
runcommand�format)rFrrQs   r(r/z!ModifiedInterpreter.transfer_path8sa���	��4�D��K�K���!�!�!�!��8�D������f�T�l�l�		�	�	�	�	r0c�@�|j}|�dS	|�|jd���}nB#ttt
f$r(|jjrYdSd}|���YnwxYw|r�|j�	��d|_|\}}|jj
}|dkr!|�tt|��|���nk|dkr/|j�
d��r|���n6|dkr0d}t||tj���t|||���	|j���n#t$$rYnwxYw|jjs6|jj�|jj|j��|_dSdS)	Ng�������?)rW�OKr�	EXCEPTION�<<toggle-jit-stack-viewer>>�ERRORz/pyshell.ModifiedInterpreter: Subprocess ERROR:
)r"�pollresponse�
active_seqr�r#�KeyboardInterruptr��closingrD�resetoutputr�print�repr�getvar�remote_stack_viewerr��
__stderr__�endexecutingr"rJ�after�pollintervalr0rR)rF�clt�response�how�whatr�errmsgs       r(r0z#ModifiedInterpreter.poll_subprocessGs����k���;��F�	&��'�'���d�'�C�C�H�H���'�#4�5�	&�	&�	&��~�%�
�����H��#�#�%�%�%�%�%�
	&�����	��N�&�&�(�(�(�"�D�O� �I�C���n�,�G��d�{�{��#��$�t�*�*�7�3�3�3�3����#�#��>�(�(�)F�G�G�/��,�,�.�.�.������K���f�d���8�8�8�8��f�d��1�1�1�1�
���+�+�-�-�-�-��!�
�
�
���
�����~�%�	C� �N�/�5�5���+�T�-A�C�C�D�M�M�M�	C�	Cs'�*�#A)�A)�(A)�2E�
E�Ec��||_dSrCr)rFrs  r(�setdebuggerzModifiedInterpreter.setdebuggeros
�� ��
�
�
r0c��|jSrCrr�s r(r8zModifiedInterpreter.getdebuggerrs
���}�r0c�P�|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�rJrlrir�s r(�open_remote_stack_viewerz,ModifiedInterpreter.open_remote_stack_viewerus'��	
���!�!�#�t�'?�@�@�@��r0c��ddlm}|j�dddi��}|� |jj���dS|�|j|��}ddlm	}m
}t|jj��}tj
��}tj|d��d}|||d�	��}	|	j�d
d���||	jd|��}
|
���dS)
Nr)�
debugobj_rrF�stackviewer)rN)�ScrolledCanvas�TreeNode�normalrd)�bg�highlightthicknessr�both)�expand�fill)�idlelibryr"�remotequeuer�r�rw�StubObjectTreeItem�idlelib.treer{r|�Toplevelrrfrg�frame�pack�canvasr�)rFry�oid�itemr{r|r�rjrd�sc�nodes           r(riz'ModifiedInterpreter.remote_stack_viewer�s
��&�&�&�&�&�&��k�%�%�f�m�Z��L�L���;��N��$�$�&�&�&��F��,�,�T�[�#�>�>��9�9�9�9�9�9�9�9��t�~�*�+�+���%�'�'���*�5�(�;�;�L�I�
�
�^�C�J�1�
E�
E�
E��
��
�
�Q�V�
�,�,�,��x��	�4��.�.�����
�
�
�
�
r0rc�\�|�|��}|�||��dS)z1Like runsource() but assumes complete exec sourceN)�stuffsource�execfile�rF�sourcer&s   r(�
execsourcezModifiedInterpreter.execsource�s/���#�#�F�+�+���
�
�h��'�'�'�'�'r0c�,�|�ptj|��5}|���}tr)dtj�|���d�|zdz}ddd��n#1swxYwY	t||d��}|�|��dS#ttf$rf|j���td|jj���tj||��|j���YdSwxYw)zExecute an existing fileNz__file__ = r'''z'''
z
del __file__rFzB*** Error in script or command!
Traceback (most recent call last):r)�tokenizer��read�use_subprocessrPrQ�abspathr��runcode�
OverflowError�SyntaxErrorr�rerfrr�showsyntaxerrorr@)rFr&r�r��codes     r(r�zModifiedInterpreter.execfile�sh���>���x�(�(�
;�B�������!�;�P������0I�0I�P�P�P� &�'�)9�:�F�
;�
;�
;�
;�
;�
;�
;�
;�
;�
;�
;����
;�
;�
;�
;�

	��6�8�V�4�4�D�
�L�L���������{�+�	(�	(�	(��N�&�&�(�(�(��6��~�,�
.�
.�
.�
.�
#�2�4��B�B�B��N�%�%�'�'�'�'�'�'�
	(���s%�AA(�(A,�/A,�4B�A3D�Dc��|�|��}t|t��sJ�tj|||��S)zBExtend base class method: Stuff the source in the line cache first)r��
isinstancer�r�	runsourcer�s   r(r�zModifiedInterpreter.runsource�sB���#�#�F�+�+���&�#�&�&�&�&�&�&�/��f�h�G�G�Gr0c��d|jz}|jdz|_|�d��}t|��dzd||ftj|<|S)z"Stuff source in the filename cachez<pyshell#%d>rr�r)�gid�splitr�r4r5)rFr�r&r�s    r(r�zModifiedInterpreter.stuffsource�sP��!�D�H�,���8�a�<������T�"�"��$'��K�K��M�1�e�X�$E�	���!��r0c�V�|�d�|����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)rZr[�rFr&s  r(�prepend_syspathz#ModifiedInterpreter.prepend_syspath�s6�������&��"�"�	$�	$�	$�	$�	$r0c���|j}|j}|�ddd��tj��\}}}t|dd��p|pd}t|dd��pd}t|d	d��pd
}	|	d
kr|dz
}|dkr	d|	dz
z}
n
d|dz
|	dz
fz}
|�||
��|���|�d
|z��|�	��dS)z�Override Interactive Interpreter method: Use Colorizing

        Color the offending position instead of printing it and pointing at it
        with a caret.

        r`r�r��msgrbz<no detail available>r'r�offsetrziomark + %d charsz&iomark linestart + %d lines + %d charszSyntaxError: %s
N)
r�rJr~r��exc_infor��colorize_syntax_errorrer!r@)rFr&r�rJr�value�tbr�r'r��poss           r(r�z#ModifiedInterpreter.showsyntaxerror�s���N�	��~��������.�.�.��,�.�.���e�R��e�U�B�'�'�K�5�K�4K�����"�-�-�2������"�-�-�2����Q�;�;��a�K�F��Q�;�;�%����2�C�C�:��!�8�V�A�X�&�'�C��'�'��c�2�2�2��������
�
�&��,�-�-�-��������r0c���|j���|���tj|��|j�d��r|j���dSdS)z1Extend base class method to reset output properlyr_N)r�re�checklinecacher�
showtracebackrh�open_stack_viewerr�s r(r�z!ModifiedInterpreter.showtraceback�sv����"�"�$�$�$��������,�T�2�2�2��>� � �!>�?�?�	/��N�,�,�.�.�.�.�.�	/�	/r0c�z�tj}t|��D]}|dd�|dd�zdkr||=�dS)z%Remove keys other than '<pyshell#n>'.Nrr2r3)r4r5r6)rFr5r;s   r(r�z"ModifiedInterpreter.checklinecache�sP�������;�;�	�	�C��2�A�2�w��R�S�S��!�T�)�)��#�J��	�	r0c��|jjr|���dS|jr|j�dd|fi��nt||j��dS)z*Run the code without invoking the debuggerrrFr�r)r�r<�display_executing_dialogr"r�rFr�)rFr�s  r(rZzModifiedInterpreter.runcommand�sj���>�#�	��)�)�+�+�+��1��;�	$��K�#�#�F�I��w��C�C�C�C���t�{�#�#�#��qr0c��|jjr|���|���|j}	|j���|s+|j�$|j�dd|fi��|_n.|r|j	||j
��nt||j
��n�#t$rH|jj
s8tjddd|jj���r�|���n�Yn�t$rIt'd|jj�	��|���|j���nH|jjr(d
|j_t'd|jj�	��n|���YnxYwt$s-	|j���dS#t.$rYdSwxYwdS#t$s+	|j���w#t.$rYwwxYwwxYw)�Override base class methodNrFr�zExit?zDo you want to exit altogether?�yes�rr�z IDLE internal error in runcode()rFrc)r�r<rDr�r�beginexecutingr"�
asyncqueuerb�runr�rF�
SystemExitrdr
�askyesnorJr�r�rfrrk�canceledr")rFr�rs   r(r�zModifiedInterpreter.runcodeso���>�#�	&��#�#�%�%�%��������=��&	��N�)�)�+�+�+��
(��� 7�"&�+�"8�"8���9=���#E�#E�����
(����T�4�;�/�/�/�/��T�4�;�'�'�'����	�	�	��>�)�

��&��5�!��>�.�	0�0�0�)�
��&�&�(�(�(�(��)�(�	)��

)��8��>�0�2�2�2�2��"�"�$�$�$���+�+�-�-�-�-��>�*�)�.3�D�N�+��-�D�N�4I�J�J�J�J�J��&�&�(�(�(������!�
���N�/�/�1�1�1�1�1��%�����D�D�����
�
��>�
���N�/�/�1�1�1�1��%�����D�����
���sb�A4B2�1G�2AF�G�BF�G�)G�
G�G�H� G:�9H�:
H�H�H�Hc�@�|jj�|��S)r�)r�rr!)rFr	s  r(r!zModifiedInterpreter.write.s���~�$�*�*�1�-�-�-r0c�H�tjdd|jj���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�rJr�s r(r#z.ModifiedInterpreter.display_port_binding_error2s8���� �
/��>�&�	(�	(�	(�	(�	(�	(r0c�H�tjdd|jj���dS)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�s r(r-z/ModifiedInterpreter.display_no_subprocess_error=s9����)�
J��>�&�	(�	(�	(�	(�	(�	(r0c�H�tjdd|jj���dS)NzAlready executingzYThe Python Shell window is already executing a command; please wait until it is finished.r�r�r�s r(r�z,ModifiedInterpreter.display_executing_dialogEs6�����
0��>�&�		(�	(�	(�	(�	(�	(r0)Frb)FrC)&r�r�r�rIrRr"rrrr3rDrNrPrTr;r/rbr0rrtr8rwrir�r�r�r�r�r�r�r�r�rZr�r!r#r-r�r�r0r(r�r��s������C�C�C��H�
�F��J�D�D�D�

F�
F�
F�)�)�)�V*�*�*�*�XG�G�G�B�B�B�
�
�
���������J�$C�$C�$C�L�H�!�!�!����������"�C�(�(�(�
����(H�H�H����
$�
$�
$�����4/�/�/����
�
�
�,�,�,�\.�.�.�	(�	(�	(�(�(�(�(�(�(�(�(r0r�c	�X��eZdZddlmZde��zZeZe	Z
gd�Zej
dgzZ
deeejd�e
������zZe
�ed��[d	Zd
ZddlmZddlmZd;d�Z�fd�Z�fd�Zd�Zd�Zd�Zd;d�Z d	Z!d	Z"d	Z#d	Z$d	Z%d	Z&d�Z'd�Z(d;d�Z)d�Z*d;d�Z+d�Z,d�Z-d�Z.d�Z/d�Z0d�Z1d �Z2d!�Z3d"�Z4d#Z5d$�Z6d%�Z7d&�Z8d'�Z9d;d(�Z:d)�Z;d*�Z<d+�Z=d,�Z>e?j@d-��ZAd.�ZBd;d/�ZCd;d0�ZDd;d1�ZEd2�ZFd3�ZGd4�ZHd<d6�ZI�fd7�ZJ�fd8�ZKd;d9�ZLd:�ZM�xZNS)=r�r)�SqueezerzIDLE Shell ))r�_File)�edit�_Edit)rt�_Debug)�options�_Options)�window�_Window)�help�_Help)�Squeeze�<<squeeze-current-text>>rc��|ddkS)Nrr\r�)�
rmenu_items r(r�zPyShell.<lambda>es��:�a�=�F�2�r0)zCopy with prompts�<<copy-with-prompts>>r]Fr�)�History)�ShellSidebarNc�8�tr/|j}|dddkr|�dd��t|��|_|�@t��}t
|��|���t|��}d|_	tj||dd��d|_d|_
ttd��rtjnd|_|j�d	��d
|_|j|_|j}|�d���|�d
|j��|�d|j��|�d|j��|�d|j��|�d|j��|�d|j��|�d|j��|�d|j��tr6|�d|j ��|�d|j!��|�"|��|_#|�d|j$��tj%|_&tj'|_(tj)|_*ddl+m,}t[|d|j.|j/��|_)ta|d|j.|j/��|_%ta|d|j.d��|_'ta|d|j.|j/��|_1ts3|j%t_%|j't_'|j)t_)	ddl2}|j3|_4n#tj5t_'�xYw|�6|j��|_7d|_8|�9|��|_	|j:j;j|j_|j:�<t{����dS)Nr�r�shell)r��She_llF��ps1z>>>
r�r2�char)�wrapz<<newline-and-indent>>z<<plain-newline-and-indent>>z<<interrupt-execution>>z<<end-of-file>>z<<open-stack-viewer>>�<<toggle-debugger>>r_r�z<<view-restart>>z<<restart-shell>>r�)�iomenur�rr�backslashreplacer�2)>r��
menu_specsrvr�rr�Tkr�withdrawr��
shell_sidebarrrI�usetabs�indentwidth�hasattrr�r��sys_ps1r��prompt_last_line�promptrJ�	configurerK�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_stdinr�r�r�encoding�errorsrr�pydoc�
plainpager�pagerrjr��historyrmr��perr��insertfilterr�)rFrN�msr�rJr�rs       r(rIzPyShell.__init__ss����	2���B��!�u�Q�x�7�"�"��	�	�!�0�1�1�1�)�$�/�/����=��4�4�D��$�����M�M�O�O�O�#�D�)�)�E�!�����d�E�4��6�6�6�������")�#�u�"5�"5�B�s�w�w�7��� $�� 2� 2�4� 8� 8�� <����l����y�����F��#�#�#��	�	�*�D�,?�@�@�@��	�	�0�$�2H�I�I�I��	�	�+�T�-A�B�B�B��	�	�#�T�%6�7�7�7��	�	�)�4�+A�B�B�B��	�	�'��)=�>�>�>��	�	�/��1M�N�N�N��	�	�)�4�+J�K�K�K��	?��I�I�(�$�*@�A�A�A��I�I�)�4�+=�>�>�>��
�
�d�+�+��
��	�	�,��1�	3�	3�	3��:����:����)���"�"�"�"�"�"�!�$��"(�/�6�=�B�B��
�#�D�(�$*�O�V�]�D�D���#�D�(�$*�O�5G�I�I���$�T�9�%+�_�f�m�E�E����	#���C�J���C�J��
�C�I�	��L�L�L��*�E�K�K��	���C�J������|�|�D�I�.�.������!�.�.�t�4�4���
 �8�<�.��	������7�9�9�:�:�:�:�:s�,M=�=Nc���t�����|j�|j���dSdSrC)r��	ResetFontr��update_font�rFr�s �r(rzPyShell.ResetFont�sE���
����������)���*�*�,�,�,�,�,�*�)r0c���t�����tj��}ddd�tj|d��tj|d��tj|d��d�}|���D]\}}|jj|fi|���|j�|j�	��dSdS)N)rdrcrrr})r�rrr)
r��ResetColorizerrrfrg�itemsrJ�
tag_configurer��
update_colors)rFrj�
tag_colorsr��tag_colors_configr�s     �r(rzPyShell.ResetColorizer�s����
����� � � ��%�'�'��"&�d�;�;��)�%��:�:��)�%��:�:��*�5�(�;�;�	
�
�
�'1�&6�&6�&8�&8�	>�	>�"�C�"�#�D�I�#�C�=�=�+<�=�=�=�=���)���,�,�.�.�.�.�.�*�)r0c�<�tj|jd���dS)Nr�)�insert_tagsra)rrJr�s  r(�
replace_eventzPyShell.replace_event�s�����	�w�7�7�7�7��wr0c�,�tjd���S)NT)�
shell_only)r�
GetExtensionsr�s r(�get_standard_extension_namesz$PyShell.get_standard_extension_names�s���%��6�6�6�6r0c�b���j�||��}ttt	|����tt	|������}�fd�|D��}d�d�t
||�����D����dzS)z6Return text between first and last with prompts added.c�N��g|]!}�jj�|����"Sr�)r��line_prompts�get)rr'rFs  �r(r
z+PyShell.get_prompt_text.<locals>.<listcomp>�s=���
�
�
��
��+�/�/��7�7�
�
�
r0r�c3�2K�|]\}}|�|n|�d|��V��dS)N� r�)rr�rs   r(�	<genexpr>z*PyShell.get_prompt_text.<locals>.<genexpr>�sP����
�
�����N�D�D�6�(:�(:�D�(:�(:�
�
�
�
�
�
r0)rJrr�rxryrR�zip�
splitlines)rF�first�lastrJ�lineno_range�promptss`     r(�get_prompt_textzPyShell.get_prompt_text�s�����y�}�}�U�D�)�)�����e�������d��������
�
�
�
�&�
�
�
���y�y�
�
� #�G�T�_�_�->�->� ?� ?�
�
�
�
�
�
��	r0c�0�|j}|�d��}|�dS|�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)rJrn�clipboard_clearr&�clipboard_append)rFrzrJ�selfirst�sellast�prompt_texts      r(r�z"PyShell.copy_with_prompts_callback�s����y���:�:�3�4�4�����F��*�*�Z�(�(���2�;�#����j�j�!;�<�<�G��������*�*�8�W�=�=�����k�*�*�*�*�*r0c�
�|adSrC�r )rF�streams  r(�set_warning_streamzPyShell.set_warning_stream
s�����r0c��tSrCr0r�s r(�get_warning_streamzPyShell.get_warning_streams���r0c��|jr2tjdd|j���|���dS|j���}|r|���dS|���dS)NzDon't debug nowz*You can only toggle the debugger when idler�ra)	r<r
r�rJ�set_debugger_indicatorrrr8�close_debugger�
open_debugger)rFrz�dbs   r(r�zPyShell.toggle_debuggers����>�	%�� �!2�<��y�
"�
"�
"�
"�
�'�'�)�)�)��7���(�(�*�*�B��
%��#�#�%�%�%�%�%��"�"�$�$�$�$�$r0c�h�|j���}|�d|��dS)Nr�)rrr8�setvar�rFr9s  r(r6zPyShell.set_debugger_indicators4��
�[�
$�
$�
&�
&�����)�2�v�:�6�6�6�6�6r0c��dSrCr�r�s  r(r�zPyShell.toggle_jit_stack_viewer#s���r0c��|j���}|r�|j�d��|���|jjrtj|jj��|���|j�	d��|j
|_|���|�
��dS)Nz[DEBUG OFF]
)rrr8rtr:r"r�close_remote_debuggerrerr!r�r�r@r6r<s  r(r7zPyShell.close_debugger&s���
�[�
$�
$�
&�
&��
�	��K�#�#�D�)�)�)��H�H�J�J�J��{�!�
E��0���1C�D�D�D��������L����/�/�/��,�D�K��O�O�����#�#�%�%�%�%�%r0c�P�|jjr tj|jj|��}nt	j|��}|j�|��|���d|jz|_	|�
��|���dS)Nz[DEBUG ON]
)rrr"r�start_remote_debuggerr�DebuggerrtrBr�r�r@r6)rF�dbg_guis  r(r8zPyShell.open_debugger3s����;��	.� �6�t�{�7I�;?�A�A�G�G��'��-�-�G������(�(�(�� � �"�"�"�$�t�|�3����������#�#�%�%�%�%�%r0c�J�|jrdnd}|�dd|��dS)N�disabledr}rtz*tack*iewer)r<�update_menu_state)rF�states  r(�debug_menu_postcommandzPyShell.debug_menu_postcommand?s0��"�n�:�
�
�(�����w�
�u�=�=�=�=�=r0c�<�|���d|_dS)�Helper for ModifiedInterpreterTN)rer<r�s r(r�zPyShell.beginexecutingCs������������r0c�J�d|_d|_|���dS)rJFN)r<r�r@r�s r(rkzPyShell.endexecutingHs&�������
��������r0c���|jr#tjddd|j���}|durdS|���d|_d|_tj|��S)zExtend EditorWindow.close()zKill?z7Your program is still running!
 Do you want to kill it?�okr�F�cancelT)	r<r
�askokcancelrJr=r�rdrr:)rFros  r(r:z
PyShell.closeNst���>�	 �!�-��J���y�	"�"�"�H�
�5� � ��x���������
�����!�$�'�'�'r0c�>�|���tr|j���|jt
_|jt
_|j	t
_
d|_d|_d|j_
d|_tj|��dS)zEExtend EditorWindow._close(), shut down debugger and execution serverN)r7r�rrrTr�r�rr�rr�r�rrNrqrrr�r�s r(r�zPyShell._close]s����������	*��K�'�'�)�)�)��%��
��%��
��O��	�������!��
�������D�!�!�!�!�!r0c��dS)z8Override EditorWindow method: never remove the colorizerTr�r�s  r(�ispythonsourcezPyShell.ispythonsourcems���tr0c��|jSrC)�shell_titler�s r(�short_titlezPyShell.short_titleqs����r0zHType "help", "copyright", "credits" or "license()" for more information.c
��|j�dd��|���tr4d}|j���}|s|���dSnd}tjt_|�
dtj�dtj�d|j
�d|����|j���|���d	dl}d
|_d|_d
S)Nr�rvrbFz�==== 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 z on r�rT)rJr>rer�rrr3r:r�displayhookr�r!�version�platform�	COPYRIGHT�focus_forcer@�tkinter�_support_default_root�
_default_root)rF�nosub�clientr\s    r(r�z
PyShell.beginws����	���8�X�.�.�.��������	.��E��[�1�1�3�3�F��
��
�
�����u�
�'�E�"�o�C�O��
�
�
��K�K�K�����t�~�~�~�u�u�F�	G�	G�	G��	����������������(,��%� $����tr0c�X�|jsdSd|_|j���dS�NT)�reading�_stop_readline_flagr��quitr�s r(r=zPyShell.stop_readline�s,���|�	��F�#'�� ���
�
�����r0c�~�|j}	d|_|j���||_n#||_wxYw|jr	d|_dS|j�dd��}t
|��dkrd}|���|jrd|_tst�|jr	d|_d}|S)NTFrbr�r5rr�)rcr��mainlooprdrJrr�rer�r�rc�	endoffile)rFr:rs   r(�readlinezPyShell.readline�s����|��	 ��D�L��H�������D�L�L��4�D�L������#�	�',�D�$��2��y�}�}�X�x�0�0���t�9�9��>�>��D��������=�	(�!�D�M�!�
(�'�'��>�	�"�D�N��D��s� 1�	:c��dSrbr�r�s r(�isattyzPyShell.isatty�s���tr0c��	|j�ddd��rdSn#YnxYw|jsK|jsD|���|j�d��|���dSd|_d|_	|jrX|jj
rL|j���r|j���n|j�
��|jr|j���dS)N�	sel.firstz!=r(zKeyboardInterrupt
raFT)rJr�r<rcrerrr!r@rhr�r"r8rDrPr�rer�s  r(r�zPyShell.cancel_callback�s��	��y� � ��d�J�?�?�
���
��	��D������	�$�,�	��������K���3�4�4�4��O�O�����7������
��N�	3�t�{�1�	3��{�&�&�(�(�
3���.�.�0�0�0�0���0�0�2�2�2��<�	��H�M�M�O�O�O��ws�!�%c�H�|jr	|jsdS|j�ddd��r|j�ddd��sdS|js)|���|���n'd|_d|_|j�	��dS)Nr�z==rvr5FTra)
r<rcrJr�rer:r�rhr�rer�s  r(r�zPyShell.eof_callback�s����>�	�$�,�	��F��	�!�!�(�D�(�;�;�	��	�!�!�(�D�(�;�;�	��F��~�	��������J�J�L�L�L�L�!�D�M�!�D�N��H�M�M�O�O�O��wr0c��|jr6|j�dd��|j�d��n|�|��dS)Nrvr�ra)rcrJrv�see�newline_and_indent_eventr�s  r(r�zPyShell.linefeed_callback�sT���<�	1��I���X�t�,�,�,��I�M�M�(�#�#�#�#��)�)�%�0�0�0��wr0c��	�|jr	|jsdS	|j�dd��}|r4|j�ddd��r|�||��dSn#YnxYw|j�ddd���r�|j�d	d��}|�rB|j�dd|d
���rd|j�d��v�r|j�dd��}|r8|j�|d
d|d
��r|d
|d
f}|j�dd��}|rS|j�|d
d|d
��r+|d
|j�	|d
dz��f}|�|j�|d
|d
��|��dS|j�d	d��}|r�|j�dd|d
��r�|j�dd��}|rS|j�|d
d|d
��r+|d
|j�	|d
dz��f}|�|j�|d
|d
��|��dS|j�dd��}|rX|j�|d
dd��r6|�|j�|d
d��|��n/|�|j�dd��|��dS|j�ddd��r|j�
dd��|j�dd��}|r/|���s|j�dd��|j�ddd��r|�
|��dS|j�
dd��|jr6|j�dd��|j�d��n|�
|��|j���|jr|j���n|���dS)Nrmr(z<=r�rarvr��iomark linestartr�rrz>=rz+1czinsert lineendr|r5zend-1c linestartr�)r<rcrJrr��recall�
tag_prevrange�	tag_names�
tag_nextrangernr>�stripr�rqrvrp�update_idletasksr�re�runit)	rFrz�sel�prev�	prev_cons�	next_cons�next�indicesr	s	         r(r�zPyShell.enter_callback�s����>�	�$�,�	��F�	��)�-�-��Z�8�8�C��
#��9�$�$�Z��x�@�@�#��K�K��U�+�+�+�"�7���	��D�����9���X�s�,>�?�?�"	�
�9�*�*�7�H�=�=�D��

��I�%�%�h��T�!�W�=�=�

��T�Y�%8�%8��%B�%B�B�B� �I�3�3�I�x�H�H�	��3���!2�!2�9�Q�<��t�A�w�!O�!O�3�%�a�L�$�q�'�2�D� �I�3�3�I�x�H�H�	��L���!2�!2�9�Q�<��d�1�g�!N�!N�L� ��G�T�Y�_�_�Y�q�\�E�5I�%J�%J�K�D����D�I�M�M�$�q�'�4��7�;�;�U�C�C�C��w��9�*�*�7�H�=�=�D��
��	�)�)�*:�D�$�q�'�J�J�
� �I�3�3�I�?O�P�P�	��L���!2�!2�9�Q�<��d�1�g�!N�!N�L� ��G�T�Y�_�_�Y�q�\�E�5I�%J�%J�K�D����D�I�M�M�$�q�'�4��7�;�;�U�C�C�C��w��i�-�-�i�9K�L�L�G��
X��y� � ����T�3E�F�F�
X����D�I�M�M�'�!�*�6F�G�G��O�O�O�O����D�I�M�M�*<�>N�O�O�QV�W�W�W��7��9���X�s�H�5�5�	3��I���x��2�2�2�
�I�M�M�(�H�-�-���	1�Q�W�W�Y�Y�	1��I���X�x�0�0�0��9���X�s�,>�?�?�	��)�)�%�0�0�0��7��	���8�X�.�.�.��<�	1��I���X�t�,�,�,��I�M�M�(�#�#�#�#��)�)�%�0�0�0��	�"�"�$�$�$��<�	��H�M�M�O�O�O�O��J�J�L�L�L��ws�AA$�$A(c��tjdd|��}tjdd|��}|�d��}|j���	|j�ddd��|j�dd	��|j�d
d��}|����	d��r0|�
|��|j�d
d��}|j�d|d���|j
��t|��d
kr�tjd|d���d��}tjd|���d��}|d
d�D]g}|�|��r||t|��d�z}|j�dd|���z|j
���h|j�d��|j���dS#|j�d��|j���wxYw)Nz^\s*\nrbz\n\s*$r�r{r�r�rvr5r|�:rrz	^([ \t]*))�re�subr�rJ�undo_block_startr~r>r�rstrip�endswithrqrvrx�user_input_insert_tagsr��search�groupr�rp�undo_block_stop)rFr	rzr��prefix�orig_base_indent�new_base_indentrs        r(rtzPyShell.recall.sM���F�9�b�!�$�$���F�9�b�!�$�$������
�
���	�"�"�$�$�$�	(��I� � ���u�5�5�5��I���x��2�2�2��Y�]�]�#5�x�@�@�F��}�}���'�'��,�,�
E��-�-�e�4�4�4�����'9�8�D�D���I���X�u�Q�x�~�~�'7�'7�!�8�
:�
:�
:��5�z�z�A�~�~�#%�9�\�5��8�#D�#D�#J�#J�1�#M�#M� �#%�9�\�6�#B�#B�#H�#H��#K�#K��!�!�"�"�I�B�B�D����'7�8�8�N�.��c�:J�6K�6K�6L�6L�1M�M���I�$�$�X�t�d�k�k�m�m�/C�%)�%@�B�B�B�B�
�I�M�M�(�#�#�#��I�%�%�'�'�'�'�'��
�I�M�M�(�#�#�#��I�%�%�'�'�'�'���s
�F=I�5Jz[ \t]*(\n[ \t]*)?\Zc��|j�d��}|j�dd��}|j�d|��}|j�|��}|sY|j�|��dkr |j�|j|��|j	�
��dSdS)N�end-2cr�r5rbr�)rJrnr�_last_newline_rer�rrr�r~r�r��update_sidebar)rF�index_beforer�input_is_completes    r(rzz
PyShell.runitKs����y���x�0�0���y�}�}�X�x�0�0���$�(�(��T�2�2�� �K�1�1�$�7�7�� �	0��y�}�}�\�*�*�d�2�2��	�$�$�T�%@�,�O�O�O���-�-�/�/�/�/�/�	0�	0r0c���|jjr|j���Sddlm}	||jtj|j��n##tj
dd|j���YnxYwdS)Nr)�StackBrowserzNo stack tracez<There is no stack trace yet.
(sys.last_value is not defined)r�)rrr"ri�idlelib.stackviewerr�r�r��
last_valuerNr
r�rJ)rFrzr�s   r(r�zPyShell.open_stack_viewerWs����;��	5��;�2�2�4�4�4�4�4�4�4�4�4�	"��L���C�N�D�J�?�?�?�?��	"�� �!1�2��y�
"�
"�
"�
"�
"�
"�����ts�!A�A/c�n�|j�d��|j�d��dS)Nr�r6)rJrpr�s  r(r�zPyShell.view_restart_markes0���	�
�
�h�����	�
�
�i� � � � � r0c�<�|j�d���dS)z&Callback for Run/Restart Shell Cntl-F6TrN)rrrDr�s  r(r�zPyShell.restart_shellis!����&�&��&�5�5�5�5�5r0c���|���|j}|jr7|�|j��r|dt	|j���}|j�dd��|j�|��|j	�
��|j�dd��|���|j
���dS)Nrz	iomark-1crvr5)rer�r�r�r�rJrmrr!r�r�r>�set_line_and_columnrU�
reset_undo)rFr�s  r(r@zPyShell.showpromptms�������������<�	1�F�O�O�D�L�9�9�	1��/�c�$�,�/�/�/�/�0�F��	���)�[�1�1�1�����6�"�"�"���)�)�+�+�+��	���8�X�.�.�.�� � �"�"�"���������r0c��|jjj}t|dd���}d�|�|����}|�d��s|dz
}|jj�	d|d��dS)N�T)r��tabsize�expand_tabsr�rsr)
rrr�r�r
rRr�r�r�bottomrv)rFr�r��wrapper�wrapped_msgs     r(�show_warningzPyShell.show_warning{s�����%�+���E�1�$�G�G�G���i�i����S� 1� 1�2�2���#�#�D�)�)�	 ��4��K������1�;��I�I�I�I�Ir0c��|j�dd��}|jr|j�|��|j�d��dkr|j�dd��|j�dd��|���|j���dS)Nr�r5r�r�)	rJrr�storervr>r��ctip�remove_calltip_window)rFr�s  r(rezPyShell.resetoutput�s�������x��2�2���<�	'��L���v�&�&�&��9�=�=��"�"�d�*�*��I���X�t�,�,�,��	���8�X�.�.�.�� � �"�"�"��	�'�'�)�)�)�)�)r0r�c���	|j�dd��tj|||d��}|j�dd��n#�xYw|jrd|_t
st�|S)Nr��rightr7F)rJr?rr!r�r�rc)rFr	r��counts    r(r!z
PyShell.write�s���	��I�"�"�8�W�5�5�5� �&�t�Q��h�?�?�E��I�"�"�8�V�4�4�4�4��	������=�	(�!�D�M�!�
(�'�'��s�A
A�Ac���	|j�ddd��rdSn#t$rYdSwxYwt�����S)Nrmr�r�rE)rJr�r�r�r[r
s �r(r[zPyShell.rmenu_check_cut�sf���	��y� � ��c�8�<�<�
"�!�z�
"���	�	�	��:�:�	�����w�w�&�&�(�(�(s�"�
0�0c���|j�ddd��rdSt�����S)Nrvr�r�rE)rJr�r�r_r
s �r(r_zPyShell.rmenu_check_paste�s:����9���X�c�(�3�3�	��:��w�w�(�(�*�*�*r0c�j�|j���|j���dSrC)r��squeeze_current_textr�r�r�s  r(r�z"PyShell.squeeze_current_text_event�s1���
�*�*�,�,�,���)�)�+�+�+�+�+r0c�8�|j���dSrC)r�r�)rFrnrJr�s    r(�on_squeezed_expandzPyShell.on_squeezed_expand�s����)�)�+�+�+�+�+r0rC)r�)Or�r�r��idlelib.squeezerr�rrTr�rr�rr�rr�r�r6�	itertools�	takewhile�_idxrv�allow_line_numbersr��idlelib.historyr��idlelib.sidebarr�rIrrrrr&r�rcr<r�rhrdrdr2r4r�r6r�r7r8rHr�rkr:r�rRrUrZr�r=rirkr�r�r�r�rtr�r�r�rzr�r�r�r@r�rer!r[r_r�r�r�r�s@r(r�r�Ms0�������)�)�)�)�)�)��.�.�"2�"2�2�K�,�N�)�M����J��*�/�.��K�
�s�s�4�4�+�	�+�2�2�K�A�A������D����t�2�3�3�3�	
���$��(�'�'�'�'�'�,�,�,�,�,�,�L;�L;�L;�L;�\-�-�-�-�-�/�/�/�/�/� ���7�7�7����"+�+�+�+�(�G��I��H��I��G��� � � ����%�%�%�%�7�7�7�
�
�
�
�&�&�&�
&�
&�
&�>�>�>����
���
(�
(�
(�"�"�"� ��� � � �U�����4������.�������,
�
�
����M�M�M�^(�(�(�8"�r�z�"8�9�9��
0�
0�
0�����!�!�!�!�6�6�6�6����J�J�J�*�*�*�����)�)�)�)�)�+�+�+�+�+�
,�,�,�,�,�,�,�,�,�,�,r0r�c
��|jdkr3dD]2}|�|dd|�|d��z���1dSdS)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��clss  r(�
fix_x11_paster��sk�����%�%�-�	;�	;�C��O�O���8�����[�9�9�:�
;�
;�
;�
;�&�%�	;�	;r0a�
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�����ddl}ddlm}ddlm}ddlm}t
d��dad}d}d}d}d}d}		|�tj	dd�d��\}
}nQ#|j
$rD}td	|�d
t��tj
���tjd��Yd}~nd}~wwxYw|
D]�\}
}|
d
kr|}d}|
dkrd}d}|
dkrd}|
dkr7tj�t��tj��|
dkrd}|
dkrtdtj
���da|
dkrG|}t"j�|��rn#td|��tj��d}|
dkrd}	d}|
dkr|t(_d}��|r,|ddkr tj���}d}t1t3tj����D]>}t"j�tj|��tj|<�?|r%|ddkrdg|dd�zt_	n�|rd
g|zt_	n�|r|g|zt_	n�|r�d}g}|D]4}|�t"j�|�����5|D]O}t"j�|��}|tjvr tj�d|���PnAt#j��}|tjvr tj�d|��t?j dddd���}|p|}|p|}tr|stC��tEd� ��a#tF�$��dd!l%m&}|tF��t"j�'t"j�tP��d"���|��d#kr<t"j�'�d$��}tF�)|�%��nU|�*��sAtVd&krd'�d(}nd)�d*}��fd+�|D��}d,�|D��}tGj,dg|�R�t[tF��t]tF��t_tF��a0|�1tFt`��|r[|sY|sW|dd�D]1}t`�2|���|�3|���2|st`�4��|rWt`�5��}|sdS|�*��r%t`j6r|j7�8��nt`j9}|r|�:��|	ryt"j;�<d-��pt"j;�<d.��}|r9t"j�|��r|j=�>|��|s|r�|j=�?d/�@tj	����|r|j=�A|��nd|r4|j=�B|��|j=�>|��n-|r+|�C��}|r|�D|��t`jEr%tF�F��t`jE�%tF�G��t
d��dS)0Nr)�system)�testing)�macosxTFrzc:deihnr:st:zError: r�rr�rz-dz-ez-hz-iz-nz: Warning: running IDLE without a subprocess is deprecated.z-rzNo script file: z-sz-t�-rbrrzeditor-on-startupr
)r�Idle)�	className)�fix_scaling�Icons�Windowszidle.ico)rg333333!@z.png)�� �0�z.gif)r�r�r�c�Z��g|]'}tj��d|�fz����(S)z	idle_%d%s)rPrQrR)r�size�ext�icondirs  ��r(r
zmain.<locals>.<listcomp>ZsB���(�(�(���W�\�\�'�;�$���+D�E�E�(�(�(r0c�:�g|]}tt|�����S))�masterr)�
PhotoImager�)r�iconfiles  r(r
zmain.<locals>.<listcomp>\s5��,�,�,���4�h�7�7�7�,�,�,r0�IDLESTARTUP�
PYTHONSTARTUPzdif 1:
            import sys as _sys
            _sys.argv = {!r}
            del _sys
            
)H�getoptrYr�r�r�r�r/r�r��argv�errorrf�	usage_msgr�exitrr!rPrQr�r�rTr�r�r�r�r�rp�dirnamerv�getcwdrr�
NoDefaultRootr�r�r��idlelib.runr�rR�__file__�
wm_iconbitmap�isAquaTk�	TkVersion�wm_iconphotorr�r�rN�setupAppr�r}�newrO�dictr��lowerrqr8�environrrrr�rZr[r�r��preferTabsPreferenceWarningr��inversedictrg�destroy)r�r�r�r��enable_shell�enable_editrt�cmd�script�startup�optsrYr��o�ar2�pathxr&�dir�
edit_startr�r��sizes�	iconfiles�iconsr��prefer_tabs_preference_warningr�r�s                           @@r(rr�s������M�M�M��������������������T�����N��L��K��E�
�C�
�F��G���]�]�3�8�A�B�B�<��@�@�
��d�d���<����
�*��*�*�y�*�*���<�<�<�<��������������������� � ���1���9�9��C��L���9�9��E��L���9�9��K���9�9��J���Y�'�'�'��H�J�J�J���9�9��L���9�9��N��z�
#�
#�
#�
#�"�N���9�9��F��w�~�~�f�%�%�
���(�&�1�1�1���
�
�
��L���9�9��G��L���9�9�"#�G���L�����Q��3����i�n�n������
�3�s�x�=�=�
!�
!�3�3���g�o�o�c�h�q�k�2�2�������$��Q��3����4�$�q�r�r�(�?����	�$��6�D�=����	�$��8�d�?����	
�$������	4�	4�H��L�L������2�2�3�3�3�3��	(�	(�C��'�/�/�#�&�&�C��#�(�?�?������3�'�'�'��	(�
�i�k�k���c�h����H�O�O�A�s�#�#�#��#�F�I�$7�f�F�F�F�J��+��K��2�{�?�L���g������
�����D��M�M�O�O�O�'�'�'�'�'�'��K������g�l�l�2�7�?�?�8�4�4�g�>�>�G�
�v�x�x�9����7�<�<���4�4�����8��,�,�,�,�
�_�_�
�
�(������C�%�E�E��C� �E�(�(�(�(�(�!&�(�(�(�	�,�,�!*�,�,�,����$�'��'�'�'�'��$�����$�����D�!�!�E�
�O�O�D�%� � � ����	�v�	� ����G�
*�
*���:�:�h�'�'�/��K�K��)�)�)���
��	�	������� � �"�"���	��F��?�?���	���	�

�I�O�O������
��
��
�������,��:�>�>�-�0�0�3��:�>�>�/�2�2�	��	,�����x�0�0�	,��L�!�!�(�+�+�+�
�?�f�?�
����!��&���"�"�		$�	$�	$�
�	*��L�#�#�C�(�(�(�(�
�	*��L�(�(��0�0�0��L�!�!�&�)�)�)��	�
?�*0�)K�)K�)M�)M�&�)�	?����=�>�>�>�
�
���
�
�����
���L�L�N�N�N��U�����s�+A#�#
B1�-:B,�,B1)NN)Rr�r�r�r\�ImportErrorrfrjr�rY�ctypes�PROCESS_SYSTEM_DPI_AWARE�OleDLL�SetProcessDpiAwarenessr"r#r
r�rr�r4rP�os.pathrr�r'r�textwrapr
rLr r�r,�idlelib.colorizerr�idlelib.configr�idlelib.delegatorrr�rr�idlelib.editorrr�idlelib.filelistr�idlelib.outwinrrrr�rrr�idlelib.undorr�rr��eofr�re�	NameErrorr r)r+r/�
checkcacher<r>r�r�r�r��	RPCClientr�r�r�r�r�r�rr�r0r(�<module>rs:���
�
�
��z���%(�[��%<�C�K�!�"������������	�E�9�?B�~�O�O�O�O�
�*�Q�-�-�������<�7���
��
�
�
�#$� ���
�h���6�6�7O�P�P�P�P�����1�
�
�
���
����������'�'�'�'�'�'���������	�	�	�	�����#�#�#�#�#�#�	�	�	�	�
�
�
�
����� � � � � � �����������������,�,�,�,�,�,�#�#�#�#�#�#�'�'�'�'�'�'�������������6�6�6�6�6�6�6�6�%�%�%�%�%�%�'�'�'�'�'�'�������������G�G�G�G�G�G�G�G�G�G�&�&�&�&�&�&�������	�
 �C��D�H��D�H�H���	�	�	��D�	�������>B�
�
�
�
�"��)�)�)�������+/�2;�2F�����(5�	��{"�{"�{"�{"�{"�,�{"�{"�{"�|�����h����(
2�
2�
2�
2�
2�^�
2�
2�
2�/�/�/�/�/�M�/�/�/�D1�1�1�1�1�	�1�1�1������#�-�������k(�k(�k(�k(�k(�0�k(�k(�k(�\
`	,�`	,�`	,�`	,�`	,�l�`	,�`	,�`	,�F;�;�;�4
�	�ln�n�n�b�z����D�F�F�F��������s-�&�#A	�)B�B
�B
�)D:�:E�E
© 2025 GrazzMean