Server : LiteSpeed
System : Linux server51.dnsbootclub.com 4.18.0-553.62.1.lve.el8.x86_64 #1 SMP Mon Jul 21 17:50:35 UTC 2025 x86_64
User : nandedex ( 1060)
PHP Version : 8.1.33
Disable Function : NONE
Directory :  /opt/cppython/lib/python3.8/test/__pycache__/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]


Current File : //opt/cppython/lib/python3.8/test/__pycache__/test_code.cpython-38.opt-2.pyc
U

>��g�6�@s�ddlZddlZddlZddlZddlZddlZzddlZWnek
rTdZYnXddlm	Z	m
Z
mZmZdd�Z
dd�Zdd�ZGd	d
�d
ej�Zdd�ZGd
d�dej�ZGdd�dej�Zedd��rxedk	�rxejZe�dej�ZejZefe_eje_ejZ ej!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_detailccs4|D]*}t|�}|�d�r(d|jVq|VqdS)Nz<code objectz<code object %s>)�repr�
startswith�co_name)�tZelt�r�r�-/opt/cppython/lib/python3.8/test/test_code.py�consts�s

r
cCs<dD]}td|t|d|�f�qtdtt|j���dS)N)
�nameZargcountZposonlyargcountZkwonlyargcount�namesZvarnamesZcellvarsZfreevarsZnlocals�flagsz%s: %sZco_zconsts:)�print�getattr�tupler
�	co_consts)�co�attrrrr�dump�srcCsdt��|���S)NzForeign getitem: )�super�__getitem__)�self�irrr�external_getitem�src@s4eZdZedd��Zedd��Zdd�Zdd�Zd	S)
�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�dd��dd�����fdd�}Gd	d
�d
t�}||dt�|j}|jdj}|�||�|�|j	j
tj@t
|j	j
��|dd
dg�}|�|dd�dS)Nr)�FunctionTypecs�fdd�jS)Ncs�S�Nrr��	__class__rr�<lambda>��zICodeTest.test_closure_injection.<locals>.create_closure.<locals>.<lambda>)�__closure__r(rr(r�create_closure�sz7CodeTest.test_closure_injection.<locals>.create_closurecSs|j|jdd�S)Nr()�co_freevars)�replacer.)�crrr�new_code�sz1CodeTest.test_closure_injection.<locals>.new_codec	s6�|j�}�|�}|j}t||�|t�|||��dSr')�__code__�__defaults__�setattr�globals)�clsr�f�codeZclosure�defaults�r&r-r1rr�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�sr@r���zForeign getitem: 1)�typesr&�listrrr,�
cell_contentsZassertIs�assertFalser2�co_flags�inspectZ	CO_NOFREE�hexr")rr;r@�functionZ	class_ref�objrr:r�test_closure_injection�s
�zCodeTest.test_closure_injectioncCs\dd�}|j}t|�}||j|j|j|j|j|j|j|j	|j
|j|j|j
|j|j|j|j�S)NcSsdSr'rrrrr�func�r+z'CodeTest.test_constructor.<locals>.func)r2�type�co_argcount�co_posonlyargcount�co_kwonlyargcount�
co_nlocals�co_stacksizerH�co_coder�co_names�co_varnamesr#rr$�	co_lnotabr.�co_cellvars)rrNr�CodeTyperrr�test_constructor�s(�zCodeTest.test_constructorcCs�dd�}|j}dd�}|j}ddddd	d
|jtjBfdd|jfd
|jfdd|jfddddd|jffD]D\}}|j||d��(|j	f||i�}|�
t||�|�W5QRXqddS)NcSsd}|S)NrAr��xrrrrN�sz#CodeTest.test_replace.<locals>.funccSsd}|S)NrBr)�yrrr�func2�sz$CodeTest.test_replace.<locals>.func2)rPr)rQr)rRr)rSr)rTrrH)r$�drUr)rV)ZmynamerW)r.)Zfreevar)rY)Zcellvar)r#Znewfilename)rZnewnamerX)r�value)r2rHrIZCO_COROUTINErUrrWrXZsubTestr/r"r)rrNr8r_�code2rrar1rrr�test_replace�s0�zCodeTest.test_replaceN)r=r>r?rr%rMr[rcrrrrr�s

