Sindbad~EG File Manager

Current Path : /usr/local/lib/python3.9/test/__pycache__/
Upload File :
Current File : //usr/local/lib/python3.9/test/__pycache__/test_code.cpython-39.opt-2.pyc

a

��g�1�@s�ddlZddlZddlZddlZddlZzddlZWneyJdZYn0ddlmZm	Z	m
Z
mZmZdd�Z
dd�Zdd�ZGd	d
�d
ej�Zdd�ZGd
d�dej�ZGdd�dej�Zedd��rredu�rrejZe�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_detail�
gc_collectccs4|D]*}t|�}|�d�r(d|jVq|VqdS)Nz<code objectz<code object %s>)�repr�
startswith�co_name)�t�elt�r�r
�*/usr/local/lib/python3.9/test/test_code.py�consts�s

rcCs<dD]}td|t|d|�f�qtdtt|j���dS)N)
�nameZargcountZposonlyargcountZkwonlyargcount�namesZvarnamesZcellvarsZfreevarsZnlocals�flagsz%s: %sZco_zconsts:)�print�getattr�tupler�	co_consts)�co�attrr
r
r�dump�srcCsdt��|���S)NzForeign getitem: )�super�__getitem__)�self�ir
r
r�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#rr
r
r�
test_newempty�s
zCodeTest.test_newemptycs�ddlm�dd��dd�����fdd�}Gd	d
�d
t�}||dt�|j}|jdj}|�||�|�|j	j
tj@t
|j	j
��|gd��}|�|dd
�dS)Nr)�FunctionTypecs�fdd�jS)Ncs�S�Nr
r
��	__class__r
r�<lambda>��zICodeTest.test_closure_injection.<locals>.create_closure.<locals>.<lambda>)�__closure__r*r
r*r�create_closure�sz7CodeTest.test_closure_injection.<locals>.create_closurecSs|j|jdd�S)Nr*)�co_freevars)�replacer0)�cr
r
r�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/r3r
r�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__r
r
r
r�List�srAr)���zForeign getitem: 1)�typesr(�listrrr.�
cell_contentsZassertIs�assertFalser4�co_flags�inspectZ	CO_NOFREE�hexr$)rr=rA�functionZ	class_ref�objr
r<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�dS)NcSsdSr)r
r
r
r
r�func�r-z'CodeTest.test_constructor.<locals>.func)r4�type�co_argcount�co_posonlyargcount�co_kwonlyargcount�
co_nlocals�co_stacksizerI�co_coder�co_names�co_varnamesr%r	r&�	co_lnotabr0�co_cellvars)rrOr�CodeTyper
r
r�test_constructor�s(�zCodeTest.test_constructorcCs�dd�}|j}dd�}|j}ddddd	d
|jtjBfdd|jfd
|jfdd|jfddddd|jffD]\\}}|j||d��6|j	fi||i��}|�
t||�|�Wd�qd1s�0YqddS)NcSsd}|S)NrBr
)�xr
r
rrO�sz#CodeTest.test_replace.<locals>.funccSsd}|S)NrCr
)�yr
r
r�func2�sz$CodeTest.test_replace.<locals>.func2)rQr)rRr)rSr)rTr)rUrrI)r&�drVr)rW)ZmynamerX)r0)Zfreevar)rZ)Zcellvar)r%Znewfilename)r	ZnewnamerY)r�value)r4rIrJZCO_COROUTINErVrrXrYZsubTestr1r$r)rrOr:r_�code2rrar3r
r
r�test_replace�s0�zCodeTest.test_replaceN)r>r?r@rr'rNr\rcr
r
r
rr�s

$rcCs|t�d|ddd��uS)N�_rB���)�sys�intern)�sr
r
r�
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)rrra�vr
r
r�
find_consts

