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 :  /usr/lib/python3.10/test/__pycache__/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /usr/lib/python3.10/test/__pycache__/test_interpreters.cpython-310.pyc
o

�9j�Y�@sFddlZddlZddlZddlmZddlZddlZddlZddl	m
Z
dd�Zdd�Zd&dd	�Z
ejd
d��ZGdd
�d
ej�ZGdd�de�ZGdd�de�ZGdd�de�ZGdd�de�ZGdd�de�ZGdd�de�ZGdd�de�ZGdd�de�ZGdd�de�ZGd d!�d!e�ZGd"d#�d#e�ZGd$d%�d%e�ZdS)'�N)�dedent)�interpreterscCs>t��\}}|�dd�}td|�d|�d��}|t|dd�fS)N�
z
                z-
        import contextlib
        with open(zg, 'w', encoding='utf-8') as spipe:
            with contextlib.redirect_stdout(spipe):
                z	
        �utf-8��encoding)�os�pipe�replacer�open)�script�r�w�indented�wrapped�r�-/usr/lib/python3.10/test/test_interpreters.py�_captured_scripts�
�rc	Cs<t��D]}|jdkrqz|��WqtyYqwdS�Nr)r�list_all�id�close�RuntimeError��interprrr�clean_up_interpreterss
��rcCsJt|�\}}|�|j||d�|��Wd�S1swYdS)N��channels)r�run�read)r�requestrr�rpiperrr�_run_output"s
$�r"c#sv�t��\�}��fdd�}tj|d�}|��dVt|d��
}|�d�Wd�n1s0wY|��dS)Ncs��td��d���dS)Nz7
            # wait for "signal"
            with open(z5) as rpipe:
                rpipe.read()
            )rrr�rr
rrr,s�z_running.<locals>.run��targetr�done)rr	�	threading�Thread�startr�write�join)rrr�t�spiperr#r�_running)s��r.c@seZdZdd�ZdS)�TestBasecCs
t�dS�N)r��selfrrr�tearDown?�
zTestBase.tearDownN)�__name__�
__module__�__qualname__r3rrrrr/=sr/c@s4eZdZdd�Zdd�Zdd�Zdd�Zd	d
�ZdS)�CreateTestscCs*t��}|�|tj�|�|t���dSr0)r�create�assertIsInstance�Interpreter�assertInr�r2rrrr�test_in_mainEszCreateTests.test_in_maincsnt���d���fdd�}tj|d�}��|��Wd�n1s$wY|��|��t���dS)Ncst���������dSr0)rr9�acquire�releaser�r�lockrr�fMsz%CreateTests.test_in_thread.<locals>.fr$)r'�Lockr(r)r+r<rr�r2rCr,rrAr�test_in_threadJs
�zCreateTests.test_in_threadcCsHt��\}t��}t|td��}t�t|��}|�t��|||g�dS)Nz�
            from test.support import interpreters
            interp = interpreters.create()
            print(interp.id)
            )rrr9r"rr;�int�assertEqual)r2�mainr�out�interp2rrr�test_in_subinterpreterXs

z"CreateTests.test_in_subinterpretercCshtt���}g}td�D]}t��}|�|�q|D]}|��qt��}|�tt���||hB�dS�N�)�setrr�ranger9�appendrrH)r2�before�
interp_lst�_�interpsrrrr�test_after_destroy_allcs
z"CreateTests.test_after_destroy_allcCs\tt���}t��}t��}t��}|��|��t��}|�tt���|||hB�dSr0)rOrrr9rrH)r2rR�interp1rK�interp3rrrr�test_after_destroy_someqs z#CreateTests.test_after_destroy_someN)r5r6r7r>rFrLrVrYrrrrr8Csr8c@�eZdZdd�Zdd�ZdS)�GetCurrentTestscCs t��}t��}|�||�dSr0)r�get_main�get_currentrH)r2rI�currentrrr�	test_main�szGetCurrentTests.test_maincCs<t��}t��}t|td��}t�t|��}|�||�dS)Nz�
            from test.support import interpreters
            cur = interpreters.get_current()
            print(cur.id)
            )	�
