python (3.11.7)

(root)/
lib/
python3.11/
test/
__pycache__/
test_finalization.cpython-311.opt-1.pyc

e:dZddlZddlZddlZddlZ	ddlmZn#e$rdZYnwxYw	ddlmZn#e$rdZYnwxYwddl	m
Z
Gdd	ZGd
deZeGdd
eZ
eGddeZGddeZGddeZGddZGddeejZGddZGddeeZGddeeZGddeeZGd d!eejZGd"d#ZGd$d%eeZGd&d'eeZGd(d)eeZGd*d+eejZGd,d-eZeGd.d/eZeGd0d1eZ eGd2d3eeZ!e
j"Gd4d5eejZ#e$d6krej%dSdS)7zB
Tests for object finalization semantics, as outlined in PEP 442.
N)with_tp_delc,Gddt}|S)NceZdZdZdS)with_tp_del.<locals>.Cc td)Nzrequires _testcapi.with_tp_del	TypeErrorclsargskwargss   J/BuggyBox/python/3.11.7/bootstrap/lib/python3.11/test/test_finalization.py__new__zwith_tp_del.<locals>.C.__new__s @AAAN__name__
__module____qualname__rrrCrs(
B
B
B
B
Brr)objectrrs  rrr
s;	B	B	B	B	B	B	B	Br)
without_gcc Gdd}|S)NceZdZdZdS)without_gc.<locals>.Cc td)Nzrequires _testcapi.without_gcrr
s   rrzwithout_gc.<locals>.C.__new__s ?@@@rNrrrrrrs(
A
A
A
A
Arrrrs  rrrs9	A	A	A	A	A	A	A	Ar)supportceZdZdZgZgZgZgZdZdZ	e
dZe
ej
dZdZdZdZd	S)
NonGCSimpleBasezd
    The base class for all the objects under test, equipped with various
    testing features.
    Frc0|j|jtjtj|j|jdSN)	survivorsclearerrorsgcgarbagecollect	del_callstp_del_callsrs r_cleanupzNonGCSimpleBase._cleanup.sx






     rc#Ktj5|j|jdt
_	dV|jr
|jd	dt
_|n%#dt
_|wxYw	ddddS#1swxYwYdS)zI
        A context manager to use around all finalization tests.
        FNrT)	r
disable_gcr)r$r*r 	_cleaningr%r,r+s rtestzNonGCSimpleBase.test7s


!
!
	
	M!!!""$$$(-O%
:(*Q-'(-1)-1)
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	s)?CB/!C"B22CC
CcdS)z8
        Check the object is sane (non-broken).
        Nrselfs rcheck_sanityzNonGCSimpleBase.check_sanityIrc	|jsQ|jt|||dSdS#t$r%}|j|Yd}~dSd}~wwxYw)z
        PEP 442 finalizer.  Record that this was called, check the
        object is in a sane state, and invoke a side effect.
        N)r/r)appendidr4side_effect	Exceptionr%r3es  r__del__zNonGCSimpleBase.__del__Ns
	">
#%%bhh///!!###  """""
#
#	"	"	"Kq!!!!!!!!!	"AA
B&BBcdS)z6
        A side effect called on destruction.
        Nrr2s rr9zNonGCSimpleBase.side_effect[r5rN)rrr__doc__r#r)r*r%r/	__slots__classmethodr,
