+
    '(j?                        ^ RI t ^ RIt^ RIt^ RIt^ RIt^ RIHt ^ RIHt ^ RIt^ RIHt	 ^RI
Ht ^RI
Ht ^RI
Ht ^RI
Ht ^R	I
Ht ^R
IHt ^RIHt  ! R R]4      tR tR t ! R R]4      t ! R R]4      t ! R R]4      t ! R R]4      t ! R R]4      t ! R R]4      t]R8X  d   ]P<                  ! 4        R# R# )    N)ABCMeta)abstractmethod)greenlet)TestCase)RUNNING_ON_MANYLINUX)PY313)PY314)RUNNING_ON_FREETHREAD_BUILD)fails_leakcheck)ignores_leakcheckc                       ] tR t^tRtR# )	SomeError N__name__
__module____qualname____firstlineno____static_attributes__r       Q/home/ubuntu/cf-venv/lib/python3.14/site-packages/greenlet/tests/test_greenlet.pyr   r      s    r   r   c                      \         P                  ! 4       P                  P                  4        \        h   T P	                  \
        P                  ! 4       ^ ,          4       h ; ir   )r   
getcurrentparentswitchappendsysexc_infor   seens   &r   fmainr"   #   sJ    $$++- OCLLN1%&s	   -5 .A#c                 F    R  p\        W R7      pVP                  V4       R# )c                     V hNr   )excs   &r   crashersend_exception.<locals>.crasher/   s    	r   r   NRawGreenletr   )gr&   r'   g1s   &&  r   send_exceptionr.   ,   s    	W	'BIIcNr   c                     a  ] tR t^5t o R tR tR tR tR tR t	R t
R tR	 t]R
 4       tR tR tR tR t]P(                  ! ];'       d    ]R4      R 4       tR tR tR tR tR tR tR tR tR t R t!R t"R t#]$R2R l4       t%]$R 4       t&R t']$R  4       t(R! t)R" t*R# t+R$ t,R% t-R& t.]P(                  ! ];'       d    ]R'4      R( 4       t/R) t0R* t1R+ t2R, t3R- t4R. t5R/ t6R0t7V t8R1# )3TestGreenletc                  a . oV3R  lp\        V4      pSP                  ^ 4       VP                  4        SP                  ^4       VP                  4        SP                  ^4       V P                  S\	        \        ^4      4      4       R# )c                     < S P                  ^4       \        P                  ! 4       P                  P	                  4        S P                  ^4       R#    Nr   r   r   r   r   lsts   r   f'TestGreenlet._do_simple_test.<locals>.f:   s4    JJqM!((//1JJqMr   N)r+   r   r   assertEquallistrange)selfr8   r,   r7   s   &  @r   _do_simple_testTestGreenlet._do_simple_test7   sc    	 N

1	


1	


1d58n-r   c                &    V P                  4        R # r%   )r>   r=   s   &r   test_simpleTestGreenlet.test_simpleF   s    r   c                    \        4       pV P                  \        4      ;_uu_ 4       pVP                  4        R R R 4       V P	                  R\        XP                  4      4       R #   + '       g   i     L7; iNrun)r+   assertRaisesAttributeErrorr   assertInstr	exceptionr=   r,   r&   s   &  r   (test_switch_no_run_raises_AttributeError5TestGreenlet.test_switch_no_run_raises_AttributeErrorI   sL    M~..#HHJ / 	eS/0 /.s   A((A8	c                    \        4       pV P                  \        4      ;_uu_ 4       pVP                  \        4       R R R 4       V P                  R\        XP                  4      4       R #   + '       g   i     L7; irE   )r+   rG   rH   throwr   rI   rJ   rK   rL   s   &  r   'test_throw_no_run_raises_AttributeError4TestGreenlet.test_throw_no_run_raises_AttributeErrorP   sO    M~..#GGI / 	eS/0 /.s   A--A=	c                    \        R R7      pV P                  V4       V P                  VP                  \        P
                  ! 4       4       R # )Nr)   )r+   assertIsNotNoneassertIsr   r   r   r=   r,   s   & r   test_parent_equals_None$TestGreenlet.test_parent_equals_NoneW   s5    t$Qahh 3 3 56r   c                v    \        R R7      pV P                  V4       V P                  VP                  4       R # )NrF   )r+   rT   assertIsNonerF   rV   s   & r   test_run_equals_None!TestGreenlet.test_run_equals_None\   s,    D!Q!%% r   c                  a . oV3R  lp\        V4      p\        V4      pVP                  4        V P                  \        S4      ^4       VP                  4        V P                  \        S4      ^4       VP                  4        V P                  \        S4      ^4       V P                  VP                  R4       VP                  4        V P                  \        S4      ^4       V P                  VP                  R4       R# )c                     < S P                  ^4       \        P                  ! 4       P                  P	                  4        S P                  ^^.4       R# r3   )r   r   r   r   r   extendr6   s   r   r8   )TestGreenlet.test_two_children.<locals>.fd   s9    JJqM!((//1JJ1vr   TN)r+   r   r:   lendead)r=   r8   r,   hr7   s   &   @r   test_two_childrenTestGreenlet.test_two_childrena   s    	 NN	
S1%	
S1%	
S1%&	
S1%&r   c                  aa . oV3R  loVV3R lpT P                  \        P                  ! V4      \        '       g   ^M^4       \	        V4      pT P                  \        P                  ! V4      \        '       g   ^M^4       VP                  4        V P                  S. RO4       T P                  \        P                  ! V4      \        '       g	   ^4       R# ^4       R# )c                     < S P                  R 4       \        P                  ! 4       P                  P	                  4        R# )bNr5   r6   s   r   r8   3TestGreenlet.test_two_recursive_children.<locals>.fx   s)    JJsO!((//1r   c                     < SP                  R 4       \        S4      p V P                  4        SP                  R4       R# )acN)r   r+   r   )r,   r8   r7   s    r   r,   3TestGreenlet.test_two_recursive_children.<locals>.g|   s+    JJsOAAHHJJJsOr   N)rl   ri   rm   )r:   r   getrefcountr	   r+   r   )r=   r,   r8   r7   s   & @@r   test_two_recursive_children(TestGreenlet.test_two_recursive_childrenu   s    	2	
 	+eeQCN 	+eeQC	
o.+eeQCCr   c                2  a a . oV V3R  lp\        ^
4       Uu. uF  p\        P                  ! VR7      NK  	  ppV F  pVP                  4        K  	  V F  pVP	                  ^
4       K  	  S P                  \        S4      \        V4      4       R# u upi )c                  J   < S P                  4        SP                  R 4       R# TN)r>   r   )r=   successs   r   r8   $TestGreenlet.test_threads.<locals>.f   s      "NN4 r   targetN)r<   	threadingThreadstartjoinr:   rb   )r=   r8   ithsthru   s   f    @r   test_threadsTestGreenlet.test_threads   sw    	! 499=9ayq)9=BHHJ BGGBK Ws3x0 >s    Bc                   aa R  oR oRVV3R llp\        ^4       F  pV! 4        \        P                  ! 4        K!  	  R# )c                     R  p\         P                   ! V4      pVP                  4        V P                  V4       VP                  4        R# )c                  b     \         P                  ! 4       P                  P                  4        K0  Tr   r   r   r   r   r   r   bodyPTestGreenlet.test_switching_many_threads.<locals>.creates_greenlet.<locals>.body   s     '')00779r   N)r   r   r   wait)	greenletswait_to_die_untilr   r,   s   &&  r   creates_greenletBTestGreenlet.test_switching_many_threads.<locals>.creates_greenlet   s<    : !!$'AHHJQ""$r   c                     VP                  4        VP                  4       '       g:   \        V 4       F(  p VP                  '       g   VP	                  4        K(  K*  	  KO  R #   \
        P                   d     KH  i ; ir%   )r   is_setr;   rc   r   r   error)r   wait_to_check_until
quit_afterr,   s   &&& r   switches_from_other_threadLTestGreenlet.test_switching_many_threads.<locals>.switches_from_other_thread   sf    $$& ''))iA vvvHHJ  & ) *
 $>>  s   "A""A;:A;c           	      r  < . p\         P                  ! 4       p\         P                  ! 4       p\        V 4       Uu. uF  p\         P                  ! SVV3R 7      NK  	  pp\        V 4       Uu. uF  p\         P                  ! S	WV3R 7      NK  	  ppWV,            F  pVP	                  4        K  	  \        V4      V 8  d   \        P                  ! R4       K(  VP                  4        V F  pVP                  R4       K  	  VP                  4        V F  pVP                  R4       K  	  R# u upi u upi )rx   argsg-C6?g      ?N)