_interpretersr\rr9r"rr;rG�assertNotEqual)r2rIrrJr^rrr�test_subinterpreter�s
z#GetCurrentTests.test_subinterpreterN)r5r6r7r_rbrrrrr[�r[c@s$eZdZdd�Zdd�Zdd�ZdS)�ListAllTestscCst��}|�dt|��dS�N�)rrrH�len)r2rUrrr�test_initial�szListAllTests.test_initialcCsRt��}t��}t��}g}t��D]}|�|j�q|�||j|j|jg�dSr0)rr]r9rrQrrH�r2rI�first�second�idsrrrr�test_after_creating�sz ListAllTests.test_after_creatingcCsVt��}t��}t��}|��g}t��D]}|�|j�q|�||j|jg�dSr0)rr]r9rrrQrrHrirrr�test_after_destroying�sz"ListAllTests.test_after_destroyingN)r5r6r7rhrmrnrrrrrd�srdc@s�eZdZdd�Zdd�Zdd�Zdd�Ze�d	�d
d��Z	e�d	�dd
��Z
dd�Ze�d	�dd��Zdd�Z
dd�Zdd�ZdS)�TestInterpreterAttrscCsLt��}t��}t��}|�|jtj�|�|jtj�|�|jtj�dSr0)rr\r]r9r:rr`�
InterpreterID)r2rIr^rrrr�test_id_type�sz!TestInterpreterAttrs.test_id_typecCst��}|�|jd�dSr)rr\rHr�r2rIrrr�test_main_id��z!TestInterpreterAttrs.test_main_idcC�Rt�d�}|�|jd�|�t��t�d�Wd�dS1s"wYdS�Nrf�1)rr;rHr�assertRaises�	TypeErrorr=rrr�test_custom_id��

"�z#TestInterpreterAttrs.test_custom_idcC�@t�d�}|�t��d|_Wd�dS1swYdS�Nrf�)rr;rx�AttributeErrorrr=rrr�test_id_readonly��
"�z%TestInterpreterAttrs.test_id_readonlyznot ready yet (see bpo-32604)cC�t��}|�|j�dSr0)rr\�assertFalse�isolatedrrrrr�test_main_isolated��z'TestInterpreterAttrs.test_main_isolatedcCr�r0)rr9r�r�r=rrr�$test_subinterpreter_isolated_default�r�z9TestInterpreterAttrs.test_subinterpreter_isolated_defaultcCs4tjdd�}tjdd�}|�|j�|�|j�dS)NT�r�F)rr9�
assertTruer�r��r2rWrKrrr�%test_subinterpreter_isolated_explicit��z:TestInterpreterAttrs.test_subinterpreter_isolated_explicitcCst�d�}|�|j�dSre)rr;r�r�r=rrr�test_custom_isolated_default�s
z1TestInterpreterAttrs.test_custom_isolated_defaultcCs8tjddd�}tjddd�}|�|j�|�|j�dS)NrfTr�F)rr;r�r�r�r�rrr�test_custom_isolated_explicit�sz2TestInterpreterAttrs.test_custom_isolated_explicitcCr|)NrfT)rr;rxrr�r=rrr�test_isolated_readonly�r�z+TestInterpreterAttrs.test_isolated_readonlycCs,t��}t��}|�||�|�||�dSr0)rr9rHrar�rrr�
test_equality�sz"TestInterpreterAttrs.test_equalityN)r5r6r7rqrsrzr��unittest�skipr�r�r�r�r�r�r�rrrrro�s


roc@sFeZdZdd�Ze�d�dd��Zdd�Zdd	�Zd
d�Z	dd
�Z
dS)�TestInterpreterIsRunningcCst��}|�|���dSr0)rr\r��
is_runningrrrrrr_�rtz"TestInterpreterIsRunning.test_main�Fails on FreeBSDcCs^t��}|�|���t|��|�|���Wd�n1s!wY|�|���dSr0)rr9r�r�r.r�r=rrrrb�s
�z,TestInterpreterIsRunning.test_subinterpretercCs4t��}t|td|j�d���}|�|��d�dS)Nz`
            import _xxsubinterpreters as _interpreters
            if _interpreters.is_running(zZ):
                print(True)
            else:
                print(False)
            �True)rr9r"rrrH�strip)r2rrJrrr�test_from_subinterpreters