contextlibcontextmanagerr0r4r=r9rrrr r s
IIL
FII!![![ 
"""rr ceZdZdZdZdS)
SimpleBasec.t||_dSr")r8id_r2s r__init__zSimpleBase.__init__csd88rcdSr"rr2s rr4zSimpleBase.check_sanityfr5rN)rrrrIr4rrrrFrFas2$$$$$rrFceZdZdZdS)NonGCrN)rrrrArrrrLrLjsIIIrrLceZdZdZdZdS)NonGCResurrectorrc:|j|dSzF
        Resurrect self by storing self in a class-wide list.
        Nr#r7r2s rr9zNonGCResurrector.side_effectr 	
d#####rN)rrrrAr9rrrrNrNns(I$$$$$rrNceZdZdS)SimpleNrrrrrrrTrTxDrrTceZdZdZdS)SimpleResurrectorc:|j|dSrPrQr2s rr9zSimpleResurrector.side_effect~rRrNrrrr9rrrrXrX|s#$$$$$rrXc8eZdZdZdZdZdZdZdZdZ	dS)	TestBasecZtjdd|_gtjdd<dSr")r&r'old_garbager2s rsetUpzTestBase.setUps':aaa=
111


rc	|tjg|`tjdS#|`tjwxYwr")assertEqualr&r'r^r(r2s rtearDownzTestBase.tearDownsM	RZ,,, JLLLLL JLLLLs	 9Acz|ttjt|dSr")rasortedrFr)r3idss  rassert_del_callszTestBase.assert_del_callss/
 455vc{{CCCCCrcz|ttjt|dSr")rardrFr*res  rassert_tp_del_callszTestBase.assert_tp_del_callss/
 788&++FFFFFrc|tdtjDt|dS)Nc34K|]}t|VdSr"r8.0xs  r	<genexpr>z,TestBase.assert_survivors.<locals>.<genexpr>s(DD!1DDDDDDr)rardrFr#res  rassert_survivorszTestBase.assert_survivorss>DDz/CDDDDDfSkkRRRRRrc|tdtjDt|dS)Nc34K|]}t|VdSr"rlrms  rrpz*TestBase.assert_garbage.<locals>.<genexpr>s(::!1::::::r)rardr&r'res  rassert_garbagezTestBase.assert_garbages=::rz:::::F3KKHHHHHrcBtjdSr")rFr#r$r2s rclear_survivorszTestBase.clear_survivorss""$$$$$rN)
rrrr_rbrgrirqrtrvrrrr\r\sDDDGGGSSSIII%%%%%rr\c^eZdZdZdZdZejdZejdZ	dS)SimpleFinalizationTestz.
    Test finalization without refcycles.
    ct5t}t|g}t	j|}~t
j|||	g|
|dt
j|||	gddddS#1swxYwYdSr")rFr0rTr8weakrefrefr&r(rgrqassertIsr3srfwrs    rtest_simplez"SimpleFinalizationTest.test_simples
__

	&	&Aa55'CQBJLLL!!#&&&!!"%%%MM""$$%%%JLLL!!#&&&!!"%%%	&	&	&	&	&	&	&	&	&	&	&	&	&	&	&	&	&	&CC33C7:C7cbt5t}t|g}t	j|}~t
j|||	||
|d|t
j|||	gdddn#1swxYwY||ddSr")
rFr0rXr8rzr{r&r(rgrqassertIsNotrvr|r}s    rtest_simple_resurrectz,SimpleFinalizationTest.test_simple_resurrectsE
__

	&	&!##Aa55'CQBJLLL!!#&&&!!#&&&RRTT4(((  """JLLL!!#&&&!!"%%%	&	&	&	&	&	&	&	&	&	&	&	&	&	&	&	


bbddD!!!!!sC DD

D
ct5t}|t	j|t
|g}~t	j|||	gt	j|||	gddddS#1swxYwYdSr")
rFr0rLassertFalser&
is_trackedr8r(rgrqr3r~rfs   rtest_non_gcz"SimpleFinalizationTest.test_non_gcs
__


	&
	&AR]1--...a55'CJLLL!!#&&&!!"%%%JLLL!!#&&&!!"%%%
	&
	&
	&
	&
	&
	&
	&
	&
	&
	&
	&
	&
	&
	&
	&
	&
	&
	&sCC((C,/C,ct5t}|t	j|t
|g}~t	j|||	||
t	j||dz|	|ddddS#1swxYwYdSN)rFr0rNrr&rr8r(rgrqrvrs   rtest_non_gc_resurrectz,SimpleFinalizationTest.test_non_gc_resurrects+
__

	'	' ""AR]1--...a55'CJLLL!!#&&&!!#&&&  """JLLL!!#'***!!#&&&	'	'	'	'	'	'	'	'	'	'	'	'	'	'	'	'	'	'sCC??DDN)
