403Webshell
Server IP : 118.27.122.248  /  Your IP : 216.73.217.130
Web Server : Apache
System : Linux web0264.sh.tyo1 4.18.0-553.79.1.lve.el7h.x86_64 #1 SMP Wed Oct 15 16:34:46 UTC 2025 x86_64
User : c9415830 ( 11735)
PHP Version : 8.4.17
Disable Function : NONE
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : ON  |  Sudo : OFF  |  Pkexec : OFF
Directory :  /opt/alt/python36/lib64/python3.6/test/__pycache__/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /opt/alt/python36/lib64/python3.6/test/__pycache__/test_finalization.cpython-36.pyc
3

�w2_�8�@sdZddlZddlZddlZddlZyddlmZWnek
rPdd�ZYnXddlm	Z	Gdd�d�Z
Gd	d
�d
e
�ZGdd�de
�ZGd
d�de
�Z
Gdd�de�ZGdd�de
e�ZGdd�d�ZGdd�deej�ZGdd�d�ZGdd�dee�ZGdd�dee�ZGdd�dee�ZGdd �d eej�ZGd!d"�d"�ZGd#d$�d$ee�ZGd%d&�d&ee�ZGd'd(�d(ee�ZGd)d*�d*eej�ZGd+d,�d,e�ZeGd-d.�d.e��ZeGd/d0�d0e��ZeGd1d2�d2ee��Z e	j!Gd3d4�d4eej��Z"e#d5k�r
ej$�dS)6zB
Tests for object finalization semantics, as outlined in PEP 442.
�N)�with_tp_delcCsGdd�dt�}|S)Nc@seZdZdd�ZdS)zwith_tp_del.<locals>.Cc_std��dS)Nzrequires _testcapi.with_tp_del)�	TypeError)�cls�args�kwargs�r�;/opt/alt/python36/lib64/python3.6/test/test_finalization.py�__new__szwith_tp_del.<locals>.C.__new__N)�__name__�
__module__�__qualname__r	rrrr�Csr
)�object)rr
rrrr
sr)�supportc@s^eZdZdZgZgZgZgZdZfZ	e
dd��Ze
ej
dd���Zdd�Zd	d
�Zdd�Zd
S)�NonGCSimpleBasezd
    The base class for all the objects under test, equipped with various
    testing features.
    FcCs>|jj�|jj�tjj�tj�|jj�|jj�dS)N)�	survivors�clear�errors�gc�garbage�collect�	del_calls�tp_del_calls)rrrr�_cleanup%s



zNonGCSimpleBase._cleanupccs^tj��L|jj�|jj�dt_zdV|jr<|jd�Wddt_|j�XWdQRXdS)zI
        A context manager to use around all finalization tests.
        FNrT)	rZ
disable_gcrrrr�	_cleaningrr)rrrr�test.s


zNonGCSimpleBase.testcCsdS)z8
        Check the object is sane (non-broken).
        Nr)�selfrrr�check_sanity@szNonGCSimpleBase.check_sanitycCs^y*|js(|jjt|��|j�|j�Wn.tk
rX}z|jj|�WYdd}~XnXdS)z�
        PEP 442 finalizer.  Record that this was called, check the
        object is in a sane state, and invoke a side effect.
        N)rr�append�idr�side_effect�	Exceptionr)r�errr�__del__EszNonGCSimpleBase.__del__cCsdS)z6
        A side effect called on destruction.
        Nr)rrrrr RszNonGCSimpleBase.side_effectN)r
rr�__doc__rrrrr�	__slots__�classmethodr�
contextlib�contextmanagerrrr#r rrrrrs	
rc@seZdZdd�Zdd�ZdS)�
SimpleBasecCst|�|_dS)N)r�id_)rrrr�__init__ZszSimpleBase.__init__cCs|jt|�kst�dS)N)r*r�AssertionError)rrrrr]szSimpleBase.check_sanityN)r
rrr+rrrrrr)Xsr)c@seZdZfZdS)�NonGCN)r
rrr%rrrrr-asr-c@seZdZfZdd�ZdS)�NonGCResurrectorcCs|jj|�dS)zF
        Resurrect self by storing self in a class-wide list.
        N)rr)rrrrr gszNonGCResurrector.side_effectN)r