ry   Eventr<   rz   r{   rb   timesleepsetr|   )
thread_countr   greenlets_all_createdall_threads_dead_creators	switcherstr   r   s
   &       r   run_it8TestGreenlet.test_switching_many_threads.<locals>.run_it   s3   I$-OO$5!(0 &	 '    (8	@U@W X '	   &
 '    (B'0'7'9: '   **	 + i.</

6"!%%'s   "s 5s   #D/-#D4N)   )r<   gccollect)r=   r   r   r   r   s   &  @@r   test_switching_many_threads(TestGreenlet.test_switching_many_threads   s6    	%
	 	  	H rAHJJL r   c                   . p\        \        4      p\        \        4      pVP                  V4       VP                  V4       W#n        V P	                  V. 4       V P                  \        VP                  4       V P	                  V\        .4       VP                  4       pV P	                  VR4       V P	                  V\        .4       VP                  ^4      pV P	                  V^4       V P	                  V\        .4       R# )   Nr   )r+   r"   r   r   r:   rG   r   )r=   r!   r-   g2values   &    r   test_exceptionTestGreenlet.test_exception   s    
		$
		$	r" 	)RYY/	{+		#	{+		"#	{+r   c                    . p\        \        4      pVP                  V4       V P                  \        \
        V\        4       V P                  V\        .4       R # r%   )r+   r"   r   rG   KeyErrorr.   r:   )r=   r!   r-   s   &  r   test_send_exception TestGreenlet.test_send_exception   sB    
		$(NBAz*r   c                   . p\        \        4      p\        \        4      pVP                  V4       VP                  V4       V P                  V. 4       ?\        P
                  ! 4        V P                  V\        P                  .4       ?\        P
                  ! 4        V P                  V\        P                  \        P                  .4       R # r%   )r+   r"   r   r:   r   r   r   GreenletExit)r=   r!   r-   r   s   &   r   test_deallocTestGreenlet.test_dealloc   s    
		$
		$r"


 5 567


 5 5x7L7LMNr   c                H  a R  p\        V4      pVP                  4        . o\        P                  pV3R lpV\        n         ?V\        n        V P	                  \        S4      ^4       V P                  S^ ,          P                  \        4       R#   T\        n        i ; i)c                       \         P                  ! 4       P                  P                  4        R #   \         P                   d	    \
        R hi ; ir%   )r   r   r   r   r   r   r   r   r   rF   HTestGreenlet.test_dealloc_catches_GreenletExit_throws_other.<locals>.run
  s?    *##%,,335(( *T)*s	   -1 Ac                 *   < SP                  V 4       R # r%   r   )
unraisableunraisable_eventss   &r   _captureMTestGreenlet.test_dealloc_catches_GreenletExit_throws_other.<locals>._capture  s    $$Z0r   N)	r+   r   r   unraisablehookr:   rb   assertIsInstance	exc_valuer   )r=   rF   r,   old_hookr   r   s   &    @r   .test_dealloc_catches_GreenletExit_throws_other;TestGreenlet.test_dealloc_catches_GreenletExit_throws_other	  s    	* 	
%%	1%	*!)C./3/2<<iH "*Cs   B B!z=Sometimes flaky (getting one GreenletExit in the second list)c                :  aaaaaa . o. o\         P                  ! 4       o\         P                  ! 4       o\         P                  ! 4       o\         P                  ! 4       oVVVVVV3R  lp\         P                  ! VR7      pVP                  4        SP	                  ^
4       V P                  S. 4       V P                  \        S4      ^4       SR \        '       g   \        P                  ! 4        V P                  S. 4       SP                  4        SP	                  ^4        V P                  S\        P                  .4       SP                  4        VP                  ^
4       SR SR R#   SP                  4        TP                  ^
4       SR SR i ; i)c                  B  < \        \        4      p V P                  S4       SP                  V 4       ? \        P
                  ! 4        SP                  4        SP                  ^4       \        4        SP                  4        SP                  ^4       \        4        R# )   N)r+   r"   r   r   r   r   r   r   )r-   /bg_glet_created_running_and_no_longer_ref_in_bgbg_should_be_clearfg_ref_releasedok_to_exit_bg_threadr!   somerefs    r   r8   1TestGreenlet.test_dealloc_other_thread.<locals>.f1  sn    U#BIIdONN2JJL;??A  #M""$ %%a(Mr   rw   NNNN)ry   r   rz   r{   r   r:   rb   r
   r   r   r   r   r   r|   )	r=   r8   r   r   r   r   r   r!   r   s	   &  @@@@@@r   test_dealloc_other_thread&TestGreenlet.test_dealloc_other_thread!  sI    :C//:K7#//+&__.(0	 	 A&		7<<R@r"Wq)AJ** JJL 	r""	TH$9$9#:; $$&FF2JQ
 !$$&FF2JQ
s   '!E1 1)Fc                B  a  V 3R  lp\        V4      pVP                  4       pS P                  W2P                  J 4       S P                  V4       VP                  4       pS P	                  V4       S P                  VR4       S P                  VP                  R4       R# )c                     < \         P                  ! ^ 4      p SP                  V P                  R4       \        P
                  ! 4       P                  P                  V 4       R# )r   Nmeaning of life)r   	_getframer:   f_backr   r   r   r   )r8   r=   s    r   f1#TestGreenlet.test_frame.<locals>.f1`  sE    a AQXXt,!((//2$r   r   N)r+   r   
assertTruegr_frameassertFalser:   )r=   r   r,   framefrom_gs   f    r   
test_frameTestGreenlet.test_frame_  s{    	%
 O
+,!23T*r   c                    R  p\         P                  ! VRR7      p\         P                  ! VRR7      pVP                  4        VP                  4        VP                  ^
4       VP                  ^
4       R# )c                 F   a  \        V 3R  l4      pVP                  4        R# )c                  0   < \         P                  ! S 4      # r%   )r   r   xs   r   <lambda>>TestGreenlet.test_thread_bug.<locals>.runner.<locals>.<lambda>q  s    DJJqMr   Nr*   )r   r,   s   f r   runner,TestGreenlet.test_thread_bug.<locals>.runnerp  s    12AHHJr   r   N)g?)g333333?)ry   rz   r{   r|   )r=   r   t1t2s   &   r   test_thread_bugTestGreenlet.test_thread_bugo  sU    	 V&9V&9





r   c                p   a  V 3R  lp\        V4      P                  ^^R7      pS P                  V^*4       R# )c                 P   < SP                  V ^4       SP                  V^4       ^*# )   )r:   )rl   ri   r=   s   &&r   rF   ,TestGreenlet.test_switch_kwargs.<locals>.run{  s&    Q"Q"r   )rl   ri   Nr+   r   r:   )r=   rF   r   s   f  r   test_switch_kwargsTestGreenlet.test_switch_kwargsz  s4    	 ##a1#-Br   c                    R  p\        V4      pV P                  R^/VP                  ^4      4       V P                  RR^/3VP                  4       4       V P                  RVP                  4       4       R# )c                     \         P                  ! 4       P                  P                  V R 7       \         P                  ! 4       P                  P                  ^^R 7       W ^,          3# )r   r   r   s   &r   rF   6TestGreenlet.test_switch_kwargs_to_parent.<locals>.run  sP    !((//!/4!((//Q/71f9r   r   N)   )r   	   )r+   r:   r   )r=   rF   r,   s   &  r   test_switch_kwargs_to_parent)TestGreenlet.test_switch_kwargs_to_parent  sd    	 #q188A;/$a)188:6,r   c                  aaa / o\         P                  ! 4       o\         P                  ! 4       oVVV3R  lp\         P                  ! VR7      pVP                  4        SP	                  ^
4       V P                  \        P                  4      ;_uu_ 4        SR,          P                  4        RRR4       SP                  4        VP                  ^
4       SP                  4        R#   + '       g   i     LC; i)c                  h   < \        R  4      SR&   S P                  4        SP                  ^
4       R# )c                      R # r%   r   r   r   r   r   ITestGreenlet.test_switch_to_another_thread.<locals>.run.<locals>.<lambda>      Dr   r,   Nr+   r   r   created_eventdata
done_events   r   rF   7TestGreenlet.test_switch_to_another_thread.<locals>.run  )    #L1DIOOBr   rw   r,   N)ry   r   rz   r{   r   rG   r   r   r   r   r|   clear)r=   rF   threadr  r  r  s   &  @@@r   test_switch_to_another_thread*TestGreenlet.test_switch_to_another_thread  s    !)__&
	  !!-2x~~..I /B

 /.s   C**C:	c                V   a a VV 3R  lpV 3R lo\        V4      P                  4        R# )c                     <  \        R 4      h   \        P                  ! 4       p \        S4      P	                  4        SP                  T \        P                  ! 4       4        R# ; i)funN)