$rcCs|t�d|ddd��kS)N�_rA���)�sys�intern)�srrr�
isinterned
sric@s`eZdZdd�Zdd�Zdd�Zedd��Zed	d
��Zedd��Z	ed
d��Z
edd��ZdS)�CodeConstsTestcCs4|D]}||kr|Sq|�||�|�d�dS)NzShould never be reached)ZassertIn�fail)rr
ra�vrrr�
find_consts

zCodeConstsTest.find_constcCst|�s|�d|f�dS)NzString %r is not interned�rirk�rrhrrr�assertIsInternedszCodeConstsTest.assertIsInternedcCst|�r|�d|f�dS)NzString %r is internedrnrorrr�assertIsNotInternedsz"CodeConstsTest.assertIsNotInternedcCs(tddd�}|�|jd�}|�|�dS)Nzres = "str_value"�?�exec�	str_value��compilermrrp�rrrlrrr�test_interned_string!sz#CodeConstsTest.test_interned_stringcCs,tddd�}|�|jd�}|�|d�dS)Nzres = ("str_value",)rrrs�rtrrurwrrr�test_interned_string_in_tuple'sz,CodeConstsTest.test_interned_string_in_tuplecCs4tddd�}|�|jtd��}|�t|�d�dS)Nzres = a in {"str_value"}rrrsryr)rvrmr�	frozensetrprrwrrr�!test_interned_string_in_frozenset-sz0CodeConstsTest.test_interned_string_in_frozensetcCsddd�}|�|��dS)NrtcSs|Sr'r)�arrrr75sz6CodeConstsTest.test_interned_string_default.<locals>.f)rt)rp�rr7rrr�test_interned_string_default3s
z+CodeConstsTest.test_interned_string_defaultcCs(tddd�}|�|jd�}|�|�dS)Nzres = "str\0value!"rrrsz
strvalue!)rvrmrrqrwrrr�test_interned_string_with_null9sz-CodeConstsTest.test_interned_string_with_nullN)r=r>r?rmrprqrrxrzr|rr�rrrrrjs



rjc@seZdZdd�ZdS)�CodeWeakRefTestcsni}tdt�|�|d}~d�_�fdd�}t�|j|�}��t|���~��t|������j�dS)Nz
def f(): passr7Fcs
d�_dS)NT)�called)r8�rrr�callbackKsz,CodeWeakRefTest.test_basic.<locals>.callback)	rsr5r��weakref�refr2Z
assertTrue�boolrG)r�	namespacer7r�Zcoderefrr�r�
test_basicBszCodeWeakRefTest.test_basicN)r=r>r?r�rrrrr�@sr�T�ZcpythoncCs|adSr')�
LAST_FREED)Zptrrrr�myfreeksr�c@sHeZdZdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Ze	d
d��Z
dS)�CoExtracCstd�S)Nz	lambda:42)�evalr�rrr�get_funcsszCoExtra.get_funcc	Cs<|��}|�ttdtt�d��|�ttdtt�d��dS)N�*r`)r��assertRaises�SystemError�SetExtra�
FREE_INDEX�ctypes�c_voidp�GetExtrar~rrr�test_get_non_codeys��zCoExtra.test_get_non_codec	CsJ|��}|�tt|jtdt�d��|�t	|jtdt�d��d�dS)Nr`r)
r�r�r�r�r2r�r�r�r"r�r~rrr�test_bad_index�s���zCoExtra.test_bad_indexcCs.|��}t|jtt�d��~|�td�dS)Nr`)r�r�r2r�r�r�r"r�r~rrr�test_free_called�szCoExtra.test_free_calledcCsn|��}t��}t|jtt�d��t|jtt�d��|�td�t��}t|jt|�|�|j	d�~dS)N��i,)
r�r�r�r�r2r�r"r�r�ra)rr7�extrarrr�test_get_set�szCoExtra.test_get_setcCsZ|��}Gdd�dtj�}t|jtt�d��|||�}~|��|�	�|�
td�dS)Ncs$eZdZ�fdd�Zdd�Z�ZS)z6CoExtra.test_free_different_thread.<locals>.ThreadTestcst���||_||_dSr')r�__init__r7�test)rr7r�r(rrr��s
z?CoExtra.test_free_different_thread.<locals>.ThreadTest.__init__cSs|`|j�td�dS)N��)r7r�r"r�r�rrr�run�sz:CoExtra.test_free_different_thread.<locals>.ThreadTest.run)r=r>r?r�r��
__classcell__rrr(r�
ThreadTest�sr�r�)r��	threading�Threadr�r2r�r�r��start�joinr"r�)rr7r��ttrrr�test_free_different_thread�s	
z"CoExtra.test_free_different_threadc
Cs�dd�}|j}t|j�}t|j�}|�dtjd�|�dd�||j|j|j	|j
|jd|jt
|�|j|j|j|j|j|j|j|j|j�}t|�||jd|j|j�}Gdd	�d	�}|�}t�|�}	||�~dS)
NcSs|Sr'rr\rrrr7�sz-CoExtra.test_clean_stack_on_return.<locals>.f���Z	LOAD_FASTrrAZnfc@seZdZdS)z/CoExtra.test_clean_stack_on_return.<locals>.VarNr<rrrr�Var�sr�)r2rOrErU�insert�opcodeZopmaprPrQrRrSrTrH�bytesrrVrWr#rr$rXr.rY�__globals__r3r,r�r�)
rr7r8�ct�bytecoder0Znew_functionr�Z
the_object�varrrr�test_clean_stack_on_return�s:


�
z"CoExtra.test_clean_stack_on_returnN)r=r>r?r�r�r�r�r�r�rr�rrrrr�rs	r�cCsHddlm}t||�tttg}tdd�r<tdk	r<|�t	�t
|�dS)Nr)�	test_codeTr�)r�r�rrrjr�rr��appendr�r)�verboser�Ztestsrrr�	test_main�s


r��__main__)N)-rIrfr�Zunittestr�r�r��ImportErrorZtest.supportrrrrr
rrZTestCaserrirjr�Z	pythonapi�pyZ	CFUNCTYPEr�ZfreefuncZ_PyEval_RequestCodeExtraIndexZRequestCodeExtraIndexZargtypesZ	c_ssize_tZrestypeZ_PyCode_SetExtrar�Z	py_objectZc_intZ_PyCode_GetExtrar�ZPOINTERr�r�Z	FREE_FUNCr�r�r�r=rrrr�<module>�sN
	
i0
�h



F1le Man4ger