zCodeConstsTest.find_constcCst|�s|�d|f�dS)NzString %r is not interned�rirk�rrhr
r
r�assertIsInternedszCodeConstsTest.assertIsInternedcCst|�r|�d|f�dS)NzString %r is internedrnror
r
r�assertIsNotInternedsz"CodeConstsTest.assertIsNotInternedcCs(tddd�}|�|jd�}|�|�dS)Nzres = "str_value"�?�exec�	str_value��compilermrrp�rrrlr
r
r�test_interned_string sz#CodeConstsTest.test_interned_stringcCs,tddd�}|�|jd�}|�|d�dS)Nzres = ("str_value",)rrrs�rtrrurwr
r
r�test_interned_string_in_tuple&sz,CodeConstsTest.test_interned_string_in_tuplecCs4tddd�}|�|jtd��}|�t|�d�dS)Nzres = a in {"str_value"}rrrsryr)rvrmr�	frozensetrprrwr
r
r�!test_interned_string_in_frozenset,sz0CodeConstsTest.test_interned_string_in_frozensetcCsddd�}|�|��dS)NrtcSs|Sr)r
)�ar
r
rr94sz6CodeConstsTest.test_interned_string_default.<locals>.f)rt)rp�rr9r
r
r�test_interned_string_default2s
z+CodeConstsTest.test_interned_string_defaultcCs(tddd�}|�|jd�}|�|�dS)Nzres = "str\0value!"rrrsz
strvalue!)rvrmrrqrwr
r
r�test_interned_string_with_null8sz-CodeConstsTest.test_interned_string_with_nullN)r>r?r@rmrprqrrxrzr|rr�r
r
r
rrjs



rjc@seZdZdd�ZdS)�CodeWeakRefTestcsti}tdt�|�|d}~d�_�fdd�}t�|j|�}��t|���~t���	t|������j�dS)Nz
def f(): passr9Fcs
d�_dS)NT)�called)r:�rr
r�callbackJsz,CodeWeakRefTest.test_basic.<locals>.callback)
rsr7r��weakref�refr4Z
assertTrue�boolrrH)r�	namespacer9r�Zcoderefr
r�r�
test_basicAszCodeWeakRefTest.test_basicN)r>r?r@r�r
r
r
rr�?sr�T�ZcpythoncCs|adSr))�
LAST_FREED)Zptrr
r
r�myfreeksr�c@s<eZdZdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Zd
S)�CoExtracCstd�S)Nz	lambda:42)�evalr�r
r
r�get_funcsszCoExtra.get_funcc	Cs<|��}|�ttdtt�d��|�ttdtt�d��dS)N�*r`)r��assertRaises�SystemError�SetExtra�
FREE_INDEX�ctypes�c_voidp�GetExtrar~r
r
r�test_get_non_codeys��zCoExtra.test_get_non_codec	CsJ|��}|�tt|jtdt�d��|�t	|jtdt�d��d�dS)Nr`r)
r�r�r�r�r4r�r�r�r$r�r~r
r
r�test_bad_index�s���zCoExtra.test_bad_indexcCs.|��}t|jtt�d��~|�td�dS)Nr`)r�r�r4r�r�r�r$r�r~r
r
r�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�r4r�r$r�r�ra)rr9�extrar
r
r�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__r9�test)rr9r�r*r
rr��s
z?CoExtra.test_free_different_thread.<locals>.ThreadTest.__init__cSs|`|j�td�dS)N��)r9r�r$r�r�r
r
r�run�sz:CoExtra.test_free_different_thread.<locals>.ThreadTest.run)r>r?r@r�r��
__classcell__r
r
r*r�
ThreadTest�sr�r�)r��	threading�Threadr�r4r�r�r��start�joinr$r�)rr9r��ttr
r
r�test_free_different_thread�s	
z"CoExtra.test_free_different_threadN)	r>r?r@r�r�r�r�r�r�r
r
r
rr�rs	r�cCsHddlm}t||�tttg}tdd�r<tdur<|�t	�t
|�dS)Nr)�	test_codeTr�)r�r�rrrjr�rr��appendr�r)�verboser�Ztestsr
r
r�	test_main�s


r��__main__)N)-rJrfr�Zunittestr�r��ImportErrorZtest.supportrrrrrrrrZTestCaserrirjr�Z	pythonapi�pyZ	CFUNCTYPEr�ZfreefuncZ_PyEval_RequestCodeExtraIndexZRequestCodeExtraIndex�argtypesZ	c_ssize_tZrestypeZ_PyCode_SetExtrar�Z	py_objectZc_intZ_PyCode_GetExtrar�ZPOINTERr�r�Z	FREE_FUNCr�r�r�r>r
r
r
r�<module>�sL
	
i0
�D



Sindbad File Manager Version 1.0, Coded By Sindbad EG ~ The Terrorists