ValueErrorr   r   r+   r   r:   )r   rd   r=   s    r   r8   &TestGreenlet.test_exc_state.<locals>.f  sK    ; '';<<>A%%'  3<<>:s
    AA&c                  R   < S P                  \        P                  ! 4       R4       R # )N)NNN)r:   r   r   rA   s   r   rd   &TestGreenlet.test_exc_state.<locals>.h  s    S\\^-?@r   Nr*   )r=   r8   rd   s   f @r   test_exc_stateTestGreenlet.test_exc_state  s     	;	A 	Ar   c                   R  pR pR p\        V4      pV P                  VP                  / 4       VP                  4        V P                  VP                  ^*4       V P                  VP                  R^*/4       VP                  Vn        V P                  VP                  R^*/4       V P                  \        W$4       V P                  \        W4^*4       R# )c                  :    ^*\         P                  ! 4       n        R# )*   N)r   r   testr   r   r   r8   *TestGreenlet.test_instance_dict.<locals>.f  s    )+H!&r   c                 
    V = R # r%   __dict__)r,   s   &r   deldict0TestGreenlet.test_instance_dict.<locals>.deldict  s    
r   c                     Wn         R # r%   r  )r,   r   s   &&r   setdict0TestGreenlet.test_instance_dict.<locals>.setdict  s    Jr   r  N)r+   r:   r  r   r  rG   	TypeError)r=   r8   r  r   r,   s   &    r   test_instance_dictTestGreenlet.test_instance_dict  s    	,		NR(	
$fb\2ZZ
fb\2)W0)W4r   c                t   a . oV3R  lp\        V4      pVP                  4        V P                  SR.4       R# )c                  d   < S P                  \        \        P                  ! 4       R 4      4       R# rF   N)r   hasattrr   r   )has_runs   r   func;TestGreenlet.test_running_greenlet_has_no_run.<locals>.func  s"    NN++-u5r   FNr   )r=   r*  r,   r)  s   &  @r    test_running_greenlet_has_no_run-TestGreenlet.test_running_greenlet_has_no_run  s4    	
 	
5'*r   c                    ^ RI pV P                  \        VP                   \        4       4       V P                  \        VP                  \        4       4       R# r   N)copyrG   r"  r+   deepcopy)r=   r0  s   & r   test_deepcopyTestGreenlet.test_deepcopy  s5    )TYY>)T]]KMBr   c                F  aaa \        R  4      o\        P                  ! 4       o. oVVV3R lp\        VSR7      pVP                  4        ?V P	                  S4       V P                  S^ ,          S4       V P                  S^,          P                  S4       SR RoRoR# )c                      R # r%   r   r   r   r   r   ;TestGreenlet.test_parent_restored_on_kill.<locals>.<lambda>  s    $r   c                  &  <  SP                  4        R #   \        P                   dg    SP                  \        P                  ! 4       P
                  4       SP                  \        P                  ! 4       4       S P                  4         R # i ; ir%   )r   r   r   r   r   r   )hubmainresults   r   worker9TestGreenlet.test_parent_restored_on_kill.<locals>.worker  s_    (( h113::;h1134

	s    A7BBr)   r   N)r+   r   r   r   r   rU   r   )r=   r;  r,   r8  r9  r:  s   &  @@@r   test_parent_restored_on_kill)TestGreenlet.test_parent_restored_on_kill  s    ,'""$	 s+	
fQi&fQi&&, 1Ir   c                    \        4       p\        R  VR7      pV P                  \        4      ;_uu_ 4        VP                  4        RRR4       R#   + '       g   i     R# ; i)c                      R # r%   r   r   r   r   r   9TestGreenlet.test_parent_return_failure.<locals>.<lambda>      r   r)   N)r+   rG   rH   r   )r=   r-   r   s   &  r   test_parent_return_failure'TestGreenlet.test_parent_return_failure  s>    ]b1~..IIK /...s   AA"	c                     ! R  R\         4      pV! R 4      pV P                  \        VP                  \        4       4       R# )c                   &   a  ] tR tRt o R tRtV tR# )>TestGreenlet.test_throw_exception_not_lost.<locals>.mygreenleti  c                J     \         h    M; i\        P                  ! Y4      # r%   )	Exceptionr+   __getattribute__r=   names   &&r   rJ  OTestGreenlet.test_throw_exception_not_lost.<locals>.mygreenlet.__getattribute__  s'    #O"33D??s    r   Nr   r   r   r   rJ  r   __classdictcell____classdict__s   @r   
mygreenletrG    s     @ @r   rR  c                      R # r%   r   r   r   r   r   <TestGreenlet.test_throw_exception_not_lost.<locals>.<lambda>      tr   N)r+   rG   r   rP   )r=   rR  r,   s   &  r   test_throw_exception_not_lost*TestGreenlet.test_throw_exception_not_lost  s4    	@ 	@ |$)QWWik:r   c                j  aaa . oR  oVVV3R lp\         P                  ! VR7      pVP                  4        VP                  ^
4       ?S'       d   V P	                  4        V P                  \        P                  4      ;_uu_ 4       pS^ ,          P                  \        4       RRR4       S'       g8   \        XP                  4      pT P                  VR8H  ;'       g    RV9   4       M%V P                  \        XP                  4      R4       \        S^ ,          P                  R4      '       dH   V P                  \         4      ;_uu_ 4        S^ ,          P                  P#                  4        RRR4       S'       gZ   \        S^ ,          P                  P$                  R4      '       d,   S^ ,          P                  P$                  P#                  4        M"V P'                  S^ ,          P                  4       ?RoSR RV n        R#   + '       g   i     ELq; i  + '       g   i     L; i)	c                  `    \         P                  ! 4       P                  P                  4        R # r%   r   r   r   r   r;  GTestGreenlet._do_test_throw_to_dead_thread_doesnt_crash.<locals>.worker       !((//1r   c                     < \        S4      p V P                  4        SP                  V 4       S'       d(   V P                  4        \        P                  ! 4        R # R # r%   )r+   r   r   r   r   )r,   r:  wait_for_cleanupr;  s    r   creatorHTestGreenlet._do_test_throw_to_dead_thread_doesnt_crash.<locals>.creator  s?    F#AHHJMM!
##%  r   rw   NBcannot switch to a different thread (which happens to have exited)zCannot switchr  r   T)ry   rz   r{   r|   wait_for_pending_cleanupsrG   r   r   rP   r   rJ   rK   r   r:   r(  r   RuntimeErrorr  f_localsr[   expect_greenlet_leak)r=   r]  r^  r   r&   sr:  r;  s   &f    @@r   *_do_test_throw_to_dead_thread_doesnt_crash7TestGreenlet._do_test_throw_to_dead_thread_doesnt_crash  s   	2	& G,			r
 **,x~~..#1IOOI& /  CMM"AOOYY ( ("a'
 CMM"T
 6!9%%w//""<00q	""((* 1  vay))22G<<q	""++113fQi0011I %)!C /.." 10s   	H"H"H	"H2	c                &    V P                  4        R # r%   rf  rA   s   &r   &test_throw_to_dead_thread_doesnt_crash3TestGreenlet.test_throw_to_dead_thread_doesnt_crash7  s    779r   c                (    V P                  R 4       R# rt   ri  rA   s   &r   +test_throw_to_dead_thread_doesnt_crash_wait8TestGreenlet.test_throw_to_dead_thread_doesnt_crash_wait;  s    77=r   c                     ! R  R\         4      pV! 4       pV P                  VP                  ^*4      ^+4       RV n        R# )c                   2   a  ] tR tRt o R tR tR tRtV tR# )7TestGreenlet.test_recursive_startup.<locals>.convolutedi@  c                @    \         P                  ! V 4       ^ V n        R# r/  )r+   __init__countrA   s   &r   rs  @TestGreenlet.test_recursive_startup.<locals>.convoluted.__init__A  s    $$T*