�z1TestInterpreterIsRunning.test_from_subinterpretercCsHt��}|��|�t��
|��Wd�dS1swYdSr0)rr9rrxrr�r=rrr�test_already_destroyed�

"�z/TestInterpreterIsRunning.test_already_destroyedcC�Bt�d�}|�t��
|��Wd�dS1swYdS�N�@B)rr;rxrr�r=rrr�test_does_not_exist�

"�z,TestInterpreterIsRunning.test_does_not_existcCr��N���)rr;rx�
ValueErrorr�r=rrr�test_bad_idr�z$TestInterpreterIsRunning.test_bad_idN)r5r6r7r_r�r�rbr�r�r�r�rrrrr��s
r�c@sfeZdZdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	dd�Z
dd�Ze�
d�dd��ZdS)�TestInterpreterClosecCsbt��}t��}t��}t��}|�tt���||||h�|��|�tt���|||h�dSr0)rr\r9rHrOrr)r2rIrWrKrXrrr�
test_basics
��zTestInterpreterClose.test_basiccCsttt���}t�}td�D]}t��}|�|�q
|�tt���||B�|D]}|��q'|�tt���|�dSrM)rOrrrPr9�addrHr)r2rRrUrTrrrr�test_all)s
zTestInterpreterClose.test_allcsjt��\���t�����Wd�n1swY��fdd�}tj|d�}|��|��dS)Ncs8��t��
���Wd�dS1swYdSr0)rxrrr�rIr2rrrC9s
"�z)TestInterpreterClose.test_main.<locals>.fr$)	rrrxrrr'r(r)r+rErr�rr_4s

�zTestInterpreterClose.test_maincCsHt��}|��|�t��
|��Wd�dS1swYdSr0)rr9rrxrr=rrrr�Ar�z+TestInterpreterClose.test_already_destroyedcCr�r�)rr;rxrrr=rrrr�Gr�z(TestInterpreterClose.test_does_not_existcCr�r�)rr;rxr�rr=rrrr�Lr�z TestInterpreterClose.test_bad_idcCsZt��\}t��}t|tdt|j��d���}|�|��d�|�t	t���||h�dS)Nza
            from test.support import interpreters
            interp = interpreters.Interpreter(z)
            try:
                interp.close()
            except RuntimeError:
                print('failed')
            �failed)
rrr9r"rrGrrHr�rO)r2rIrrJrrr�test_from_currentQs
�z&TestInterpreterClose.test_from_currentcCsht��\}t��}t��}|�tt���|||h�|�td|j�d���|�tt���||h�dS)Nzf
            from test.support import interpreters
            interp2 = interpreters.Interpreter(int(zs))
            interp2.close()
            interp3 = interpreters.create()
            interp3.close()
            )rrr9rHrOrrr)r2rIrWrKrrr�test_from_sibling_s
��z&TestInterpreterClose.test_from_siblingcs4t����fdd�}tj|d�}|��|��dS)Ncs���dSr0)rrrrrrCpsz6TestInterpreterClose.test_from_other_thread.<locals>.fr$)rr9r'r(r)r+rErrr�test_from_other_threadns
z+TestInterpreterClose.test_from_other_threadr�c	Cs�t��\}t��}t|��)|�t��|��Wd�n1s"wY|�|���Wd�dS1s9wYdSr0)	rrr9r.rxrrr�r�)r2rIrrrr�test_still_runningws