rrr%r rrrrr.dsr.c@seZdZdS)�SimpleN)r
rrrrrrr/msr/c@seZdZdS)�SimpleResurrectorN)r
rrrrrrr0psr0c@sDeZdZdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	dS)�TestBasecCs"tjdd�|_gtjdd�<dS)N)rr�old_garbage)rrrr�setUpvszTestBase.setUpc
Cs&z|jtjg�Wd|`tj�XdS)N)�assertEqualrrr2r)rrrr�tearDownzszTestBase.tearDowncCs|jttj�t|��dS)N)r4�sortedr)r)r�idsrrr�assert_del_calls�szTestBase.assert_del_callscCs|jttj�t|��dS)N)r4r6r)r)rr7rrr�assert_tp_del_calls�szTestBase.assert_tp_del_callscCs$|jtdd�tjD��t|��dS)Ncss|]}t|�VqdS)N)r)�.0�xrrr�	<genexpr>�sz,TestBase.assert_survivors.<locals>.<genexpr>)r4r6r)r)rr7rrr�assert_survivors�szTestBase.assert_survivorscCs$|jtdd�tjD��t|��dS)Ncss|]}t|�VqdS)N)r)r:r;rrrr<�sz*TestBase.assert_garbage.<locals>.<genexpr>)r4r6rr)rr7rrr�assert_garbage�szTestBase.assert_garbagecCstjj�dS)N)r)rr)rrrr�clear_survivors�szTestBase.clear_survivorsN)
r
rrr3r5r8r9r=r>r?rrrrr1tsr1c@s0eZdZdZdd�Zdd�Zdd�Zdd	�Zd
S)�SimpleFinalizationTestz.
    Test finalization without refcycles.
    c
Csztj��ht�}t|�g}tj|�}~tj�|j|�|j	g�|j
|�d�tj�|j|�|j	g�WdQRXdS)N)r)rr/r�weakref�refrrr8r=�assertIs)r�sr7�wrrrr�test_simple�s





z"SimpleFinalizationTest.test_simplec
Cs�tj��pt�}t|�g}tj|�}~tj�|j|�|j	|�|j
|�d�|j�tj�|j|�|j	g�WdQRX|j|�d�dS)N)
r)rr0rrArBrrr8r=�assertIsNotr?rC)rrDr7rErrr�test_simple_resurrect�s





z,SimpleFinalizationTest.test_simple_resurrectc
Csrtj��`t�}|jtj|��t|�g}~tj�|j|�|j	g�tj�|j|�|j	g�WdQRXdS)N)
r)rr-�assertFalser�
is_trackedrrr8r=)rrDr7rrr�test_non_gc�s




z"SimpleFinalizationTest.test_non_gcc
Cs~tj��lt�}|jtj|��t|�g}~tj�|j|�|j	|�|j
�tj�|j|d�|j	|�WdQRXdS)N�)r)rr.rIrrJrrr8r=r?)rrDr7rrr�test_non_gc_resurrect�s



z,SimpleFinalizationTest.test_non_gc_resurrectN)r
rrr$rFrHrKrMrrrrr@�s

r@cs(eZdZ�fdd�Z�fdd�Z�ZS)�
SelfCycleBasecst�j�||_dS)N)�superr+rB)r)�	__class__rrr+�s
zSelfCycleBase.__init__cst�j�|j|kst�dS)N)rOrrBr,)r)rPrrr�s
zSelfCycleBase.check_sanity)r
rrr+r�
__classcell__rr)rPrrN�srNc@seZdZdS)�SimpleSelfCycleN)r
rrrrrrrR�srRc@seZdZdS)�SelfCycleResurrectorN)r
rrrrrrrS�srSc@seZdZdd�ZdS)�SuicidalSelfCyclecCs
d|_dS)z7
        Explicitly break the reference cycle.
        N)rB)rrrrr �szSuicidalSelfCycle.side_effectN)r
rrr rrrrrT�srTc@s(eZdZdZdd�Zdd�Zdd�ZdS)	�SelfCycleFinalizationTestzX
    Test finalization of an object having a single cyclic reference to
    itself.
    c
Csztj��ht�}t|�g}tj|�}~tj�|j|�|j	g�|j
|�d�tj�|j|�|j	g�WdQRXdS)N)r)rrRrrArBrrr8r=rC)rrDr7rErrrrF�s