r   c                    VR 8X  d*   V P                   ^ 8X  d   ^V n         V P                  ^+4       \        P                  ! W4      # rZ   )rt  r   r+   rJ  rK  s   &&r   rJ  HTestGreenlet.test_recursive_startup.<locals>.convoluted.__getattribute__D  s6    5=TZZ1_!"DJKKO"33D??r   c                >     V P                   P                  V4       K  r   r   r   )r=   r   s   &&r   rF   ;TestGreenlet.test_recursive_startup.<locals>.convoluted.runI  s    KK&&u-r   )rt  N)	r   r   r   r   rs  rJ  rF   r   rO  rP  s   @r   
convolutedrq  @  s     @
. .r   r{  TN)r+   r:   r   rd  )r=   r{  r,   s   &  r   test_recursive_startup#TestGreenlet.test_recursive_startup>  s9    	. 	. L"r*
 %)!r   c                l  aaa \         P                  ! 4       oSP                  4        \         P                  ! 4       oSP                  4         ! VV3R  lR\        4      pR pVVV3R lp\        P
                  ! 4       p\        V4      .oV! 4       S^ ,          n        S^ ,          P                  4        \         P                  ! VR7      pVP                  4        SP                  4        SP                  4        V P                  \        P
                  ! 4       V4       VP                  ^
4       R# )c                   0   <a  ] tR tRt o VV3R ltRtV tR# );TestGreenlet.test_threaded_updatecurrent.<locals>.finalizedi[  c                H   < SP                  4        SP                  4        R # r%   releaseacquire)r=   lock1lock2s   &r   __del__CTestGreenlet.test_threaded_updatecurrent.<locals>.finalized.__del__\  s     r   r   Nr   r   r   r   r  r   rO  )rQ  r  r  s   @r   	finalizedr  [  s        r   r  c                  `    \         P                  ! 4       P                  P                  4        R # r%   r   r   r   r   deallocator=TestGreenlet.test_threaded_updatecurrent.<locals>.deallocatorc  r[  r   c                     < SP                  4        \        P                  ! 4        S ^  SP                  4        SP                  4        \        P                  ! 4        SP                  4        R# r/  r  r   r   r  )r,   r  r  s   r   fthread9TestGreenlet.test_threaded_updatecurrent.<locals>.fthreade  sF    MMO!!MMOMMO!MMOr   rw   N)ry   Lockr  objectr   r   r+   bombr   rz   r{   r  r:   r|   )	r=   r  r  r  r9  r   r,   r  r  s	   &     @@@r   test_threaded_updatecurrent(TestGreenlet.test_threaded_updatecurrentT  s      	  	  	 	2	 ""$%&K!		!G,		 	,,.5	r
r   c                   aaa . oVVV3R  loR o\        S4      .oS^ ,          P                  4        \        SS^ ,          4      oSP                  4       pV P                  S4       V P                  V^*4       R# )c                    < \         P                  ! 4       P                  P                  4       p S^  \         P                  ! 4       P                  Sn         \         P                  ! 4       P                  P                  V 4       SP	                  \         P                  ! 4       4       R#   SP	                  \         P                  ! 4       4       i ; ir/  )r   r   r   r   r   )r   	initiatorr!   r;  s    r   r;  >TestGreenlet.test_dealloc_switch_args_not_lost.<locals>.worker  s    '')00779Eq	'224;;I3##%,,33E:H//12H//12s   .B+ +&Cc                      ^*# r  r   r   r   r   r  ATestGreenlet.test_dealloc_switch_args_not_lost.<locals>.initiator      r   N)r+   r   r   r:   )r=   r   r  r!   r;  s   & @@@r   !test_dealloc_switch_args_not_lost.TestGreenlet.test_dealloc_switch_args_not_lost  sk    	3	 f%&q		6!95	  "#r   c                   aaa R  o ! R R\         4      pV! 4       o\        ^*R7      oVVV3R lp\        V4      pV P                  VP	                  4       S4       R# )c                     V ! V/ VB  R # r%   r   )r*  rl   ks   &&&r   _apply0TestGreenlet.test_tuple_subclass.<locals>._apply  s    !MqMr   c                   &   a  ] tR tRt o R tRtV tR# )1TestGreenlet.test_tuple_subclass.<locals>.mytuplei  c                r    \         P                  ! 4       P                  4        \        P	                  V 4      # r%   )r   r   r   tuple__len__rA   s   &r   r  9TestGreenlet.test_tuple_subclass.<locals>.mytuple.__len__  s&    ##%,,.}}T**r   r   N)r   r   r   r   r  r   rO  rP  s   @r   mytupler    s     + +r   r  )rl   c                  j   < S ! \         P                  ! 4       P                  P                  SS4       R # r%   r   )r  r   kwargss   r   switchapply5TestGreenlet.test_tuple_subclass.<locals>.switchapply  s$    8&&(//66fEr   N)r  dictr+   r:   r   )r=   r  r  r,   r  r   r  s   &   @@@r   test_tuple_subclass TestGreenlet.test_tuple_subclass  sL    		+e 	+ y	F$V,r   c                    \        R \        3R\        R 4      /4      p ! R RV4      p ! R RV4      pV! 4        V P                  \        V4       R# )AbstractSubclassrF   c                     R # r%   r   rA   s   &r   r   7TestGreenlet.test_abstract_subclasses.<locals>.<lambda>  s    r   c                       ] tR tRtRtR# ):TestGreenlet.test_abstract_subclasses.<locals>.BadSubclassi  r   Nr   r   r   r   BadSubclassr        r   r  c                   &   a  ] tR tRt o R tRtV tR# );TestGreenlet.test_abstract_subclasses.<locals>.GoodSubclassi  c                    R # r%   r   rA   s   &r   rF   ?TestGreenlet.test_abstract_subclasses.<locals>.GoodSubclass.run  s    r   r   N)r   r   r   r   rF   r   rO  rP  s   @r   GoodSubclassr    s      r   r  N)r   r+   r   rG   r"  )r=   r  r  r  s   &   r   test_abstract_subclasses%TestGreenlet.test_abstract_subclasses  sT    "NN#4568
	* 		+ 	 	)[1r   c                   a a \         P                  ! 4       '       g   R # \         P                  ! 4       ^ ,          oS^28  d   R # VV 3R lp\        ^4       F  pV! 4       '       g   K   R # 	  R # )Nc                  V  <a	a
aa \         P                  ! 4       o
S
P                  4        \         P                  ! 4       oSP                  4        R .oV
V3R lp \         P                  ! V R7      pVP	                  4         ! V
VV3R lR\
        4      o	 ! V	3R lR\
        4      p. p\        S^,          4      p\        P                  ! 4       pV! 4       pV FT  pRpS^ ,          '       d   VP                  ^
4        R # \        4       pS^ ,          '       d    MLVP                  V4       KV  	  \        P                  ! 4        S^ ,          '       d   VP                  ^
4       R # SP                  VP                  V4       V F  pSP                  VP                  V4       K!  	  R# )	Fc                  r   < S P                  4        \        P                  ! 4        SP                  4        R # r%   r  )r  r  s   r   another_threadWTestGreenlet.test_implicit_parent_with_threads.<locals>.attempt.<locals>.another_thread  s!    ##%r   rw   c                   2   <a  ] tR tRt o VVV3R ltRtV tR# )TTestGreenlet.test_implicit_parent_with_threads.<locals>.attempt.<locals>.gc_callbacki  c                R   < SP                  4        SP                  4        R S^ &   R# rt   r  )r=   r  r  recycleds   &r   r  \TestGreenlet.test_implicit_parent_with_threads.<locals>.attempt.<locals>.gc_callback.__del__  s    MMOMMO"&HQKr   r   Nr  )rQ  r  r  r  s   @r   gc_callbackr    s     ' 'r   r  c                   .   <a  ] tR tRt o V3R ltRtV tR# )PTestGreenlet.test_implicit_parent_with_threads.<locals>.attempt.<locals>.garbagei  c                ,   < W n         S! 4       V n        R # r%   )cyclecallback)r=   r  s   &r   rs  YTestGreenlet.test_implicit_parent_with_threads.<locals>.attempt.<locals>.garbage.__init__  s    !%J$/MDMr   )r  r  N)r   r   r   r   rs  r   rO  )rQ  r  s   @r   garbager    s     2 2r   r  NT)ry   r  r  rz   r{   r  r<   r   r   r|   r+   r   r   r   r:   r   )r  r   r  lr   currentr,   r   lastr  r  r  r  Nr=   s            @@@@r   attempt?TestGreenlet.test_implicit_parent_with_threads.<locals>.attempt  s5   NN$EMMONN$EMMOwH    7AGGI' 'f '
2& 2 Aac
A))+G	AA;;FF2J "}A;;  