rrrr@rrrcpython_onlyrrrrrrxrxsz&&&""" 
&&&
'''''rrxc(eZdZfdZfdZxZS)
SelfCycleBasecVt||_dSr")superrIr{r3	__class__s rrIzSelfCycleBase.__init__s$
rcHtdSr")rr4rs rr4zSelfCycleBase.check_sanitys
r)rrrrIr4
__classcell__rs@rrrsQ         rrceZdZdS)SimpleSelfCycleNrUrrrrrrVrrceZdZdS)SelfCycleResurrectorNrUrrrrrrVrrceZdZdZdS)SuicidalSelfCyclecd|_dS)7
        Explicitly break the reference cycle.
        N)r{r2s rr9zSuicidalSelfCycle.side_effectsrNrZrrrrrs#rrc$eZdZdZdZdZdZdS)SelfCycleFinalizationTestzX
    Test finalization of an object having a single cyclic reference to
    itself.
    ct5t}t|g}t	j|}~t
j|||	g|
|dt
j|||	gddddS#1swxYwYdSr")rFr0rr8rzr{r&r(rgrqr|r}s    rrz%SelfCycleFinalizationTest.test_simples
__

	&	&!!Aa55'CQBJLLL!!#&&&!!"%%%MM""$$%%%JLLL!!#&&&!!"%%%	&	&	&	&	&	&	&	&	&	&	&	&	&	&	&	&	&	&rcdt5t}t|g}t	j|}~t
j|||	||
|d|t
j|||	g|
|dddddS#1swxYwYdSr")rFr0rr8rzr{r&r(rgrqr|rvr}s    rrz/SelfCycleFinalizationTest.test_simple_resurrectsL
__

	&	&$&&Aa55'CQBJLLL!!#&&&!!#&&&MM""$$%%%
  """JLLL!!#&&&!!"%%%MM""$$%%%!	&	&	&	&	&	&	&	&	&	&	&	&	&	&	&	&	&	&sC>D%%D),D)c<t5t}t|g}t	j|}~t
j|||	g|
|dt
j|||	g|
|dddddS#1swxYwYdSr")rFr0rr8rzr{r&r(rgrqr|r}s    rtest_simple_suicidez-SelfCycleFinalizationTest.test_simple_suicide%s:__

	&	&!##Aa55'CQBJLLL!!#&&&!!"%%%MM""$$%%%JLLL!!#&&&!!"%%%MM""$$%%%	&	&	&	&	&	&	&	&	&	&	&	&	&	&	&	&	&	&sC*DDDN)rrrr@rrrrrrrrsK
&&&&&&(&&&&&rrc$eZdZdZfdZxZS)ChainedBasec0d|_||_||_dS)NFsuicidedleftright)r3rs  rchainzChainedBase.chain9s
	


rct|jrdS|j}|jr	|j}|jrdSdSr")rr4rrr)r3rrrs   rr4zChainedBase.check_sanity>sl
=
	*
	*
	*9D}
*
*JE~
*
*
*
*
*r)rrrrr4rrs@rrr7sG
*********rrceZdZdS)
SimpleChainedNrUrrrrrOrVrrceZdZdS)ChainedResurrectorNrUrrrrrRrVrrceZdZdZdS)SuicidalChainedc0d|_d|_d|_dS)rTNrr2s rr9zSuicidalChained.side_effectWs
	


rNrZrrrrrUs#rrcTeZdZdZdZdZdZdZdZdZ	dZ
d	Zd
ZdZ
dZd
S)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.
    cd|D}tt|D]&}||||dz