z%SelfCycleFinalizationTest.test_simplec
Cs�tj��~t�}t|�g}tj|�}~tj�|j|�|j	|�|j
|�d�|j�tj�|j|�|j	g�|j
|�d�WdQRXdS)N)r)rrSrrArBrrr8r=rCr?)rrDr7rErrrrH�s






z/SelfCycleFinalizationTest.test_simple_resurrectc
Cs�tj��vt�}t|�g}tj|�}~tj�|j|�|j	g�|j
|�d�tj�|j|�|j	g�|j
|�d�WdQRXdS)N)r)rrTrrArBrrr8r=rC)rrDr7rErrr�test_simple_suicides






z-SelfCycleFinalizationTest.test_simple_suicideN)r
rrr$rFrHrVrrrrrU�srUcs$eZdZdd�Z�fdd�Z�ZS)�ChainedBasecCsd|_||_||_dS)NF)�suicided�left�right)rrYrrr�chain&szChainedBase.chaincs�t�j�|jr.|jdkst�|jdks�t�nT|j}|jrJ|jdksXt�n|j|ksXt�|j}|jrt|jdks�t�n|j|ks�t�dS)N)rOrrXrYr,rZ)rrYrZ)rPrrr+s
zChainedBase.check_sanity)r
rrr[rrQrr)rPrrW$srWc@seZdZdS)�
SimpleChainedN)r
rrrrrrr\<sr\c@seZdZdS)�ChainedResurrectorN)r
rrrrrrr]?sr]c@seZdZdd�ZdS)�SuicidalChainedcCsd|_d|_d|_dS)z7
        Explicitly break the reference cycle.
        TN)rXrYrZ)rrrrr DszSuicidalChained.side_effectN)r