�"�z'TestInterpreterClose.test_still_runningN)r5r6r7r�r�r_r�r�r�r�r�r�r�r�r�rrrrr�s
	r�c@sheZdZdd�Zdd�Ze�eed�d�dd��Z	e�
d	�d
d��Zdd
�Zdd�Z
dd�Zdd�ZdS)�TestInterpreterRuncCsZt��}td�\}}|�|�|�|��}Wd�n1s wY|�|d�dS)N�print("it worked!", end="")�
it worked!)rr9rrrrH)r2rr�filerJrrr�test_success�s

�zTestInterpreterRun.test_successcszt���td�\�}|�!��fdd�}tj|d�}|��|��|��}Wd�n1s0wY|�|d�dS)Nr�cs����dSr0)rr�rrrrrC�sz,TestInterpreterRun.test_in_thread.<locals>.fr$r�)	rr9rr'r(r)r+rrH)r2r�rCr,rJrr�rrF�s
�	z!TestInterpreterRun.test_in_thread�forkztest needs os.fork()cCs�t��}ddl}|jddd��4}|�d�|��d}td|j�d|�d	��}|�|�|�	d�|�
�}|�||�Wd�dS1sFwYdS)
Nrzw+rr�zspam spam spam spam spamz�
                import os
                try:
                    os.fork()
                except RuntimeError:
                    with open('zE', 'w', encoding='utf-8') as out:
                        out.write('z')
                )rr9�tempfile�NamedTemporaryFiler*�flushr�namer�seekrrH)r2rr�r��expectedr�contentrrr�	test_fork�s 
�
�

"�zTestInterpreterRun.test_forkr�c	Cszt��}t|��+|�t��
|�d�Wd�n1swYWd�dSWd�dS1s6wYdS)N�
print("spam"))rr9r.rxrrr=rrr�test_already_running�s
��"�z'TestInterpreterRun.test_already_runningcC�Dt�d�}|�t��|�d�Wd�dS1swYdS)Nr�r�)rr;rxrrr=rrrr���
"�z&TestInterpreterRun.test_does_not_existcCr�)Nr�r�)rr;rxr�rr=rrrr��r�zTestInterpreterRun.test_bad_idcC�Bt��}|�t��|�d�Wd�dS1swYdS)N�
�rr9rxryrr=rrr�test_bad_script��"�z"TestInterpreterRun.test_bad_scriptcCr�)Ns
print("spam")r�r=rrr�test_bytes_for_script�r�z(TestInterpreterRun.test_bytes_for_scriptN)r5r6r7r�rFr��
skipUnless�hasattrrr�r�r�r�r�r�r�rrrrr��s	

