python (3.12.0)

(root)/
lib/
python3.12/
test/
__pycache__/
test_frame.cpython-312.pyc

Αe18ddlZddlZddlZddlZddlZddlZddlZddlZddlZ	ddl	Z	ddlmZddl
mZddlmZGddej"ZGddej"ZGd	d
ej"ZGddej"Zej,e	dud
Gddej"Zedk(rej2yy#e
$rdZ	YwxYw)N)support)threading_helper)assert_python_okcleZdZdZd
dZdZdZdZdZdZ	dZ
d	Zd
Ze
jdZy)	ClearTestz"
    Tests for frame.clear().
    cddzyNr)selfxkwargss   C/BuggyBox/python/3.12.0/bootstrap/lib/python3.12/test/test_frame.pyinnerzClearTest.inners		!c^	|jdi|S#t$r
}|}Yd}~|Sd}~wwxYw)Nr)rZeroDivisionError)rreexcs    routerzClearTest.outers;	DJJ  
!	C
	s	,',c\|*|jj|j}|)yy)z2
        Clear all frames in a traceback.
        N)tb_framecleartb_next)rtbs  rclear_traceback_framesz ClearTest.clear_traceback_frames#s)nKKBnrcXGdd}|}tj|}|j|}~tj|jd||j
|jtj|jd|y)NceZdZy)&ClearTest.test_clear_locals.<locals>.CN__name__
__module____qualname__rrrCr,rr$c)	weakrefrefrr
gc_collectassertIsNotr
__traceback__assertIsrr$r'wrrs     rtest_clear_localszClearTest.test_clear_locals+s		
C
[[^jj1jo
rt$##C$5$56

dBD!rcxGdd}|}|j|}~|jj}|j|j	|j
d|j	|jd|j	|jd|j	|jdy)NceZdZy)7ClearTest.test_clear_does_not_clear_specials.<locals>.CNr rrrr$r3;r%rr$r&)	rr,rrr+f_codef_locals
f_builtins	f_globals)rr$r'rfs     r"test_clear_does_not_clear_specialsz,ClearTest.test_clear_does_not_clear_specials:s		
Cjj1jo
&&		4(T*t,d+rcdfd}|}t|j|jjj	y)NFc3JK	djdy#dwxYww)NT)r)endlyrsrgz)ClearTest.test_clear_generator.<locals>.gIs"


s## #)nextassertFalsegi_framer
assertTrue)rr=genr<s`  @rtest_clear_generatorzClearTest.test_clear_generatorGsG	cS	rcd	ddz|jt5jddd|jt5jjdddy#t$r }|jj}Yd}~d}~wwxYw#1swYnxYw#1swYyxYwr	rr,rassertRaisesRuntimeErrorrf_back)rrr8s   rtest_clear_executingzClearTest.test_clear_executingWs	)
aC

|
,	
GGI	


|
,	
HHNN			!	)((A	)				s.A.B
B&.	B7BBB#&B/cdfd}|}t|}j|jjy)NFc3K	ddzdy#t$r}|jj}jt5|jdddn#1swYnxYwjt5|jjdddn#1swYnxYw|Yd}~dyd}~wwxYw#dwxYww)Nr
rTrE)rr8r<rs  rr=z3ClearTest.test_clear_executing_generator.<locals>.ges

!%
OO,,&&|4GGI&&|4%HHNN$%%%
slC
C	B<+B7A	B7A$	 B7<B 	B7 B)	%B70B?4C7B<<B??CC)r>r?rrA)rr=rBr8r<s`   @rtest_clear_executing_generatorz(ClearTest.test_clear_executing_generatorbsB	cI		rcfdfd}gd}g|d|j|g|d|j|y)Nctjd}j|j|jj
z
y)Nr
)sys	_getframeappendf_linenor4co_firstlineno)r8liness rrecord_linez7ClearTest.test_lineno_with_tracing.<locals>.record_linezs0

a ALLAHH$;$;;<rch|rdtjd_y)NTr)rOrPf_trace)tracerUs rtestz0ClearTest.test_lineno_with_tracing.<locals>.test~s&M+/

a (MMr)r
FT)assertEqual)rrYexpected_linesrTrUs   @@rtest_lineno_with_tracingz"ClearTest.test_lineno_with_tracingysL	=	#U/T
/rcZtj5Gdd}|}tj|}|j	|}~|jd||j
|j|jd|dddy#1swYyxYw)NceZdZy))ClearTest.test_clear_refcycles.<locals>.CNr rrrr$rasrr$r&)	r
disable_gcr(r)rr+rr,r-r.s     rtest_clear_refcycleszClearTest.test_clear_refcycless


!		&