rrr rrrrr^Bsr^c@sheZdZdZdd�Zdd�Zdd�Zdd	�Zd
d�Zdd
�Z	dd�Z
dd�Zdd�Zdd�Z
dd�ZdS)�CycleChainFinalizationTestz�
    Test finalization of a cyclic chain.  These tests are similar in
    spirit to the self-cycle tests above, but the collectable object
    graph isn't trivial anymore.
    cCs>dd�|D�}x*tt|��D]}||j||d�qW|S)NcSsg|]
}|��qSrr)r:rrrr�
<listcomp>Usz:CycleChainFinalizationTest.build_chain.<locals>.<listcomp>�)�range�lenr[)r�classes�nodes�irrr�build_chainTsz&CycleChainFinalizationTest.build_chaincCs�t|�}tj��x|j|�}dd�|D�}dd�|D�}~tj�|j|�|jg�|jdd�|D�dg|�tj�|j|�WdQRXdS)NcSsg|]}t|��qSr)r)r:rDrrrr`^szKCycleChainFinalizationTest.check_non_resurrecting_chain.<locals>.<listcomp>cSsg|]}tj|��qSr)rArB)r:rDrrrr`_scSsg|]
}|��qSrr)r:rErrrr`ds)	rcr)rrgrrr8r=r4)rrd�Nrer7�wrsrrr�check_non_resurrecting_chainZs



z7CycleChainFinalizationTest.check_non_resurrecting_chaincCs�t|�}tj���|j|�}t|�}dd�|D�}dd�|D�}dd�|D�}~tj�|j|�|j|�|jdd�|D�dg|�|j	�tj�|j|�|jg�WdQRXdS)NcSsg|]}t|��qSr)r)r:rDrrrr`mszGCycleChainFinalizationTest.check_resurrecting_chain.<locals>.<listcomp>cSsg|]}t|t�rt|��qSr)�
isinstancer0r)r:rDrrrr`nscSsg|]}tj|��qSr)rArB)r:rDrrrr`oscSsg|]
}|��qSrr)r:rErrrr`us)
rcr)rrgrrr8r=r4r?)rrdrhrer7Zsurvivor_idsrirrr�check_resurrecting_chainhs 




z3CycleChainFinalizationTest.check_resurrecting_chaincCs|jtgd�dS)N�)rjr\)rrrr�test_homogenous{sz*CycleChainFinalizationTest.test_homogenouscCs|jtgd�dS)Nrm)rlr])rrrr�test_homogenous_resurrect~sz4CycleChainFinalizationTest.test_homogenous_resurrectcCs|jtgd�dS)Nrm)rjr^)rrrr�test_homogenous_suicidal�sz3CycleChainFinalizationTest.test_homogenous_suicidalcCs|jttgd�dS)NrL)rjr^r\)rrrr�test_heterogenous_suicidal_one�sz9CycleChainFinalizationTest.test_heterogenous_suicidal_onecCs|jtgdtgd�dS)NrL)rjr^r\)rrrr�test_heterogenous_suicidal_two�sz9CycleChainFinalizationTest.test_heterogenous_suicidal_twocCs|jttgd�dS)NrL)rlr]r\)rrrr�test_heterogenous_resurrect_one�sz:CycleChainFinalizationTest.test_heterogenous_resurrect_onecCs|jtttgd�dS)NrL)rlr]r\r^)rrrr�test_heterogenous_resurrect_two�sz:CycleChainFinalizationTest.test_heterogenous_resurrect_twocCs(|jtgdtgdtgd�dS)NrL)rlr]r\r^)rrrr�!test_heterogenous_resurrect_three�sz<CycleChainFinalizationTest.test_heterogenous_resurrect_threeN)r
rrr$rgrjrlrnrorprqrrrsrtrurrrrr_Msr_c@seZdZdd�Zdd�ZdS)�
LegacyBasecCsVy"|js |jjt|��|j�Wn.tk
rP}z|jj|�WYdd}~XnXdS)N)rrrrrr!r)rr"rrrr#�szLegacyBase.__del__cCs^y*|js(|jjt|��|j�|j�Wn.tk
rX}z|jj|�WYdd}~XnXdS)zJ
        Legacy (pre-PEP 442) finalizer, mapped to a tp_del slot.
        N)rrrrrr r!r)rr"rrr�
__tp_del__�szLegacyBase.__tp_del__N)r
rrr#rwrrrrrv�s
rvc@seZdZdS)�LegacyN)r
rrrrrrrx�srxc@seZdZdd�ZdS)�LegacyResurrectorcCs|jj|�dS)zF
        Resurrect self by storing self in a class-wide list.
        N)rr)rrrrr �szLegacyResurrector.side_effectN)r
rrr rrrrry�sryc@seZdZdS)�LegacySelfCycleN)r
rrrrrrrz�srzcs8eZdZdZ�fdd�Zdd�Zdd�Zdd	�Z�ZS)
�LegacyFinalizationTestz5
    Test finalization of objects with a tp_del.
    cs tjj�tj�t�j�dS)N)rrrrrOr5)r)rPrrr5�s
zLegacyFinalizationTest.tearDownc
Cs�tj��rt�}t|�g}tj|�}~tj�|j|�|j	|�|j
g�|j|�d�tj�|j|�|j	|�WdQRXdS)N)r)rrxrrArBrrr8r9r=rC)rrDr7rErrr�test_legacy�s






z"LegacyFinalizationTest.test_legacyc
Cs�tj���t�}t|�g}tj|�}~tj�|j|�|j	|�|j
|�|j|�d�|j�tj�|j|�|j	|d�|j
|�WdQRX|j|�d�dS)NrL)
r)rryrrArBrrr8r9r=rCr?)rrDr7rErrr�test_legacy_resurrect�s 






z,LegacyFinalizationTest.test_legacy_resurrectc
Cs�tj��lt�}t|�g}tj|�}~tj�|jg�|j	g�|j
g�|j|�|j|�d�dtj
d_WdQRX|jg�|j|�d�dS)Nr)r)rrzrrArBrrr8r9r=r>rGrrC)rrDr7rErrr�test_legacy_self_cycle�s







z-LegacyFinalizationTest.test_legacy_self_cycle)	r
rrr$r5r|r}r~rQrr)rPrr{�s
r{�__main__)%r$r'rZunittestrAZ	_testcapir�ImportErrorrrrr)r-r.r/r0r1ZTestCaser@rNrRrSrTrUrWr\r]r^r_rvrxryrzZcpython_onlyr{r
�mainrrrr�<module>sLB		?
	:M
A


Youez - 2016 - github.com/yon3zu
LinuXploit