'|S)Nc"g|]}|
Srr)rnrs  r
<listcomp>z:CycleChainFinalizationTest.build_chain.<locals>.<listcomp>hs***3***r)rangelenr)r3classesnodesis    rbuild_chainz&CycleChainFinalizationTest.build_chaingsX**'***s5zz""	'	'A!HNN51:&&&&rct|}t5||}d|D}d|D}~t	j|||g|d|Ddg|zt	j||ddddS#1swxYwYdS)Nc,g|]}t|Srrlrnr~s  rrzKCycleChainFinalizationTest.check_non_resurrecting_chain.<locals>.<listcomp>q(((Q2a55(((rc6g|]}tj|Srrzr{rs  rrzKCycleChainFinalizationTest.check_non_resurrecting_chain.<locals>.<listcomp>r 111a7;q>>111rc"g|]}|
Srrrnrs  rrzKCycleChainFinalizationTest.check_non_resurrecting_chain.<locals>.<listcomp>w111rbbdd111r)	rrFr0rr&r(rgrqra)r3rNrrfwrss      rcheck_non_resurrecting_chainz7CycleChainFinalizationTest.check_non_resurrecting_chainms:LL
__


	'
	'$$W--E((%(((C115111CJLLL!!#&&&!!"%%%11S111D6A:>>>JLLL!!#&&&
	'
	'
	'
	'
	'
	'
	'
	'
	'
	'
	'
	'
	'
	'
	'
	'
	'
	'sB8C..C25C2c~t|}t5||}t|}d|D}d|D}d|D}~t	j|||||d|Ddg|z|	t	j|||gddddS#1swxYwYdS)Nc,g|]}t|Srrlrs  rrzGCycleChainFinalizationTest.check_resurrecting_chain.<locals>.<listcomp>rrcVg|]&}t|tt|'Sr)
isinstancerXr8rs  rrzGCycleChainFinalizationTest.check_resurrecting_chain.<locals>.<listcomp>s.UUUaJqBS4T4TUBqEEUUUrc6g|]}tj|Srrrs  rrzGCycleChainFinalizationTest.check_resurrecting_chain.<locals>.<listcomp>rrc"g|]}|
Srrrs  rrzGCycleChainFinalizationTest.check_resurrecting_chain.<locals>.<listcomp>rr)
rrFr0rr&r(rgrqrarv)r3rrrrfsurvivor_idsrs       rcheck_resurrecting_chainz3CycleChainFinalizationTest.check_resurrecting_chain{s~LL
__

	&	&$$W--EE

A((%(((CUU5UUUL115111CJLLL!!#&&&!!,///11S111D6A:>>>  """JLLL!!#&&&!!"%%%	&	&	&	&	&	&	&	&	&	&	&	&	&	&	&	&	&	&sC<D22D69D6cB|tgdzdSN)rrr2s rtest_homogenousz*CycleChainFinalizationTest.test_homogenouss#))=/A*=>>>>>rcB|tgdzdSr)rrr2s rtest_homogenous_resurrectz4CycleChainFinalizationTest.test_homogenous_resurrects%%%'9&:Q&>?????rcB|tgdzdSr)rrr2s rtest_homogenous_suicidalz3CycleChainFinalizationTest.test_homogenous_suicidals$))?*;a*?@@@@@rcN|ttgdzdSrrrrr2s rtest_heterogenous_suicidal_onez9CycleChainFinalizationTest.test_heterogenous_suicidal_ones&))?M*JQ*NOOOOOrcZ|tgdztgdzzdSrrr2s rtest_heterogenous_suicidal_twoz9CycleChainFinalizationTest.test_heterogenous_suicidal_twos;))
!]Oa$77	9	9	9	9	9rcN|ttgdzdSr)rrrr2s rtest_heterogenous_resurrect_onez:CycleChainFinalizationTest.test_heterogenous_resurrect_ones'%%'9=&IA&MNNNNNrcZ|tttgdzdSrrrrrr2s rtest_heterogenous_resurrect_twoz:CycleChainFinalizationTest.test_heterogenous_resurrect_twos8%%
@1D	F	F	F	F	Frcr|tgdztgdzztgdzzdSrrr2s r!test_heterogenous_resurrect_threez<CycleChainFinalizationTest.test_heterogenous_resurrect_threesN%%
 1$
'::o=NQR=RR	T	T	T	T	TrN)rrrr@rrrrrrrrrrrrrrrr`s'''&&&&???@@@AAAPPP999OOOFFFTTTTTrrceZdZdZdZdS)
LegacyBasec	|js=|jt||dSdS#t
$r%}|j|Yd}~dSd}~wwxYwr")r/r)r7r8r4r:r%r;s  rr=zLegacyBase.__del__s	">
$%%bhh///!!#####
$
$	"	"	"Kq!!!!!!!!!	"sAA
A7A22A7c	|jsQ|jt|||dSdS#t$r%}|j|Yd}~dSd}~wwxYw)zJ
        Legacy (pre-PEP 442) finalizer, mapped to a tp_del slot.
        N)r/r*r7r8r4r9r:r%r;s  r
