HEX
Server: Apache
System: Linux zacp120.webway.host 4.18.0-553.50.1.lve.el8.x86_64 #1 SMP Thu Apr 17 19:10:24 UTC 2025 x86_64
User: govancoz (1003)
PHP: 8.3.26
Disabled: exec,system,passthru,shell_exec,proc_close,proc_open,dl,popen,show_source,posix_kill,posix_mkfifo,posix_getpwuid,posix_setpgid,posix_setsid,posix_setuid,posix_setgid,posix_seteuid,posix_setegid,posix_uname
Upload Files
File: //usr/local/lib/python3.10/test/__pycache__/test_interpreters.cpython-310.opt-1.pyc
o

�i�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�wZindented�wrapped�r�3/usr/local/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)rZrequestrrZrpiperrr�_run_output"s
$�rc#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�tZspiperr r�_running)s��r*c@seZdZdd�ZdS)�TestBasecCs
t�dS�N)r��selfrrr�tearDown?�
zTestBase.tearDownN)�__name__�
__module__�__qualname__r/rrrrr+=sr+c@s4eZdZdd�Zdd�Zdd�Zdd�Zd	d
�ZdS)�CreateTestscCs*t��}|�|tj�|�|t���dSr,)r�create�assertIsInstance�Interpreter�assertInr�r.rrrr�test_in_mainEszCreateTests.test_in_maincsnt���d���fdd�}tj|d�}��|��Wd�n1s$wY|��|��t���dS)Ncst���������dSr,)rr5�acquire�releaser�r�lockrr�fMsz%CreateTests.test_in_thread.<locals>.fr!)r$�Lockr%r&r(r8rr�r.r?r)rr=r�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)
            )rrr5rrr7�int�assertEqual)r.�mainr�out�interp2rrr�test_in_subinterpreterXs

z"CreateTests.test_in_subinterpretercCshtt���}g}td�D]}t��}|�|�q|D]}|��qt��}|�tt���||hB�dS�N�)�setrr�ranger5�appendrrD)r.�beforeZ
interp_lst�_�interpsrrrr�test_after_destroy_allcs
z"CreateTests.test_after_destroy_allcCs\tt���}t��}t��}t��}|��|��t��}|�tt���|||hB�dSr,)rKrrr5rrD)r.rN�interp1rG�interp3rrrr�test_after_destroy_someqs z#CreateTests.test_after_destroy_someN)r1r2r3r:rBrHrQrTrrrrr4Csr4c@�eZdZdd�Zdd�ZdS)�GetCurrentTestscCs t��}t��}|�||�dSr,)r�get_main�get_currentrD)r.rE�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)
            )	�
_interpretersrWrr5rrr7rC�assertNotEqual)r.rErrFrYrrr�test_subinterpreter�s
z#GetCurrentTests.test_subinterpreterN)r1r2r3rZr]rrrrrV�rVc@s$eZdZdd�Zdd�Zdd�ZdS)�ListAllTestscCst��}|�dt|��dS�N�)rrrD�len)r.rPrrr�test_initial�szListAllTests.test_initialcCsRt��}t��}t��}g}t��D]}|�|j�q|�||j|j|jg�dSr,)rrXr5rrMrrD�r.rE�first�secondZidsrrrr�test_after_creating�sz ListAllTests.test_after_creatingcCsVt��}t��}t��}|��g}t��D]}|�|j�q|�||j|jg�dSr,)rrXr5rrrMrrDrdrrr�test_after_destroying�sz"ListAllTests.test_after_destroyingN)r1r2r3rcrgrhrrrrr_�sr_c@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�dSr,)rrWrXr5r6rr[Z
InterpreterID)r.rErYrrrr�test_id_type�sz!TestInterpreterAttrs.test_id_typecCst��}|�|jd�dSr)rrWrDr�r.rErrr�test_main_id��z!TestInterpreterAttrs.test_main_idcC�Rt�d�}|�|jd�|�t��t�d�Wd�dS1s"wYdS�Nra�1)rr7rDr�assertRaises�	TypeErrorr9rrr�test_custom_id��

"�z#TestInterpreterAttrs.test_custom_idcC�@t�d�}|�t��d|_Wd�dS1swYdS�Nra�)rr7rq�AttributeErrorrr9rrr�test_id_readonly��
"�z%TestInterpreterAttrs.test_id_readonlyznot ready yet (see bpo-32604)cC�t��}|�|j�dSr,)rrW�assertFalse�isolatedrkrrr�test_main_isolated��z'TestInterpreterAttrs.test_main_isolatedcCr{r,)rr5r|r}r9rrr�$test_subinterpreter_isolated_default�rz9TestInterpreterAttrs.test_subinterpreter_isolated_defaultcCs4tjdd�}tjdd�}|�|j�|�|j�dS)NT�r}F)rr5�
assertTruer}r|�r.rRrGrrr�%test_subinterpreter_isolated_explicit��z:TestInterpreterAttrs.test_subinterpreter_isolated_explicitcCst�d�}|�|j�dSr`)rr7r|r}r9rrr�test_custom_isolated_default�s
z1TestInterpreterAttrs.test_custom_isolated_defaultcCs8tjddd�}tjddd�}|�|j�|�|j�dS)NraTr�F)rr7r�r}r|r�rrr�test_custom_isolated_explicit�sz2TestInterpreterAttrs.test_custom_isolated_explicitcCru)NraT)rr7rqrxr}r9rrr�test_isolated_readonly�rzz+TestInterpreterAttrs.test_isolated_readonlycCs,t��}t��}|�||�|�||�dSr,)rr5rDr\r�rrr�
test_equality�sz"TestInterpreterAttrs.test_equalityN)r1r2r3rjrlrsry�unittest�skipr~r�r�r�r�r�r�rrrrri�s


ric@sFeZdZdd�Ze�d�dd��Zdd�Zdd	�Zd
d�Z	dd
�Z
dS)�TestInterpreterIsRunningcCst��}|�|���dSr,)rrWr��
is_runningrkrrrrZ�rmz"TestInterpreterIsRunning.test_main�Fails on FreeBSDcCs^t��}|�|���t|��|�|���Wd�n1s!wY|�|���dSr,)rr5r|r�r*r�r9rrrr]�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)rr5rrrrD�strip)r.rrFrrr�test_from_subinterpreters
�z1TestInterpreterIsRunning.test_from_subinterpretercCsHt��}|��|�t��
|��Wd�dS1swYdSr,)rr5rrqrr�r9rrr�test_already_destroyed�

"�z/TestInterpreterIsRunning.test_already_destroyedcC�Bt�d�}|�t��
|��Wd�dS1swYdS�N�@B)rr7rqrr�r9rrr�test_does_not_exist�

"�z,TestInterpreterIsRunning.test_does_not_existcCr��N���)rr7rq�
ValueErrorr�r9rrr�test_bad_idr�z$TestInterpreterIsRunning.test_bad_idN)r1r2r3rZr�r�r]r�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�dSr,)rrWr5rDrKrr)r.rErRrGrSrrr�
test_basics
��zTestInterpreterClose.test_basiccCsttt���}t�}td�D]}t��}|�|�q
|�tt���||B�|D]}|��q'|�tt���|�dSrI)rKrrrLr5�addrDr)r.rNrPrOrrrr�test_all)s
zTestInterpreterClose.test_allcsjt��\���t�����Wd�n1swY��fdd�}tj|d�}|��|��dS)Ncs8��t��
���Wd�dS1swYdSr,)rqrrr�rEr.rrr?9s
"�z)TestInterpreterClose.test_main.<locals>.fr!)	rrrqrrr$r%r&r(rArr�rrZ4s

�zTestInterpreterClose.test_maincCsHt��}|��|�t��
|��Wd�dS1swYdSr,)rr5rrqrr9rrrr�Ar�z+TestInterpreterClose.test_already_destroyedcCr�r�)rr7rqrrr9rrrr�Gr�z(TestInterpreterClose.test_does_not_existcCr�r�)rr7rqr�rr9rrrr�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')
            Zfailed)
rrr5rrrCrrDr�rK)r.rErrFrrr�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()
            )rrr5rDrKrrr)r.rErRrGrrr�test_from_sibling_s
��z&TestInterpreterClose.test_from_siblingcs4t����fdd�}tj|d�}|��|��dS)Ncs���dSr,)rrrrrr?psz6TestInterpreterClose.test_from_other_thread.<locals>.fr!)rr5r$r%r&r(rArrr�test_from_other_threadns
z+TestInterpreterClose.test_from_other_threadr�c	Cs�t��\}t��}t|��)|�t��|��Wd�n1s"wY|�|���Wd�dS1s9wYdSr,)	rrr5r*rqrrr�r�)r.rErrrr�test_still_runningws


�"�z'TestInterpreterClose.test_still_runningN)r1r2r3r�r�rZr�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!)rr5rrrrD)r.rr�filerFrrr�test_success�s

�zTestInterpreterRun.test_successcszt���td�\�}|�!��fdd�}tj|d�}|��|��|��}Wd�n1s0wY|�|d�dS)Nr�cs����dSr,)rr�rrrrr?�sz,TestInterpreterRun.test_in_thread.<locals>.fr!r�)	rr5rr$r%r&r(rrD)r.r�r?r)rFrr�rrB�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')
                )rr5�tempfile�NamedTemporaryFiler'�flushr�namer�seekrrD)r.rr�r�ZexpectedrZcontentrrr�	test_fork�s 
�
�

"�zTestInterpreterRun.test_forkr�c	Cszt��}t|��+|�t��
|�d�Wd�n1swYWd�dSWd�dS1s6wYdS)N�
print("spam"))rr5r*rqrrr9rrr�test_already_running�s
��"�z'TestInterpreterRun.test_already_runningcC�Dt�d�}|�t��|�d�Wd�dS1swYdS)Nr�r�)rr7rqrrr9rrrr���
"�z&TestInterpreterRun.test_does_not_existcCr�)Nr�r�)rr7rqr�rr9rrrr��r�zTestInterpreterRun.test_bad_idcC�Bt��}|�t��|�d�Wd�dS1swYdS)N�
�rr5rqrrrr9rrr�test_bad_script��"�z"TestInterpreterRun.test_bad_scriptcCr�)Ns
print("spam")r�r9rrr�test_bytes_for_script�r�z(TestInterpreterRun.test_bytes_for_scriptN)r1r2r3r�rBr�Z
skipUnless�hasattrrr�r�r�r�r�r�r�rrrrr��s	

r�c@rU)�TestIsShareablec	CsTgd�}|D]!}|�|��t�|�}|�|�Wd�n1s"wYqdS)N)N�spamZspamr�i����)�subTestr�is_shareabler�)r.Z
shareables�objZ	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@rU)z2TestIsShareable.test_not_shareable.<locals>.CheesecSs
||_dSr,�r�)r.r�rrr�__init__�r0z;TestIsShareable.test_not_shareable.<locals>.Cheese.__init__cSs|jSr,r�r-rrr�__str__�sz:TestIsShareable.test_not_shareable.<locals>.Cheese.__str__N)r1r2r3r�r�rrrr�Cheese�sr�c@seZdZdZdS)z4TestIsShareable.test_not_shareable.<locals>.SubByteszA subclass of a shareable type.N)r1r2r3�__doc__rrrr�SubBytes�sr�TF.gY@ZWensleydaler�)
�bytes�NotImplemented�type�object�	Exceptionr��reprr|rr�)r.r�r�Znot_shareablesr�rrr�test_not_shareable�s.�����z"TestIsShareable.test_not_shareableN)r1r2r3r�r�rrrrr��sr�c@rU)�TestChannelscCs,t��\}}|�|tj�|�|tj�dSr,)r�create_channelr6�RecvChannel�SendChannel)r.r
�srrr�test_createszTestChannels.test_createcCsR|�t��g�t�}td�D]}t��}|�|�qtt���}|�||�dSrI)rDrZlist_all_channelsrKrLr�r�)r.�createdrO�chZafterrrr�
test_list_allszTestChannels.test_list_allN)r1r2r3r�r�rrrrr�r^r�c@�,eZdZdd�Zdd�Zdd�Zdd�Zd	S)
�TestRecvChannelAttrscCs t��\}}|�|jtj�dSr,�rr�r6rr[Z	ChannelID)r.�rchrOrrrrj�z!TestRecvChannelAttrs.test_id_typecCrnro)rr�rDrrqrr�r.r�rrrrsrtz#TestRecvChannelAttrs.test_custom_idcCrurv)rr�rqrxrr�rrrryrzz%TestRecvChannelAttrs.test_id_readonlycCs4t��\}}t��\}}|�||�|�||�dSr,�rr�rDr\)r.�ch1rO�ch2rrrr�$r�z"TestRecvChannelAttrs.test_equalityN�r1r2r3rjrsryr�rrrrr��
r�c@r�)
�TestSendChannelAttrscCs t��\}}|�|jtj�dSr,r�)r.rO�schrrrrj-r�z!TestSendChannelAttrs.test_id_typecCrnro)rr�rDrrqrr�r.r�rrrrs1rtz#TestSendChannelAttrs.test_custom_idcCrurv)rr�rqrxrr�rrrry8rzz%TestSendChannelAttrs.test_id_readonlycCs4t��\}}t��\}}|�||�|�||�dSr,r�)r.rOr�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�recvrD�assertIsNot�r.r
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'
            �rr5rrr9rrr�test_send_recv_same_interpreterOrmz,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�rr5rr�dictr�rDr\rC�r.Zr1�s1Zr2�s2Zorig1rF�obj2rrr�%test_send_recv_different_interpreters[�
�
	�
z2TestSendRecv.test_send_recv_different_interpreterscsht��\����fdd�}tj|d�}|��d}��|�|�����}|�||�|�	||�dS)Ncs>	z���}Wntjyt�d�Ynwq��|�dS)NTg�������?)r�r�ChannelEmptyError�time�sleep�send)r�r�rrr?vs��z8TestSendRecv.test_send_recv_different_threads.<locals>.fr!r�)
rr�r$r%r&rr(r�rDr�)r.r?r)r�r�rr�r� test_send_recv_different_threadsss
z-TestSendRecv.test_send_recv_different_threadscCr�r�)rr�r��recv_nowaitrDr�r�rrr�test_send_recv_nowait_main�r�z'TestSendRecv.test_send_recv_nowait_maincCs$t��\}}|�d�}|�|�dSr,)rr�rZassertIsNone)r.r
rOr�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'
            r�r9rrr�&test_send_recv_nowait_same_interpreter�rmz3TestSendRecv.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�r�rr�)rr�r�rr5rrr�rrDr\rCr�rrr�,test_send_recv_nowait_different_interpreters�rz9TestSendRecv.test_send_recv_nowait_different_interpreterscC�Dt�d�}|�tj��
|��Wd�dS1swYdSr�)rr�rq�ChannelNotFoundErrorr��r.r�rrr� test_recv_channel_does_not_exist��

"�z-TestSendRecv.test_recv_channel_does_not_existcC�Ft�d�}|�tj��|�d�Wd�dS1swYdS�Nr�r�)rr�rqrrr
rrr� test_send_channel_does_not_exist��
"�z-TestSendRecv.test_send_channel_does_not_existcCrr�)rr�rqrrr
rrr�'test_recv_nowait_channel_does_not_exist�rz4TestSendRecv.test_recv_nowait_channel_does_not_existcCrr)rr�rqrr�r
rrr�'test_send_nowait_channel_does_not_exist�rz4TestSendRecv.test_send_nowait_channel_does_not_existcCsFt��\}}|�tj��
|��Wd�dS1swYdSr,)rr�rqrr)r.r�rOrrr�test_recv_nowait_empty�s
"�z#TestSendRecv.test_recv_nowait_emptyc
Cs�t�}t��\}}|�|�}|�d�|�d�|�d�|�d�|�|�}|�|�}|��}|�|�}|�|�}	|�||�|�|d�|�|d�|�|d�|�|d�|�|	|�dS)Nrar�r�)r�rr�rr�ZassertIsrD)
r.�defaultr�r�Zobj1r�Zobj3Zobj4Zobj5Zobj6rrr�test_recv_nowait_default�s$








z%TestSendRecv.test_recv_nowait_defaultN)r1r2r3r�r�r�r�r�rrrr	r
rrrrrrrrrrr�Ds"	
	
r�r,)�
contextlibrr$�textwraprr�rZ_xxsubinterpretersr[Ztest.supportrrrr�contextmanagerr*ZTestCaser+r4rVr_rir�r�r�r�r�r�r�r�rrrr�<module>s4


<A+eN2