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.7/test/__pycache__/test_code.cpython-37.opt-2.pyc
B

��g�)�@s�ddlZddlZddlZddlZddlZyddlZWnek
rLdZYnXddlmZm	Z	m
Z
mZdd�Zdd�Z
dd�ZGd	d
�d
ej�Zdd�ZGd
d�dej�ZGdd�dej�Zedd��rpedk	�rpejZe�dej�ZejZefe_eje_ejZej ejejfe_ej!e_ej"Z#ej eje�$ej�fe#_ej!e#_da%dd�Z&ee&�Z'ee'�Z(Gdd�dej�Z)ddd�Z*e+dk�r�e*�dS)�N)�run_doctest�run_unittest�cpython_only�check_impl_detailccs8x2|D]*}t|�}|�d�r*d|jVq|VqWdS)Nz<code objectz<code object %s>)�repr�
startswith�co_name)�tZelt�r�r�*/usr/local/lib/python3.7/test/test_code.py�constsvs


r
cCs@x&dD]}td|t|d|�f�qWtdtt|j���dS)N)	�nameZargcountZkwonlyargcount�namesZvarnamesZcellvarsZfreevarsZnlocals�flagsz%s: %sZco_zconsts:)�print�getattr�tupler
�	co_consts)�co�attrrrr�dumps
rcCsdt��|���S)NzForeign getitem: )�super�__getitem__)�self�irrr�external_getitem�src@s$eZdZedd��Zedd��ZdS)�CodeTestcCsDddl}|�ddd�}|�|jd�|�|jd�|�|jd�dS)Nr�filename�funcname�)�	_testcapiZ
code_newempty�assertEqual�co_filenamer�co_firstlineno)rr!rrrr�
test_newempty�s
zCodeTest.test_newemptycs�ddlm�m�dd���fdd�����fdd�}Gd	d
�d
t�}||dt�|j}|jdj}|�||�|�	|j
jtj
@t|j
j��|dd
dg�}|�|dd�dS)Nr)�FunctionType�CodeTypecs�fdd�jS)Ncs�S)Nrr)�	__class__rr�<lambda>��zICodeTest.test_closure_injection.<locals>.create_closure.<locals>.<lambda>)�__closure__)r(r)r(r�create_closure�sz7CodeTest.test_closure_injection.<locals>.create_closurecsF�|j|j|j|j|j|j|j|j|j|j	|j
|j|j|j
d|j�S)N)r()�co_argcount�co_kwonlyargcount�
co_nlocals�co_stacksize�co_flags�co_coder�co_names�co_varnamesr#rr$�	co_lnotab�co_freevars�co_cellvars)�c)r'rr�new_code�s
z1CodeTest.test_closure_injection.<locals>.new_codec	s6�|j�}�|�}|j}t||�|t�|||��dS)N)�__code__�__defaults__�setattr�globals)�clsr�f�codeZclosure�defaults)r&r,r9rr�add_foreign_method�s
z;CodeTest.test_closure_injection.<locals>.add_foreign_methodc@seZdZdS)z-CodeTest.test_closure_injection.<locals>.ListN)�__name__�
__module__�__qualname__rrrr�List�srFr���zForeign getitem: 1)�typesr&r'�listrrr+�
cell_contentsZassertIs�assertFalser:r1�inspectZ	CO_NOFREE�hexr")rrBrFZfunctionZ	class_ref�objr)r'r&r,r9r�test_closure_injection�szCodeTest.test_closure_injectionN)rCrDrErr%rQrrrrr�srcCs|t�d|ddd��kS)N�_rG���)�sys�intern)�srrr�
isinterned�srWc@s`eZdZdd�Zdd�Zdd�Zedd��Zed	d
��Zedd��Z	ed
d��Z
edd��ZdS)�CodeConstsTestcCs4x|D]}||kr|SqW|�||�|�d�dS)NzShould never be reached)ZassertIn�fail)rr
�value�vrrr�
find_const�s

zCodeConstsTest.find_constcCst|�s|�d|f�dS)NzString %r is not interned)rWrY)rrVrrr�assertIsInterned�szCodeConstsTest.assertIsInternedcCst|�r|�d|f�dS)NzString %r is interned)rWrY)rrVrrr�assertIsNotInterned�sz"CodeConstsTest.assertIsNotInternedcCs(tddd�}|�|jd�}|�|�dS)Nzres = "str_value"�?�exec�	str_value)�compiler\rr])rrr[rrr�test_interned_string�sz#CodeConstsTest.test_interned_stringcCs,tddd�}|�|jd�}|�|d�dS)Nzres = ("str_value",)r_r`)rar)rbr\rr])rrr[rrr�test_interned_string_in_tuple�sz,CodeConstsTest.test_interned_string_in_tuplecCs4tddd�}|�|jtd��}|�t|�d�dS)Nzres = a in {"str_value"}r_r`)rar)rbr\r�	frozensetr]r)rrr[rrr�!test_interned_string_in_frozenset�sz0CodeConstsTest.test_interned_string_in_frozensetcCsddd�}|�|��dS)NracSs|S)Nr)�arrrr?�sz6CodeConstsTest.test_interned_string_default.<locals>.f)ra)r])rr?rrr�test_interned_string_default�s
z+CodeConstsTest.test_interned_string_defaultcCs(tddd�}|�|jd�}|�|�dS)Nzres = "str\0value!"r_r`z
strvalue!)rbr\rr^)rrr[rrr�test_interned_string_with_null�sz-CodeConstsTest.test_interned_string_with_nullN)rCrDrEr\r]r^rrcrdrfrhrirrrrrX�srXc@seZdZdd�ZdS)�CodeWeakRefTestcsni}tdt�|�|d}~d�_�fdd�}t�|j|�}��t|���~��t|������j�dS)Nz
def f(): passr?Fcs
d�_dS)NT)�called)r@)rrr�callback�sz,CodeWeakRefTest.test_basic.<locals>.callback)	r`r=rk�weakref�refr:Z
assertTrue�boolrM)r�	namespacer?rlZcoderefr)rr�
test_basic�szCodeWeakRefTest.test_basicN)rCrDrErqrrrrrj�srjT)�cpythoncCs|adS)N)�
LAST_FREED)Zptrrrr�myfreesrtc@s<eZdZdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Zd
S)�CoExtracCstd�S)Nz	lambda:42)�eval)rrrr�get_func$szCoExtra.get_funcc	Cs<|��}|�ttdtt�d��|�ttdtt�d��dS)N�*�d)rw�assertRaises�SystemError�SetExtra�
FREE_INDEX�ctypes�c_voidp�GetExtra)rr?rrr�test_get_non_code*s
zCoExtra.test_get_non_codec	CsJ|��}|�tt|jtdt�d��|�t	|jtdt�d��d�dS)Nryr)
rwrzr{r|r:r}r~rr"r�)rr?rrr�test_bad_index2s
zCoExtra.test_bad_indexcCs.|��}t|jtt�d��~|�td�dS)Nry)rwr|r:r}r~rr"rs)rr?rrr�test_free_called9szCoExtra.test_free_calledcCsn|��}t��}t|jtt�d��t|jtt�d��|�td�t��}t|jt|�|�|j	d�~dS)N��i,)
rwr~rr|r:r}r"rsr�rZ)rr?Zextrarrr�test_get_setBszCoExtra.test_get_setcCsZ|��}Gdd�dtj�}t|jtt�d��|||�}~|��|�	�|�
td�dS)Ncs$eZdZ�fdd�Zdd�Z�ZS)z6CoExtra.test_free_different_thread.<locals>.ThreadTestcst���||_||_dS)N)r�__init__r?�test)rr?r�)r(rrr�Ws
z?CoExtra.test_free_different_thread.<locals>.ThreadTest.__init__cSs|`|j�td�dS)Ni�)r?r�r"rs)rrrr�run[sz:CoExtra.test_free_different_thread.<locals>.ThreadTest.run)rCrDrEr�r��
__classcell__rr)r(r�
ThreadTestVsr�i�)rw�	threadingZThreadr|r:r}r~r�start�joinr"rs)rr?r��ttrrr�test_free_different_threadRs	
z"CoExtra.test_free_different_threadN)	rCrDrErwr�r�r�r�r�rrrrru#s	rucCsHddlm}t||�tttg}tdd�r<tdk	r<|�t	�t
|�dS)Nr)�	test_codeT)rr)r�r�rrrXrjrr~�appendrur)�verboser�Ztestsrrr�	test_mainfs


r��__main__)N),rNrTr�Zunittestrmr~�ImportErrorZtest.supportrrrrr
rrZTestCaserrWrXrjZ	pythonapi�pyZ	CFUNCTYPErZfreefuncZ_PyEval_RequestCodeExtraIndexZRequestCodeExtraIndexZargtypesZ	c_ssize_tZrestypeZ_PyCode_SetExtrar|Z	py_objectZc_intZ_PyCode_GetExtrar�ZPOINTERrsrtZ	FREE_FUNCr}rur�rCrrrr�<module>isJ
		30C