A;;FF2JT[['2  73 r   )r   	isenabledget_thresholdr<   )r=   r  r   r  s   f  @r   !test_implicit_parent_with_threads.TestGreenlet.test_implicit_parent_with_threads  sN    ||~~q!r6,	Z qAyy r   c                  a aa ^ RI Ho ^ RI Ho  ! R R\        4      p\        P
                  ! V4      p. S n        VVV 3R lp\        ^
4       F  pV! V4      P                  4        K  	  S =\        '       d)   S P                  \        P
                  ! V4      V4       R# S P                  \        P
                  ! V4      V4       R# )r   r   )r   c                       ] tR tRtRtR# )TTestGreenlet.test_issue_245_reference_counting_subclass_no_threads.<locals>.Greenleti	  r   Nr   r   r   r   Greenletr  	  r  r   r  c                     <  S! 4       P                   P                  4        R #   S  d%    SP                  P                  S! 4       4        R # i ; ir%   )r   r   gletsr   )r   r   r=   s   r   greenlet_mainYTestGreenlet.test_issue_245_reference_counting_subclass_no_threads.<locals>.greenlet_main  s?    0##**, 0

!!*,/0s   $ 'AAN)r   r   r   r+   r   ro   r  r<   r   r
   assertGreaterEqualr:   )r=   r  initial_refsr  r   r   r   s   f    @@r   5test_issue_245_reference_counting_subclass_no_threadsBTestGreenlet.test_issue_245_reference_counting_subclass_no_threads   s     	()	{ 	 x0 
	0 rA]#**,  J&& ##COOH$=|LS__X6Er   z;The manylinux images appear to hang on this test on 3.13rc2c                0  aaaaa ^ RI Hp ^ RI Hp ^ RIHo  ! R R\
        4      o. oV! 4       oV3R loVVVVV3R lp\        P                  ! S4      p. pV^-,           p\        '       d   ^2p\        V4       F5  pV! 4       pV! W83R7      p	VP                  V4       V	P                  4        K7  	  V F  p
V
P                  ^
4       K  	  SR	 SP                  4        V P                  4        V P                  \        P                  ! S4      V4       R
# )r   )rz   )r   r  c                       ] tR tRtRtR# )STestGreenlet.test_issue_245_reference_counting_subclass_threads.<locals>.MyGreenleti8  r   Nr   r   r   r   
MyGreenletr  8  r  r   r  c                  F   < S ! 4       P                   P                  4        R # r%   ry  r  s   r   r  VTestGreenlet.test_issue_245_reference_counting_subclass_threads.<locals>.greenlet_main>  s    L&&(r   c                    < S! S4      pSP                  V4       VP                  4        ?V P                  4        SP                  ^
4       S! 4        R# )
   N)r   r   r   r   )greenlet_running_eventminer  r   r  r  ref_cleareds   & r   thread_mainTTestGreenlet.test_issue_245_reference_counting_subclass_threads.<locals>.thread_mainA  sH    m,DLLKKM"&&( R  Lr   r   r   N)ry   rz   r   r   r   r+   r   ro   r
   r<   r   r{   r   r   ra  r:   )r=   rz   r   r  r  thread_ready_eventsr   r   eventr	  r  r  r   r  r  r  s   &          @@@@@r   2test_issue_245_reference_counting_subclass_threads?TestGreenlet.test_issue_245_reference_counting_subclass_threads*  s     	%#'	 	 g	)	 	8 z2 #b(&& L|$AGE;X>F&&u-LLN	 % .JOOB . !H 	&&(4lCr   c                    R  p\        V4      pR p\        W24      pV P                  \        4      ;_uu_ 4        VP                  4        RRR4       R#   + '       g   i     R# ; i)c                      ^# )   r   r   r   r   no_args\TestGreenlet.test_falling_off_end_switches_to_unstarted_parent_raises_error.<locals>.no_argsx  r  r   c                      ^*# r  r   r   r   r   leafYTestGreenlet.test_falling_off_end_switches_to_unstarted_parent_raises_error.<locals>.leaf}  r  r   N)r+   rG   r"  r   )r=   r   parent_never_startedr  childs   &    r   >test_falling_off_end_switches_to_unstarted_parent_raises_errorKTestGreenlet.test_falling_off_end_switches_to_unstarted_parent_raises_errorw  sP    	  +73	 D7 y))LLN *)))s   AA&	c                    R  p\        V4      pR p\        W24      pVP                  4       pV P                  VR4       R# )c                 
    V ^3#    r   r   s   &r   one_argUTestGreenlet.test_falling_off_end_switches_to_unstarted_parent_works.<locals>.one_arg  s    r7Nr   c                      ^*# r  r   r   r   r   r  RTestGreenlet.test_falling_off_end_switches_to_unstarted_parent_works.<locals>.leaf  r  r   N)r  r  r   )r=   r  r  r  r  r:  s   &     r   7test_falling_off_end_switches_to_unstarted_parent_worksDTestGreenlet.test_falling_off_end_switches_to_unstarted_parent_works  s@    	  +73	 D7*r   c                  a  ! R  R\         4      pV! 4       p. o\        V3R lV4      pV P                  \        4      ;_uu_ 4        VP                  4        RRR4       V P	                  S^*.4       V P                  \        4      ;_uu_ 4        VP                  4        RRR4       V P	                  S^*.4       R#   + '       g   i     Ln; i  + '       g   i     L8; i)c                   &   a  ] tR tRt o R tRtV tR# )XTestGreenlet.test_switch_to_dead_greenlet_with_unstarted_perverse_parent.<locals>.Parenti  c                     VR 8X  d   \         hR# r'  )r   rK  s   &&r   rJ  iTestGreenlet.test_switch_to_dead_greenlet_with_unstarted_perverse_parent.<locals>.Parent.__getattribute__  s    5=#O !r   r   NrN  rP  s   @r   Parentr    s     $ $r   r  c                  &   < S P                  ^*4      # r  r   r    s   r   r   ZTestGreenlet.test_switch_to_dead_greenlet_with_unstarted_perverse_parent.<locals>.<lambda>      DKKOr   N)r+   rG   r   r   r:   )r=   r  r  r  r!   s   &   @r   ;test_switch_to_dead_greenlet_with_unstarted_perverse_parentHTestGreenlet.test_switch_to_dead_greenlet_with_unstarted_perverse_parent  s    	$[ 	$  &x35IJ y))LLN * 	t$y))LLN *t$ *)
 *)s   B>C>C	C!	c                  a . o\        V3R  l4      p\        V3R l4      pVP                  4        V P                  S^*.4       Wn        VP                  4       pV P	                  V4       V P                  S^*^.4       R# )c                  &   < S P                  ^4      # r  r   r    s   r   r   DTestGreenlet.test_switch_to_dead_greenlet_reparent.<locals>.<lambda>  s    4;;r?r   c                  &   < S P                  ^*4      # r  r   r    s   r   r   r     r  r   N)r+   r   r:   r   r[   )r=   r  r  r:  r!   s   &   @r   %test_switch_to_dead_greenlet_reparent2TestGreenlet.test_switch_to_dead_greenlet_reparent  sl    *+BC34t$+&!Bx(r   c                l  aa \         P                  ! 4       oV3R  lpV3R lo\        V4      pVP                  4        \        R 4      pVP                  4        V P	                  VP
                  4       V P                  VP
                  P                  P                  R4       V P	                  VP
                  P                  4       V P                  VP
                  P                  P                  P                  R4       V P                  VP
                  P                  P                  4       R# )c                     < S ! 4        R # r%   r   inners   r   outerHTestGreenlet.test_can_access_f_back_of_suspended_greenlet.<locals>.outer  s    Gr   c                  R   < S P                  \        P                  ! ^ 4      4       R# r/  )r   r   r   r9  s   r   r'  HTestGreenlet.test_can_access_f_back_of_suspended_greenlet.<locals>.inner  s    KKa()r   c                      R # r%   r   r   r   r   r   KTestGreenlet.test_can_access_f_back_of_suspended_greenlet.<locals>.<lambda>      r   r'  r(  N)r   r   r+   r   rT   r   r:   f_codeco_namer   r[   )r=   r(  r8  	unrelatedr'  r9  s   &   @@r   ,test_can_access_f_back_of_suspended_greenlet9TestGreenlet.test_can_access_f_back_of_suspended_greenlet  s     ""$		* % 

  -	 	S\\*,,44g>S\\001,,33;;WE#,,--445r   c                  aaa ^ RI Ho ^RIHo VVV3R lo\	        S4      pVP                  ^4       VP                  p\        ^4       F2  pV P                  VP                  R,          V4       VP                  pK4  	  V P                  VP                  R,          ^4       V P                  VP                  4       V P                  VP                  ^