__tp_del__zLegacyBase.__tp_del__s	">
#!((D222!!###  """""
#
#	"	"	"Kq!!!!!!!!!	"r>N)rrrr=rrrrrrs2"""
"
"
"
"
"rrceZdZdS)LegacyNrUrrrrrDrrceZdZdZdS)LegacyResurrectorc:|j|dSrPrQr2s rr9zLegacyResurrector.side_effectrRrNrZrrrrrs#$$$$$rrceZdZdS)LegacySelfCycleNrUrrrrrrrrc4eZdZdZfdZdZdZdZxZS)LegacyFinalizationTestz5
    Test finalization of objects with a tp_del.
    ctjtjt	dSr")r&r'r$r(rrbrs rrbzLegacyFinalizationTest.tearDowns@	



rc*t5t}t|g}t	j|}~t
j|||	||
g||dt
j|||	|ddddS#1swxYwYdSr")rFr0rr8rzr{r&r(rgrirqr|r}s    rtest_legacyz"LegacyFinalizationTest.test_legacys0
__

	*	*Aa55'CQBJLLL!!#&&&$$S)))!!"%%%MM""$$%%%JLLL!!#&&&$$S)))	*	*	*	*	*	*	*	*	*	*	*	*	*	*	*	*	*	*sC!DDDct5t}t|g}t	j|}~t
j|||	||
|||d|t
j|||	|dz|
|dddn#1swxYwY||ddSr)
rFr0rr8rzr{r&r(rgrirqr|rvr}s    rtest_legacy_resurrectz,LegacyFinalizationTest.test_legacy_resurrectso
__

	'	'!##Aa55'CQBJLLL!!#&&&$$S)))!!#&&&MM""$$%%%  """JLLL!!#&&&$$S1W---!!#&&&	'	'	'	'	'	'	'	'	'	'	'	'	'	'	' 	


bbddD!!!!!sD
D33D7:D7clt5t}t|g}t	j|}~t
j|g|	g|
g||||ddtj
d_dddn#1swxYwY|g||ddS)Nr)rFr0rr8rzr{r&r(rgrirqrtrr'r|r}s    rtest_legacy_self_cyclez-LegacyFinalizationTest.test_legacy_self_cyclesJ
__

	%	%!!Aa55'CQBJLLL!!"%%%$$R(((!!"%%%$$$RRTT4((( $BJqM	%	%	%	%	%	%	%	%	%	%	%	%	%	%	%	
B

bbddD!!!!!sCC66C:=C:)	rrrr@rbrrrrrs@rrrso
*
*
*"""&"""""""rr__main__)&r@rCr&unittestrz	_testcapirImportErrorrr0rr rFrLrNrTrXr\TestCaserxrrrrrrrrrrrrrrrrrmainrrr<module>rsQ				%%%%%%%$$$$$$$????????D$$$$$$$$O$$$$$$$$					Z			$$$$$
$$$%%%%%%%%<>'>'>'>'>'Xx'8>'>'>'B        					mV								=*;			
v7&7&7&7&7&(*;7&7&7&t********0					K								&7			k6GTGTGTGTGT8+<GTGTGTZ""""""""0
					Z		
	
$$$$$
$$
$
					mZ		
		>">">">">"Xx'8>">">"BzHMOOOOOs&&1<<