AQB**q*/CT24(''(9(9:MM$%		&		&		&sBB!!B*N)r[)r!r"r#__doc__rrrr0r9rCrIrLr^rcpython_onlyrcrrrrrsN
", 	.0(
&&rrc*eZdZdZdZdZdZdZy)FrameAttrsTestcd}	|S#t$rE}|j}g}|r*|j|j|j}|r*Yd}~|Sd}~wwxYw)Nc$dd}fd}|S)Nr[cdz}ddzd}yNr
r	rztr
s  rrz8FrameAttrsTest.make_frames.<locals>.outer.<locals>.innerE!rryrr
s  @rrz)FrameAttrsTest.make_frames.<locals>.outerAA
7Nr)rr,rQrr)rrrrframess     rmake_frameszFrameAttrsTest.make_framessa		 G

!	 BF

bkk*ZZ

	 s	A9AAc|j\}}}|j}|j|jdtj
|j
|ddd|j}|j
|dddy)Nrr[rj)r
rt)r
rp)rwr5assertIsInstancepoptypesFunctionTyper\)rr8rrouter_localsinner_localss      rtest_localszFrameAttrsTest.test_localsss**,5%~~l..w79K9KLQQ'78~~QQ'78rc|j\}}}|j|j|j|ji|j|jiyN)rwrr\r5rr8rrs    rr0z FrameAttrsTest.test_clear_localssP**,5%



,,rc|j\}}}|j|j|j|j|j|ji|j|jiyr)rwr5rr\rs    rtest_locals_clear_localsz'FrameAttrsTest.test_locals_clear_localss^**,5%