4      R4       R# )r   )partial)_test_extension_cppc                    < V ^ 8  d'   V SP                  S! SV ^,
          4      4      ,          # \        P                  ! 4       P                  P	                  4       # r   )	test_callr   r   r   r   )vr7  r6  recurses   &r   r;  @TestGreenlet.test_get_stack_with_nested_c_calls.<locals>.recurse  sJ    1u.88!a%9PQQQ&&(//6688r   r:  i  N)	functoolsr6   r7  r+   r   r   r<   r:   rc  r   r[   )r=   grr   r}   r7  r6  r;  s   &   @@@r   "test_get_stack_with_nested_c_calls/TestGreenlet.test_get_stack_with_nested_c_calls  s    %)	9
 !
		!qAU^^C0!4LLE  	,a0%,,'2-r   c                <  aa \         P                  ! 4       oV3R  lpV3R lo\        V4      pVP                  4       p\        R 4      pVP                  4        V P	                  VP
                  P                  R4       V P                  VP                  4       R# )c                  @   < S ! \         P                  ! ^ 4      4       R# r/  )r   r   r&  s   r   r(  6TestGreenlet.test_frames_always_exposed.<locals>.outer  s    #--"#r   c                 *   < SP                  V 4       R # r%   )r   )r   r9  s   &r   r'  6TestGreenlet.test_frames_always_exposed.<locals>.inner  s    KKr   c                      R # r%   r   r   r   r   r   9TestGreenlet.test_frames_always_exposed.<locals>.<lambda>  r/  r   r(  N)	r   r   r+   r   r:   r0  r1  r[   r   )r=   r(  r?  r   r2  r'  r9  s   &    @@r   test_frames_always_exposed'TestGreenlet.test_frames_always_exposed  sx     ""$	$	 		  -	--w7%,,'r   )rd  r  N)F)9r   r   r   r   r>   rB   rM   rQ   rW   r\   re   rp   r   r   r   r   r   r   r   unittestskipIfr   r   r   r   r   r   r   r
  r  r#  r,  r2  r=  rC  rV  r   rf  rj  rm  r|  r  r  r  r  r  r  r  r  r  r  r"  r3  r@  rI  r   rO  rP  s   @r   r0   r0   5   s    .117
!
'(D,1 = =~,8+OI0 __&&&G55n+ 	 -& 5"	+C
6	; 7) 7)r : :> ) )*-^$4-82 5n(FT __&&&EDDDDL+%*)6:.&( (r   r0   c                   \   a  ] tR tRt o R tR tR tR tR tR t	R t
R	 tR
 tR tRtV tR# )TestGreenletSetParentErrorsi   c                :  aaa / o\         P                  ! 4       o\         P                  ! 4       oVVV3R  lpR p\         P                  ! VR7      pVP                  4        SP	                  ^
4       \        V4      pVP                  4        V P                  \        4      ;_uu_ 4       pSR,          Vn	        RRR4       SP                  4        VP                  ^
4       V P                  \        XP                  4      R4       R#   + '       g   i     LX; i)c                  h   < \        R  4      SR&   S P                  4        SP                  ^
4       R# )c                      R # r%   r   r   r   r   r   QTestGreenletSetParentErrors.test_threaded_reparent.<locals>.run.<locals>.<lambda>  r   r   r,   Nr  r  s   r   rF   ?TestGreenletSetParentErrors.test_threaded_reparent.<locals>.run  r  r   c                  `    \         P                  ! 4       P                  P                  4        R # r%   r   r   r   r   blankATestGreenletSetParentErrors.test_threaded_reparent.<locals>.blank  r[  r   rw   r,   Nz&parent cannot be on a different thread)ry   r   rz   r{   r   r+   r   rG   r  r   r   r|   r:   rJ   rK   )	r=   rF   rU  r	  r,   r&   r  r  r  s	   &     @@@r   test_threaded_reparent2TestGreenletSetParentErrors.test_threaded_reparent  s    !)__&
	 
	2 !!-2	
z**cCyAH +BS]]+-UV +*s   +D

D	c                  a . oV3R  lp\         P                  ! VR7      pVP                  4        VP                  ^
4       V P	                  V P
                  ^,           R7        ! V3R lR\        4      pV! R 4      pV P                  \        P                  4      ;_uu_ 4       pVP                  4        RRR4       V P                  \        XP                  4      R4       SR R#   + '       g   i     L:; i)	c                  b   < \        R  4      p SP                  V 4       V P                  4        R# )c                      R # r%   r   r   r   r   r   YTestGreenletSetParentErrors.test_unexpected_reparenting.<locals>.worker.<locals>.<lambda>      Dr   N)r+   r   r   )r,   anothers    r   r;  GTestGreenletSetParentErrors.test_unexpected_reparenting.<locals>.worker  s"    L)ANN1HHJr   rw   )initial_main_greenletsc                   .   <a  ] tR tRt o V3R ltRtV tR# )KTestGreenletSetParentErrors.test_unexpected_reparenting.<locals>.convolutedi7  c                Z   < VR 8X  d   S^ ,          V n         \        P                  ! W4      # rZ   r   r+   rJ  r=   rL  r^  s   &&r   rJ  \TestGreenletSetParentErrors.test_unexpected_reparenting.<locals>.convoluted.__getattribute__8  &    5=")!*DK"33D??r   r)   NrN  rQ  r^  s   @r   r{  rb  7       @ @r   r{  c                      R # r%   r   r   r   r   r   ITestGreenletSetParentErrors.test_unexpected_reparenting.<locals>.<lambda><  rU  r   Nr`  r   )ry   rz   r{   r|   ra  main_greenlets_before_testr+   rG   r   r   r   r:   rJ   rK   )r=   r;  r   r{  r,   r&   r^  s   &     @r   test_unexpected_reparenting7TestGreenletSetParentErrors.test_unexpected_reparenting  s    	 F+			r