r�c@rZ)�TestIsShareablec	CsTgd�}|D]!}|�|��t�|�}|�|�Wd�n1s"wYqdS)N)N�spam�spamr�i����)�subTestr�is_shareabler�)r2�
shareables�obj�	shareablerrr�test_default_shareables�s	
���z'TestIsShareable.test_default_shareablesc
Cs�Gdd�d�}Gdd�dt�}ddtdttt�t�d||d	�|d
�g}|D]!}|�t|���|�t�	|��Wd�n1sAwYq%dS)Nc@rZ)z2TestIsShareable.test_not_shareable.<locals>.CheesecSs
||_dSr0�r�)r2r�rrr�__init__�r4z;TestIsShareable.test_not_shareable.<locals>.Cheese.__init__cSs|jSr0r�r1rrr�__str__�sz:TestIsShareable.test_not_shareable.<locals>.Cheese.__str__N)r5r6r7r�r�rrrr�Cheese�sr�c@seZdZdZdS)z4TestIsShareable.test_not_shareable.<locals>.SubByteszA subclass of a shareable type.N)r5r6r7�__doc__rrrr�SubBytes�sr�TF.gY@�Wensleydaler�)
�bytes�NotImplemented�type�object�	Exceptionr��reprr�rr�)r2r�r��not_shareablesr�rrr�test_not_shareable�s.�����z"TestIsShareable.test_not_shareableN)r5r6r7r�r�rrrrr��sr�c@rZ)�TestChannelscCs,t��\}}|�|tj�|�|tj�dSr0)r�create_channelr:�RecvChannel�SendChannel)r2r
�srrr�test_createszTestChannels.test_createcCsR|�t��g�t�}td�D]}t��}|�|�qtt���}|�||�dSrM)rHr�list_all_channelsrOrPr�r�)r2�createdrT�ch�afterrrr�
test_list_allszTestChannels.test_list_allN)r5r6r7r�r�rrrrr�rcr�c@�,eZdZdd�Zdd�Zdd�Zdd�Zd	S)
�TestRecvChannelAttrscCs t��\}}|�|jtj�dSr0�rr�r:rr`�	ChannelID)r2�rchrTrrrrq�z!TestRecvChannelAttrs.test_id_typecCrurv)rr�rHrrxry�r2r�rrrrzr{z#TestRecvChannelAttrs.test_custom_idcCr|r})rr�rxrrr�rrrr�r�z%TestRecvChannelAttrs.test_id_readonlycCs4t��\}}t��\}}|�||�|�||�dSr0�rr�rHra)r2�ch1rT�ch2rrrr�$r�z"TestRecvChannelAttrs.test_equalityN�r5r6r7rqrzr�r�rrrrr��
r�c@r�)
�TestSendChannelAttrscCs t��\}}|�|jtj�dSr0r�)r2rT�schrrrrq-r�z!TestSendChannelAttrs.test_id_typecCrurv)rr�rHrrxry�r2r�rrrrz1r{z#TestSendChannelAttrs.test_custom_idcCr|r})rr�rxrrr�rrrr�8r�z%TestSendChannelAttrs.test_id_readonlycCs4t��\}}t��\}}|�||�|�||�dSr0r�)r2rTr�r�rrrr�=r�z"TestSendChannelAttrs.test_equalityNr�rrrrr�+r�r�c@s�eZdZdd�Zdd�Ze�d�dd��Zdd	�Zd
d�Z	dd
�Z
dd�Ze�d�dd��Zdd�Z
dd�Zdd�Zdd�Zdd�Zdd�ZdS)�TestSendRecvcC�>t��\}}d}|�|�|��}|�||�|�||�dS�Nr�)rr��send_nowait�recvrH�assertIsNot�r2r
r��origr�rrr�test_send_recv_mainF�
z TestSendRecv.test_send_recv_maincC�t��}|�td��dS)Na>
            from test.support import interpreters
            r, s = interpreters.create_channel()
            orig = b'spam'
            s.send_nowait(orig)
            obj = r.recv()
            assert obj == orig, 'expected: obj == orig'
            assert obj is not orig, 'expected: obj is not orig'
            �rr9rrr=rrr�test_send_recv_same_interpreterOrtz,TestSendRecv.test_send_recv_same_interpreterzbroken (see BPO-...)cC�|t��\}}t��\}}d}|�|�tt��tdt|��d��t||d�d�}|��}|�	|d�|�
t|�t|��dS)Nr�z�
                obj1 = r.recv()
                assert obj1 == b'spam', 'expected: obj1 == orig1'
                # When going to another interpreter we get a copy.
                assert id(obj1) != ��, 'expected: obj1 is not orig1'
                orig2 = b'eggs'
                print(id(orig2))
                s.send_nowait(orig2)
                �r
r�r�eggs)rr�r�r"r9rr�dictrrHrarG�r2�r1�s1�r2�s2�orig1rJ�obj2rrr�%test_send_recv_different_interpreters[�
�
	�
z2TestSendRecv.test_send_recv_different_interpreterscsht��\����fdd�}tj|d�}|��d}��|�|�����}|�||�|�	||�dS)Ncs>	z���}Wntjyt�d�Ynwq��|�dS)NTg�������?)rr�ChannelEmptyError�time�sleep�send)r�rrrrCvs��z8TestSendRecv.test_send_recv_different_threads.<locals>.fr$r�)
rr�r'r(r)rr+rrHr)r2rCr,rr�rrr� test_send_recv_different_threadsss
z-TestSendRecv.test_send_recv_different_threadscCr�r�)rr�r��recv_nowaitrHrrrrr�test_send_recv_nowait_main�rz'TestSendRecv.test_send_recv_nowait_maincCs$t��\}}|�d�}|�|�dSr0)rr�r�assertIsNone)r2r
rTr�rrr�'test_send_recv_nowait_main_with_default�s
z4TestSendRecv.test_send_recv_nowait_main_with_defaultcCr)Na�
            from test.support import interpreters
            r, s = interpreters.create_channel()
            orig = b'spam'
            s.send_nowait(orig)
            obj = r.recv_nowait()
            assert obj == orig, 'expected: obj == orig'
            # When going back to the same interpreter we get the same object.
            assert obj is not orig, 'expected: obj is not orig'
            rr=rrr�&test_send_recv_nowait_same_interpreter�rtz3TestSendRecv.test_send_recv_nowait_same_interpretercCr	)Nr�z�
                obj1 = r.recv_nowait()
                assert obj1 == b'spam', 'expected: obj1 == orig1'
                # When going to another interpreter we get a copy.
                assert id(obj1) != r
rrr)rr�r�r"r9rrr
rrHrarGrrrr�,test_send_recv_nowait_different_interpreters�rz9TestSendRecv.test_send_recv_nowait_different_interpreterscC�Dt�d�}|�tj��
|��Wd�dS1swYdSr�)rr�rx�ChannelNotFoundErrorr�r2r�rrr� test_recv_channel_does_not_exist��

"�z-TestSendRecv.test_recv_channel_does_not_existcC�Ft�d�}|�tj��|�d�Wd�dS1swYdS�Nr�r�)rr�rxr#rr$rrr� test_send_channel_does_not_exist��
"�z-TestSendRecv.test_send_channel_does_not_existcCr"r�)rr�rxr#rr$rrr�'test_recv_nowait_channel_does_not_exist�r&z4TestSendRecv.test_recv_nowait_channel_does_not_existcCr'r()rr�rxr#r�r$rrr�'test_send_nowait_channel_does_not_exist�r*z4TestSendRecv.test_send_nowait_channel_does_not_existcCsFt��\}}|�tj��
|��Wd�dS1swYdSr0)rr�rxrr)r2r�rTrrr�test_recv_nowait_empty�s
"�z#TestSendRecv.test_recv_nowait_emptyc
Cs�t�}t��\}}|�|�}|�d�|�d�|�d�|�d�|�|�}|�|�}|��}|�|�}|�|�}	|�||�|�|d�|�|d�|�|d�|�|d�|�|	|�dS)Nrfr�r)r�rr�rr��assertIsrH)
r2�defaultr�r��obj1r�obj3�obj4�obj5�obj6rrr�test_recv_nowait_default�s$








z%TestSendRecv.test_recv_nowait_defaultN)r5r6r7rrr�r�rrrrr r!r%r)r+r,r-r5rrrrr�Ds"	
	
r�r0)�
contextlibrr'�textwraprr�r�_xxsubinterpretersr`�test.supportrrrr"�contextmanagerr.�TestCaser/r8r[rdror�r�r�r�r�r�r�r�rrrr�<module>s4


<A+eN2

Youez - 2016 - github.com/yon3zu
LinuXploit