,,rc|j\}}}|jt5|`dddy#1swYyxYwr)rwrFAttributeErrorrR)rr8_s   rtest_f_lineno_del_segfaultz)FrameAttrsTest.test_f_lineno_del_segfaults>""$1a


~
.	
			s6?N)r!r"r#rwrr0rrrrrrgrgs&9--rrgceZdZdZdZy)ReprTestz 
    Tests for repr(frame).
    c*d}|jj}	||jd\}}}tjtt}	|jt|d|	|dzfz|jt|d|	|dzfz|jt|d|	|dzfzy#t$rD}|j}g}|r*|j|j|j}|r*Yd}~d}~wwxYw)	Nc$dd}fd}|S)Nr[rjcdz}ddzd}yrlrros  rrz0ReprTest.test_repr.<locals>.outer.<locals>.innerrrrrrss  @rrz!ReprTest.test_repr.<locals>.outerrurzshould have raisedz=^<frame at 0x[0-9a-fA-F]+, file %s, line %d, code test_repr>$z9^<frame at 0x[0-9a-fA-F]+, file %s, line %d, code outer>$ryz9^<frame at 0x[0-9a-fA-F]+, file %s, line %d, code inner>$r[)
__code__rSfailrr,rQrrreescaperepr__file__assertRegex)
rroffsetrrrvf_thisf_outerf_inner	file_reprs
          r	test_reprzReprTest.test_reprs
	..		,G
II*+#) IId8n-	fY%v{34	5	
gU%vz23	4	
gU%vz23	4#!	 BF

bkk*ZZ	 sC	D9D

DN)r!r"r#rdrrrrrrs 4rrceZdZdZej
dZej
ejdZ	dZ
y)TestIncompleteFrameAreInvisiblecVtjdtd}td|y)Nz
            import gc

            gc.set_threshold(1,1,1)
            class GCHello:
                def __del__(self):
                    print("Destroyed from gc")

            def gen():
                yield

            fd = open(zy)
            l = [fd, GCHello()]
            l.append(l)
            del fd
            del l
            gen()
        z-c)textwrapdedentrr)rcodes  rtest_issue95818z/TestIncompleteFrameAreInvisible.test_issue95818s2$ l#	 
$	t$rc	d}	fdd}tj}tjdd}tj}t	j
}	tj|}t|tjtjdddt	j|tjjd	tjt||j|j	tj||tjddt	j||rtjyy#tj||tjddt	j||rtjwwxYw)Ncy)z^
            Don't actually do anything, just force a frame object to be created.
            Nr)frameeventargs   rrXzGTestIncompleteFrameAreInvisible.test_sneaky_frame_object.<locals>.tracesrctjjjtjjy)z
            Yo dawg, I heard you like frames, so I'm allocating a frame while
            you're allocating a frame, so you can have a frame while you have a
            frame!
            N)rOrPrHgc	callbacksremove)phaseinfocallbacksneaky_frame_objects  rrzJTestIncompleteFrameAreInvisible.test_sneaky_frame_object.<locals>.callbacks/#&--/"8"8"?"?LL)rc3K	dwrrrrrr8zCTestIncompleteFrameAreInvisible.test_sneaky_frame_object.<locals>.f#ss	r
r)r
get_thresholdr	isenabledrOgettracedisabler>collect
set_thresholdsettracerQenabler-r@)
rrXr8
old_threshold
old_callbacksold_enabled	old_tracer=rrs
        @@rtest_sneaky_frame_objectz8TestIncompleteFrameAreInvisible.test_sneaky_frame_objects=	
		*	((*
Q
llnLLN	"	JJLAG
JJLQ1%
LLLL)"&IIKG
MM!**&9:m,+BLLOLL#		
m,+BLLOLL#		sCE33AGcNGfddGfddtj}d|}|j|j|j	@|jj|jjj?yy)NceZdZfdZy)TTestIncompleteFrameAreInvisible.test_sneaky_frame_object_teardown.<locals>.SneakyDelc.tjy)a@
                Stash a reference to the entire stack for walking later.

                It may look crazy, but you'd be surprised how common this is
                when using a test runner (like pytest). The typical recipe is:
                ResourceWarning + -Werror + a custom sys.unraisablehook.
                NrOrP)rrs r__del__z\TestIncompleteFrameAreInvisible.test_sneaky_frame_object_teardown.<locals>.SneakyDel.__del__Ts'*mmo#rN)r!r"r#r)rsr	SneakyDelrSs	
6rrceZdZdZfdZy)WTestIncompleteFrameAreInvisible.test_sneaky_frame_object_teardown.<locals>.SneakyThreadz
            A separate thread isn't needed to make this code crash, but it does
            make crashes more consistent, since it means sneaky_frame_object is
            backed by freed memory after the thread completes!
            c}y)z.Run SneakyDel.__del__ as this frame is popped.Nr)rr)rs  rrunz[TestIncompleteFrameAreInvisible.test_sneaky_frame_object_teardown.<locals>.SneakyThread.runfs
krN)r!r"r#rdr)rsrSneakyThreadr_s


"rr)
	threadingThreadstartjoinassertIsNotNoner+r4rrrH)rrrqrrs   @@r!test_sneaky_frame_object_teardownzATestIncompleteFrameAreInvisible.test_sneaky_frame_object_teardownOs
	6
	6		"9++		"#N				
01!-#**L,<,<,E,E
#6"<"<	"-rc Gddfd}tj5}tj|}|j	|j
jtddd|jy#1swY xYw)NceZdZdZy)ZTestIncompleteFrameAreInvisible.test_entry_frames_are_invisible_during_teardown.<locals>.CzA weakref'able class.N)r!r"r#rdrrrr$rys'rr$cF}tj|tS)z>Try to find globals and locals as this frame is being cleared.)r(r)exec)r)r$s rr8zZTestIncompleteFrameAreInvisible.test_entry_frames_are_invisible_during_teardown.<locals>.f|s#C
;;sD))r)	rcatch_unraisable_exceptionoperatorcallr-
unraisableexc_type	TypeErrorassertIsNone)rr8catcherweakr$s    @r/test_entry_frames_are_invisible_during_teardownzOTestIncompleteFrameAreInvisible.test_entry_frames_are_invisible_during_teardownxsu	(	(	*
/
/
1	BW==#DMM',,55yA		B
	
$&!	B	BsABB
N)r!r"r#rrrerrrequires_working_threadingrrrrrrrsV%,
<<|
0002%=3%=N"rrzneed _testcapic0eZdZdZdZdZdZdZdZy)TestCAPIc*tjSrrrs rgetframezTestCAPI.getframes}}rc|j}|j|jtj||j|jtj||j|jtj||j|jtj|yr)rr\r5	_testcapiframe_getlocalsr-r7frame_getglobalsr6frame_getbuiltinsf_lastiframe_getlasti)rrs  rtest_frame_getterszTestCAPI.test_frame_getterss

)B)B5)IJ

eooy'A'A%'HI

e&&	(C(CE(JK	(@(@(GHrctj}d}|jtj|dd|jtj
|dd|j
t5tj|dddd|j
t5tj
|dddd|j
t5tj|dddd|j
t5tj|ddddy#1swYxYw#1swY~xYw#1swYVxYw#1swYyxYw)Nr
r
xrty{)	rOrPr\rframe_getvarframe_getvarstringrF	NameErrorr)r
current_framer
s   rtest_getvarzTestCAPI.test_getvars



//
sCQG55mTJAN


y
)	7""=#6	7


y
)	>((=	>

y
)	8""=$7	8


y
)	7""=#6	7	7	7	7	>	>	8	8	7	7s08D4,E EE4D=E	EE!c#8Ktjywrrrs rgetgenframezTestCAPI.getgenframesmmosc|j}t|}|j|tj|yr)rr>r-rframe_getgenerator)rrBrs   rtest_frame_get_generatorz!TestCAPI.test_frame_get_generators2 S	

c977>?rcd}tj|jtt	}|j|jy)zzTest that accessing `f_back` does not cause a segmentation fault on
        a frame created with `PyFrame_New` (GH-99110).cyrrrrrdummyz,TestCAPI.test_frame_fback_api.<locals>.dummysrN)r	frame_newrglobalslocalsrrH)rrrs   rtest_frame_fback_apizTestCAPI.test_frame_fback_apis7	##ENNGIvxH%,,'rN)	r!r"r#rrrrrrrrrrrs"I7 @
(rr__main__)rrrrOrrr|unittestr(rImportErrorrYrtest.supportrtest.support.script_helperrTestCaserrgrrskipIfrr!mainrrr<module>rs		
)7E&!!E&P2X&&2j%4x  %4NR"h&7&7R"hd"$45+(x  +(6+(ZzHMMO]
IsCCC