& 	&&d>]>]`a>a&b	@ 	@
 |$x~~..#HHJ /S]]+]	_AJ	 /.s   'C**C:	c                :  aaa . o\         P                  ! 4       o\         P                  ! 4       oVVV3R  lp ! V3R lR\        4      p\         P                  ! VR7      pVP	                  4        SP                  ^
4        V! R 4      pV P                  \        P                  4      ;_uu_ 4       pVP                  4        RRR4       V P                  R\        XP                  4      4       V P                  R\        VP                  4      4       V P                  R\        VP                  4      4       SP                  4        VP                  ^
4       SR	 R#   + '       g   i     L; i  SP                  4        TP                  ^
4       SR	 i ; i)
c                     < \        R  4      p SP                  V 4       V P                  4        SP                  4        SP	                  ^
4       R# )c                      R # r%   r   r   r   r   r   hTestGreenletSetParentErrors.test_unexpected_reparenting_thread_running.<locals>.worker.<locals>.<lambda>J  r]  r   N)r+   r   r   r   r   )r,   r^  keep_main_aliveswitched_to_greenlets    r   r;  VTestGreenletSetParentErrors.test_unexpected_reparenting_thread_running.<locals>.workerI  s<    L)ANN1HHJ $$&  $r   c                   .   <a  ] tR tRt o V3R ltRtV tR# )ZTestGreenletSetParentErrors.test_unexpected_reparenting_thread_running.<locals>.convolutediO  c                Z   < VR 8X  d   S^ ,          V n         \        P                  ! W4      # rZ   rd  re  s   &&r   rJ  kTestGreenletSetParentErrors.test_unexpected_reparenting_thread_running.<locals>.convoluted.__getattribute__P  rg  r   r)   NrN  rh  s   @r   r{  rw  O  ri  r   r{  rw   c                      R # r%   r   r   r   r   r   XTestGreenletSetParentErrors.test_unexpected_reparenting_thread_running.<locals>.<lambda>Z      4r   Nz#Cannot switch to a different threadExpectedCurrentr   )ry   r   r+   rz   r{   r   rG   r   r   r   rI   rJ   rK   r   r|   )	r=   r;  r{  r   r,   r&   r^  rs  rt  s	   &     @@@r   *test_unexpected_reparenting_thread_runningFTestGreenletSetParentErrors.test_unexpected_reparenting_thread_runningC  s!    (0#//+	%	@ 	@ F+		!!"%	<(A""8>>22c
 3MM?S]]ASTMM*c#--&89MM)S%78!FF2J
 32 !FF2J
s%   0E4 3E!A7E4 !E1	,E4 4&Fc                <   \        R  4      pV P                  VP                  \        P                  ! 4       4       V P                  \        4      ;_uu_ 4       pV=RRR4       V P                  \        XP                  4      R4       R#   + '       g   i     L7; i)c                      R # r%   r   r   r   r   r   GTestGreenletSetParentErrors.test_cannot_delete_parent.<locals>.<lambda>h      Tr   Ncan't delete attribute)
r+   rU   r   r   r   rG   rH   r:   rJ   rK   )r=   r;  r&   s   &  r   test_cannot_delete_parent5TestGreenletSetParentErrors.test_cannot_delete_parentg  sg    \*fmmX%8%8%:;~..# /S]]+-EF /.s   BB	c                    V P                  \        4      ;_uu_ 4       p\        P                  ! 4       =R R R 4       V P                  \        XP                  4      R4       R #   + '       g   i     L7; i)Nr  rG   rH   r   r   r   r:   rJ   rK   r=   r&   s   & r   !test_cannot_delete_parent_of_main=TestGreenletSetParentErrors.test_cannot_delete_parent_of_maino  sL    ~..###%, /S]]+-EF /.s   A##A3	c                b    V P                  \        P                  ! 4       P                  4       R # r%   )r[   r   r   r   rA   s   &r   !test_main_greenlet_parent_is_none=TestGreenletSetParentErrors.test_main_greenlet_parent_is_noneu  s    (--/667r   c                   a  R  pV 3R lp\        V4      pS P                  V4       V! V4       VP                  4        S P                  V4       V! V4       VP                  4        R# )c                  `    \         P                  ! 4       P                  P                  4        R # r%   r   r   r   r   bgCTestGreenletSetParentErrors.test_set_parent_wrong_types.<locals>.bgz  s    !((//1r   c                   < R ^SR3 Fn  pSP                  \        4      ;_uu_ 4       pWn        R R R 4       SP                  \	        XP
                  4      R\        V4      P                  ,           4       Kp  	  R #   + '       g   i     LU; i)N42z4GreenletChecker: Expected any type of greenlet, not )rG   r"  r   r:   rJ   rK   typer   )gletpr&   r=   s   &  r   checkFTestGreenletSetParentErrors.test_set_parent_wrong_types.<locals>.check~  sj    1dD(&&y11S"#K 2   &JTRSWM]M]]_	 )11s   A<<BN)r+   r   r   r   )r=   r  r  r,   s   f   r   test_set_parent_wrong_types7TestGreenletSetParentErrors.test_set_parent_wrong_typesy  sW    	2	_ Oa 	

a 	

r   c                    \        R  4      pV P                  \        4      ;_uu_ 4       pWn        RRR4       V P	                  \        XP                  4      R4       R#   + '       g   i     L7; i)c                      R # r%   r   r   r   r   r   @TestGreenletSetParentErrors.test_trivial_cycle.<locals>.<lambda>  r|  r   Ncyclic parent chain)r+   rG   r  r   r:   rJ   rK   )r=   r  r&   s   &  r   test_trivial_cycle.TestGreenletSetParentErrors.test_trivial_cycle  sL    <(z**cK +S]]+-BC +*s   A  A0	c                   V P                  \        4      ;_uu_ 4       p\        P                  ! 4       \        P                  ! 4       n        R R R 4       V P                  \        XP                  4      R4       R #   + '       g   i     L7; i)Nz(cannot set the parent of a main greenletr  r  s   & r   test_trivial_cycle_main3TestGreenletSetParentErrors.test_trivial_cycle_main  sW    ~..#+3+>+>+@H!( /S]]+-WX /.s   .A;;B	c                .   \        R  4      p\        R 4      p\        R 4      pW!n        W2n        V P                  \        4      ;_uu_ 4       pWn        RRR4       V P	                  \        XP                  4      R4       R#   + '       g   i     L7; i)c                      R # r%   r   r   r   r   r   ?TestGreenletSetParentErrors.test_deeper_cycle.<locals>.<lambda>  rB  r   c                      R # r%   r   r   r   r   r   r    rB  r   c                      R # r%   r   r   r   r   r   r    rB  r   Nr  )r+   r   rG   r  r:   rJ   rK   )r=   r-   r   g3r&   s   &    r   test_deeper_cycle-TestGreenletSetParentErrors.test_deeper_cycle  sj    &&&		z**cI +S]]+-BC +*s   BB	r   N)r   r   r   r   rW  rm  r  r  r  r  r  r  r  r  r   rO  rP  s   @r   rN  rN     sE     W2'R"HGG88DY	D 	Dr   rN  c                   l   a  ] tR tRt o ]! ]R4      '       g   RR ltR tR tR t	R t
R	 tR
 tRtV tR# )TestRepri  assertEndsWithNc                L    V P                  VP                  V4      WV34       R # r%   )r   endswith)r=   re  suffixmsgs   &&&&r   r  TestRepr.assertEndsWith  s    OOAJJv.C0@Ar   c                f    \        \        P                  ! 4       4      pV P                  VR 4       R# ) current active started main>N)reprr   r   r  r=   rs   & r   test_main_while_running TestRepr.test_main_while_running  s&    $$&'A>?r   c                   a \         P                  ! 4       oV3R  lp\        V4      pVP                  4       pV P	                  VR4       R# )c                     < \        S 4      # r%   )r  r+  s   r   rF   -TestRepr.test_main_in_background.<locals>.run  s    :r    suspended active started main>N)r   r   r+   r   r  )r=   rF   r,   r  r9  s   &   @r   test_main_in_background TestRepr.test_main_in_background  s>    ""$	 HHJA@Ar   c                P    \        \        4       4      pV P                  VR 4       R# )z	 pending>N)r  r+   r  r  s   & r   test_initialTestRepr.test_initial  s    A{+r   c                6  a \         P                  ! 4       o ! V3R  lR\        P                  4      pV! 4       pVP	                  4        VP                  ^
4       V P                  VP                  R4       V P                  VP                  R4       \        ^4       F  p\        P                  ! R4       K  	  \        ^4       FO  pV P                  VP                  P                  4       \        VP                  4      pV P                  VR4       KQ  	  R# )c                   :   <a  ] tR tRt o R;ttRtV3R ltRtV t	R# )/TestRepr.test_main_from_other_thread.<locals>.Ti  Nc                   < \        S4      V n        \        P                  ! 4       V n        \        V P                  4      V n        R # r%   )r  original_mainr   r   	main_gletr  )r=   r9  s   &r   rF   3TestRepr.test_main_from_other_thread.<locals>.T.run  s0    %)$Z"!)!4!4!6#'#7 r   )r  r  r  )
r   r   r   r   r  r  r  rF   r   rO  )rQ  r9  s   @r   Tr    s     *..MKI8 8r   r  r  r  gMbP?z (thread exited) dead>N)r   r   ry   rz   r{   r|   r  r  r  r<   r   r   r   r  rc   r  )r=   r  r   r   r  r9  s   &    @r   test_main_from_other_thread$TestRepr.test_main_from_other_thread  s    ""$	8	   	8 C			r
AOO-NOAMM+JK qAJJu  qAOOAKK,,-Q[[!A#;< r   c                   \        R  4      pVP                  4        V P                  \        V4      R4       V P	                  R\        V4      4       V P	                  R\        V4      4       V P	                  R\        V4      4       R# )c                      R # r%   r   r   r   r   r   $TestRepr.test_dead.<locals>.<lambda>  s    r   z dead>	suspendedstartedactiveN)r+   r   r  r  assertNotInrV   s   & r   	test_deadTestRepr.test_dead  se    %	
DGX.d1g.DG,47+r   c                    \        R  4      p\        R 4      p\        P                  ! 4       pWV3 F3  pV P                  V: \        4       V P                  V: \        4       K5  	  R# )c                      R # r%   r   r   r   r   r   >TestRepr.test_formatting_produces_native_str.<locals>.<lambda>  r  r   c                      R # r%   r   r   r   r   r   r    r   r   N)r+   r   r   r   rJ   )r=   g_deadg_not_startedg_curr,   s   &    r   #test_formatting_produces_native_str,TestRepr.test_formatting_produces_native_str  s_     \*#L1##%-A!! !! .r   r   r%   )r   r   r   r   r(  r   r  r  r  r  r  r  r  r   rO  rP  s   @r   r  r    s?     8-..	B@B,!=F, r   r  c                   2   a  ] tR tRt o R tR tR tRtV tR# )TestMainGreenleti  c                    R \        \        P                  ! 4       4      9   g   Q h\        \        P                  ! 4       4      pR \        V4      9  g   Q hV# r+  )r  r   r   r  )r=   r   s   & r   _check_current_is_main'TestMainGreenlet._check_current_is_main  sH    h1134444$$&'T!W$$$r   c                d    V P                  4       p\        R V3/ 4      pV P                  V4       R# )subclassN)r  r  rT   )r=   	main_typer  s   &  r   )test_main_greenlet_type_can_be_subclassed:TestMainGreenlet.test_main_greenlet_type_can_be_subclassed  s.    //1	
YL"5X&r   c                x    V P                  4        V P                  \        P                  ! 4       \        4       R # r%   )r  r   r   r   r+   rA   s   &r   test_main_greenlet_is_greenlet/TestMainGreenlet.test_main_greenlet_is_greenlet  s'    ##%h113[Ar   r   N)	r   r   r   r   r  r  r  r   rO  rP  s   @r   r  r    s     '
B Br   r  c                   P   a  ] tR tRt o R tR tR tR tR tR t	R t
R	 tR
tV tR# )TestBrokenGreenletsi  c                    R  p\         P                  P                  V4      pRVn        V P	                  \
        R4      ;_uu_ 4        VP                  4        RRR4       R#   + '       g   i     R# ; i)c                      \        R 4      h)zNever get here)AssertionErrorr   r   r   r*  <TestBrokenGreenlets.test_failed_to_initialstub.<locals>.func  s     !122r   Tz;Failed to switch stacks into a greenlet for the first time.N)r   	_greenletUnswitchableGreenletforce_switch_errorassertRaisesRegexSystemErrorr   )r=   r*  r,   s   &  r   test_failed_to_initialstub.TestBrokenGreenlets.test_failed_to_initialstub  sc    	3 33D9###K$ac cHHJc c c cs   A##A4	c                  a . oV3R  lp\         P                  P                  V4      pVP                  4        V P	                  S^.4       VP                  4        V P	                  S^^.4       RVn        V P                  \        R4      ;_uu_ 4        VP                  4        RRR4       RVn        VP                  4        V P	                  S. RO4       R#   + '       g   i     L=; i)c                  "  < S P                  ^4       \        P                  ! 4       P                  P	                  4        S P                  ^4       \        P                  ! 4       P                  P	                  4        S P                  ^4       R# r3   r5   )runss   r   r*  DTestBrokenGreenlets.test_failed_to_switch_into_running.<locals>.func,  sZ    KKN!((//1KKN!((//1KKNr   Tz0Failed to switch stacks into a running greenlet.NF)r4   r   r   )r   r  r  r   r:   r  r  r  )r=   r*  r,   r  s   &  @r   "test_failed_to_switch_into_running6TestBrokenGreenlets.test_failed_to_switch_into_running*  s    	 33D9	
s#	
1v&###K$VX XHHJX  %	
y)X Xs   CC+	c                    V P                  R 4      pV P                  RVP                  4       V P                  VP                  V P	                  4       4       R# )zfail_slp_switch.pyzfail_slp_switch is runningN)assertScriptRaisesrI   output
returncode,get_expected_returncodes_for_aborted_processr=   exs   & r   &test_failed_to_slp_switch_into_running:TestBrokenGreenlets.test_failed_to_slp_switch_into_runningF  sA    $$%9:2BII>bmmT%V%V%XYr   c                    V P                  R 4      pV P                  RV4       V P                  RV4       V P                  RV4       V P                  RV4       V P                  RV4       V P                  RV4       R# )zfail_switch_two_greenlets.pyz	In g1_runTRACEzLEAVE TRACEzFalling off end of mainzFalling off end of g1_runzFalling off end of g2N
run_scriptrI   r=   r  s   & r   #test_reentrant_switch_two_greenlets7TestBrokenGreenlets.test_reentrant_switch_two_greenletsL  sh    !?@k6*gv&mV,/816:-v6r   c                    V P                  R RR7      pV P                  RVP                  4       V P                  RVP                  4       R# )zfail_switch_three_greenlets.py)	exitcodesr"  zpositional argumentsN)r4   )r  rI   r  r  s   & r   %test_reentrant_switch_three_greenlets9TestBrokenGreenlets.test_reentrant_switch_three_greenletsV  s@     $$%EQU$Vk299-,bii8r   c                L    V P                  R 4      pV P                  RV4       R# )zfail_switch_three_greenlets2.pya  RESULTS: [('trace', 'switch'), ('trace', 'switch'), ('g2 arg', 'g2 from tracefunc'), ('trace', 'switch'), ('main g1', 'from g2_run'), ('trace', 'switch'), ('g1 arg', 'g1 from main'), ('trace', 'switch'), ('main g2', 'from g1_run'), ('trace', 'switch'), ('g1 from parent', 'g1 from main 2'), ('trace', 'switch'), ('main g1.2', 'g1 done'), ('trace', 'switch'), ('g2 from parent', ()), ('trace', 'switch'), ('main g2.2', 'g2 done')]Nr  r  s   & r   &test_reentrant_switch_three_greenlets2:TestBrokenGreenlets.test_reentrant_switch_three_greenlets2_  s)     !BC= 		
r   c                L    V P                  R 4      pV P                  RV4       R# )z#fail_initialstub_already_started.pya!  RESULTS: ['Begin C', 'Switch to b from B.__getattribute__ in C', ('Begin B', ()), '_B_run switching to main', ('main from c', 'From B'), 'B.__getattribute__ back from main in C', ('Begin A', (None,)), ('A dead?', True, 'B dead?', True, 'C dead?', False), 'C done', ('main from c.2', None)]Nr  r  s   & r   4test_reentrant_switch_GreenletAlreadyStartedInPythonHTestBrokenGreenlets.test_reentrant_switch_GreenletAlreadyStartedInPythonq  s'    !FG1
 	
r   c                L    V P                  R 4      pV P                  RV4       R# )zfail_clearing_run_switches.pyzRESULTS [('G.__getattribute__', 'run'), ('RunCallable', '__del__'), ('main: g.switch()', 'from RunCallable'), ('run_func', 'enter')]Nr  r  s   & r   *test_reentrant_switch_run_callable_has_del>TestBrokenGreenlets.test_reentrant_switch_run_callable_has_del}  s'    !@A 	
r   r   N)r   r   r   r   r  r   r	  r  r  r  r  r  r   rO  rP  s   @r   r  r    s3     
*8Z79
$


 
r   r  c                   `   a  ] tR tRt o ]P
                  ! ]! ]R4      R4      R 4       tRt	V t
R# )
TestModulei  _is_gil_enabledz,Needs 3.13 and above for sys._is_gil_enabledc                    \         '       d'   V P                  \        P                  ! 4       4       R # V P	                  \        P                  ! 4       4       R # r%   )r
   r   r   r!  r   rA   s   &r   test_no_gil_on_free_threaded'TestModule.test_no_gil_on_free_threaded  s6     '&S0023OOC//12r   r   N)r   r   r   r   rK  
skipUnlessr(  r   r#  r   rO  rP  s   @r   r   r     s1     &78GI3I3r   r   __main__)r   r   r   ry   rK  abcr   r   r   r+   r>  r   r   r   r	   r
   	leakcheckr   r   rI  r   r"   r.   r0   rN  r  r  r  r   r   r9  r   r   r   <module>r)     s    	 
       ,  "   ) & (		 	H(8 H(VjD( jDZSx SlBx B.k
( k
Z3 3 zMMO r   