Ë
    ðmxi7½  ã                   ót  — d dl Z d dlZd dlZd dlZd dlZd dlmZ d dlmZ d dlZd dlmZ	 ddl
mZ ddl
mZ ddl
mZ dd	l
mZ dd
l
mZ ddlmZ  G d„ de«      Zd„ Zd„ Z G d„ de«      Z G d„ de«      Z G d„ de«      Z G d„ de«      Z G d„ de«      Z G d„ de«      Zedk(  r ej:                  «        yy)é    N)ÚABCMeta)Úabstractmethod)Úgreenleté   )ÚTestCase)ÚRUNNING_ON_MANYLINUX)ÚPY313)ÚPY314)ÚRUNNING_ON_FREETHREAD_BUILD)Úfails_leakcheckc                   ó   — e Zd Zy)Ú	SomeErrorN©Ú__name__Ú
__module__Ú__qualname__© ó    úS/home/htdocs/ttos/venv/lib/python3.12/site-packages/greenlet/tests/test_greenlet.pyr   r      s   „ Ør   r   c                 óÀ   — 	 t        j                  «       j                  j                  «        t        ‚#  | j	                  t        j                  «       d   «       ‚ xY w©Nr   )r   Ú
getcurrentÚparentÚswitchÚappendÚsysÚexc_infor   ©Úseens    r   Úfmainr    "   sJ   € ðÜ×ÑÓ×$Ñ$×+Ñ+Ô-ô €OøðØ�‰”C—L‘L“N 1Ñ%Ô&Øús	   ‚,4 ´)Ac                 óF   — d„ }t        || ¬«      }|j                  |«       y )Nc                 ó   — | ‚©Nr   )Úexcs    r   Úcrasherzsend_exception.<locals>.crasher.   s   € Øˆ	r   ©r   ©ÚRawGreenletr   )Úgr$   r%   Úg1s       r   Úsend_exceptionr+   +   s   € òä	�W QÔ	'€BØ‡I�Iˆc…Nr   c                   óœ  — e Zd Zd„ Zd„ Zd„ Zd„ Zd„ Zd„ Zd„ Z	d„ Z
d	„ Zd
„ Zd„ Zd„ Zd„ Z ej"                  exr ed«      d„ «       Zd„ Zd„ Zd„ Zd„ Zd„ Zd„ Zd„ Zd„ Zd„ Zd„ Zd„ Zd„ Z e!d0d„«       Z"e!d„ «       Z#d„ Z$e!d„ «       Z%d „ Z&d!„ Z'd"„ Z(d#„ Z)d$„ Z*d%„ Z+ ej"                  exr ed&«      d'„ «       Z,d(„ Z-d)„ Z.d*„ Z/d+„ Z0d,„ Z1d-„ Z2d.„ Z3y/)1ÚTestGreenletc                 ó  ‡— g Šˆfd„}t        |«      }‰j                  d«       |j                  «        ‰j                  d«       |j                  «        ‰j                  d«       | j                  ‰t	        t        d«      «      «       y )Nc                  ó¢   •— ‰ j                  d«       t        j                  «       j                  j	                  «        ‰ j                  d«       y )Nr   é   ©r   r   r   r   r   ©Úlsts   €r   Úfz'TestGreenlet._do_simple_test.<locals>.f9   s4   ø€ Ø�J‰J�qŒMÜ×ÑÓ!×(Ñ(×/Ñ/Ô1Ø�J‰J�q�Mr   r   é   é   é   )r(   r   r   ÚassertEqualÚlistÚrange)Úselfr4   r)   r3   s      @r   Ú_do_simple_testzTestGreenlet._do_simple_test6   sc   ø€ Øˆô	ô ˜‹NˆØ�
‰
�1ŒØ	�‰Œ
Ø�
‰
�1ŒØ	�‰Œ
Ø�
‰
�1ŒØ×Ñ˜œd¤5¨£8›nÕ-r   c                 ó$   — | j                  «        y r#   )r<   ©r;   s    r   Útest_simplezTestGreenlet.test_simpleE   s   € Ø×ÑÕr   c                 óÖ   — t        «       }| j                  t        «      5 }|j                  «        d d d «       | j	                  dt        j                  «      «       y # 1 sw Y   Œ/xY w©NÚrun)r(   ÚassertRaisesÚAttributeErrorr   ÚassertInÚstrÚ	exception©r;   r)   r$   s      r   Ú(test_switch_no_run_raises_AttributeErrorz5TestGreenlet.test_switch_no_run_raises_AttributeErrorH   sP   € Ü‹MˆØ×Ñœ~Ó.ð 	°#Ø�H‰HŒJ÷	ð 	�‰�eœS §¡Ó/Õ0÷	ð 	ús    AÁA(c                 óà   — t        «       }| j                  t        «      5 }|j                  t        «       d d d «       | j                  dt        j                  «      «       y # 1 sw Y   Œ/xY wrA   )r(   rC   rD   Úthrowr   rE   rF   rG   rH   s      r   Ú'test_throw_no_run_raises_AttributeErrorz4TestGreenlet.test_throw_no_run_raises_AttributeErrorO   sS   € Ü‹MˆØ×Ñœ~Ó.ð 	°#Ø�G‰G”IÔ÷	ð 	�‰�eœS §¡Ó/Õ0÷	ð 	ús    A$Á$A-c                 óš   — t        d ¬«      }| j                  |«       | j                  |j                  t	        j
                  «       «       y )Nr&   )r(   ÚassertIsNotNoneÚassertIsr   r   r   ©r;   r)   s     r   Útest_parent_equals_Nonez$TestGreenlet.test_parent_equals_NoneV   s5   € Ü˜tÔ$ˆØ×Ñ˜QÔØ�‰�a—h‘h¤× 3Ñ 3Ó 5Õ6r   c                 ót   — t        d ¬«      }| j                  |«       | j                  |j                  «       y )N)rB   )r(   rN   ÚassertIsNonerB   rP   s     r   Útest_run_equals_Nonez!TestGreenlet.test_run_equals_None[   s,   € Ü˜DÔ!ˆØ×Ñ˜QÔØ×Ñ˜!Ÿ%™%Õ r   c                 ó  ‡— g Šˆfd„}t        |«      }t        |«      }|j                  «        | j                  t        ‰«      d«       |j                  «        | j                  t        ‰«      d«       |j                  «        | j                  t        ‰«      d«       | j                  |j                  d«       |j                  «        | j                  t        ‰«      d«       | j                  |j                  d«       y )Nc                  ó¦   •— ‰ j                  d«       t        j                  «       j                  j	                  «        ‰ j                  ddg«       y )Nr   )r   r   r   r   r   Úextendr2   s   €r   r4   z)TestGreenlet.test_two_children.<locals>.fc   s9   ø€ Ø�J‰J�qŒMÜ×ÑÓ!×(Ñ(×/Ñ/Ô1Ø�J‰J˜˜1�vÕr   r   r5   r6   Té   )r(   r   r8   ÚlenÚdead)r;   r4   r)   Úhr3   s       @r   Útest_two_childrenzTestGreenlet.test_two_children`   s½   ø€ Øˆô	ô ˜‹NˆÜ˜‹NˆØ	�‰Œ
Ø×Ñœ˜S› 1Ô%Ø	�‰Œ
Ø×Ñœ˜S› 1Ô%Ø	�‰Œ
Ø×Ñœ˜S› 1Ô%Ø×Ñ˜Ÿ™ Ô&Ø	�‰Œ
Ø×Ñœ˜S› 1Ô%Ø×Ñ˜Ÿ™ Õ&r   c                 ó˜  ‡‡— g Šˆfd„Šˆˆfd„}| j                  t        j                  |«      t        sdnd«       t	        |«      }| j                  t        j                  |«      t        sdnd«       |j                  «        | j                  ‰g d¢«       | j                  t        j                  |«      t        sd«       y d«       y )Nc                  ó€   •— ‰ j                  d«       t        j                  «       j                  j	                  «        y )NÚbr1   r2   s   €r   r4   z3TestGreenlet.test_two_recursive_children.<locals>.fw   s)   ø€ Ø�J‰J�sŒOÜ×ÑÓ!×(Ñ(×/Ñ/Õ1r   c                  ó€   •— ‰j                  d«       t        ‰«      } | j                  «        ‰j                  d«       y )NÚaÚc)r   r(   r   )r)   r4   r3   s    €€r   r)   z3TestGreenlet.test_two_recursive_children.<locals>.g{   s+   ø€ Ø�J‰J�sŒOÜ˜A“ˆAØ�H‰HŒJØ�J‰J�s�Or   r5   r   )ra   r_   rb   )r8   r   Úgetrefcountr
   r(   r   )r;   r)   r4   r3   s     @@r   Útest_two_recursive_childrenz(TestGreenlet.test_two_recursive_childrent   s’   ù€ Øˆô	2õ	ð
 	×ÑœŸ™¨Ó+µe©QÀÔCÜ˜‹Nˆð 	×ÑœŸ™¨Ó+µe©QÀÔCØ	�‰Œ
Ø×Ñ˜šoÔ.à×ÑœŸ™¨Ó+µe¨QÕCÀÕCr   c                 ó   ‡ ‡— g Šˆ ˆfd„}t        d«      D �cg c]  }t        j                  |¬«      ‘Œ }}|D ]  }|j                  «        Œ |D ]  }|j	                  d«       Œ ‰ j                  t        ‰«      t        |«      «       y c c}w )Nc                  óH   •— ‰ j                  «        ‰j                  d«       y ©NT)r<   r   )r;   Úsuccesss   €€r   r4   z$TestGreenlet.test_threads.<locals>.f�   s   ø€ Ø× Ñ Ô"Ø�N‰N˜4Õ r   é
   ©Útarget)r:   Ú	threadingÚThreadÚstartÚjoinr8   rY   )r;   r4   ÚiÚthsÚthrh   s   `    @r   Útest_threadszTestGreenlet.test_threadsŠ   s€   ù€ Øˆõ	!ô 49¸³9Ö=¨aŒy×Ñ qÖ)Ð=ˆÐ=Øò 	ˆBØ�H‰H�Jð	àò 	ˆBØ�G‰G�B�Kð	à×Ñœ˜W›¤s¨3£xÕ0ùò >s   ˜Bc                 ó  — g }t        t        «      }t        t        «      }|j                  |«       |j                  |«       ||_        | j	                  |g «       | j                  t        |j                  «       | j	                  |t        g«       |j                  «       }| j	                  |d«       | j	                  |t        g«       |j                  d«      }| j	                  |d«       | j	                  |t        g«       y )Nr   é   )r(   r    r   r   r8   rC   r   )r;   r   r*   Úg2Úvalues        r   Útest_exceptionzTestGreenlet.test_exception—   sÌ   € ØˆÜœÓˆÜœÓˆØ
�	‰	�$ŒØ
�	‰	�$ŒØˆŒ	à×Ñ˜˜rÔ"ð 	×Ñœ) R§Y¡YÔ/Ø×Ñ˜¤	˜{Ô+à—	‘	“ˆØ×Ñ˜ Ô#Ø×Ñ˜¤	˜{Ô+à—	‘	˜"“ˆØ×Ñ˜ Ô#Ø×Ñ˜¤	˜{Õ+r   c                 ó¶   — g }t        t        «      }|j                  |«       | j                  t        t
        |t        «       | j                  |t        g«       y r#   )r(   r    r   rC   ÚKeyErrorr+   r8   )r;   r   r*   s      r   Útest_send_exceptionz TestGreenlet.test_send_exception³   sB   € ØˆÜœÓˆØ
�	‰	�$ŒØ×Ñœ(¤N°B¼ÔAØ×Ñ˜¤˜zÕ*r   c                 ó¢  — g }t        t        «      }t        t        «      }|j                  |«       |j                  |«       | j                  |g «       ~t	        j
                  «        | j                  |t        j                  g«       ~t	        j
                  «        | j                  |t        j                  t        j                  g«       y r#   )r(   r    r   r8   ÚgcÚcollectr   ÚGreenletExit)r;   r   r*   rv   s       r   Útest_dealloczTestGreenlet.test_deallocº   s“   € ØˆÜœÓˆÜœÓˆØ
�	‰	�$ŒØ
�	‰	�$ŒØ×Ñ˜˜rÔ"ØÜ
�
‰
ŒØ×Ñ˜¤× 5Ñ 5Ð6Ô7ØÜ
�
‰
ŒØ×Ñ˜¤× 5Ñ 5´x×7LÑ7LÐMÕNr   c                 óV  — d„ }t        |«      }|j                  «        t        j                  }ddlm}  |«       x}t        _        	 ~|t        _        |j                  «       }| j                  d|«       | j                  d|«       | j                  d|«       y # |t        _        w xY w)Nc                  óš   — 	 t        j                  «       j                  j                  «        y # t         j                  $ r t
        d ‚w xY wr#   )r   r   r   r   r   r   r   r   r   rB   zHTestGreenlet.test_dealloc_catches_GreenletExit_throws_other.<locals>.runÉ   s?   € ð*Ü×#Ñ#Ó%×,Ñ,×3Ñ3Õ5øÜ×(Ñ(ò *Ü TÐ)ð*ús	   ‚,/ ¯A
r   )ÚStringIOÚ	ExceptionÚignoredr   )r(   r   r   ÚstderrÚiorƒ   ÚgetvaluerE   )r;   rB   r)   Ú	oldstderrrƒ   r†   Úvs          r   Ú.test_dealloc_catches_GreenletExit_throws_otherz;TestGreenlet.test_dealloc_catches_GreenletExit_throws_otherÈ   sˆ   € ò	*ô ˜ÓˆØ	�‰Œ
ô
 —J‘Jˆ	ÝÙ&›jÐ(ˆ””ð	#Øà"ŒCŒJà�O‰OÓˆØ�‰�k 1Ô%Ø�‰�i Ô#Ø�‰�k 1Õ%øð #ŒC�Jús   ÁB ÂB(z=Sometimes flaky (getting one GreenletExit in the second list)c                 ó2  ‡‡‡‡‡‡— g Šg Št        j                  «       Št        j                  «       Št        j                  «       Št        j                  «       Šˆˆˆˆˆˆfd„}t        j                  |¬«      }|j                  «        ‰j	                  d«       | j                  ‰g «       | j                  t        ‰«      d«       ‰d d …= t        st        j                  «        | j                  ‰g «       ‰j                  «        ‰j	                  d«       	 | j                  ‰t        j                  g«       ‰j                  «        |j                  d«       ‰d d …= ‰d d …= y # ‰j                  «        |j                  d«       ‰d d …= ‰d d …= w xY w)Nc                  ó>  •— t        t        «      } | j                  ‰«       ‰j                  | «       ~ t	        j
                  «        ‰j                  «        ‰j                  d«       t        «        ‰j                  «        ‰j                  d«       t        «        y )Nr0   )r(   r    r   r   r}   r~   ÚsetÚwait)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   r4   z1TestGreenlet.test_dealloc_other_thread.<locals>.fó   sn   ø€ ÜœUÓ#ˆBØ�I‰I�dŒOØ�N‰N˜2ÔØÜ�J‰JŒLØ;×?Ñ?ÔAØ× Ñ  Ô#äŒMØ×"Ñ"Ô$Ø ×%Ñ% aÔ(Ü�Mr   rj   ri   r   r0   )rl   ÚEventrm   rn   r�   r8   rY   r   r}   r~   rŽ   r   r   ro   )	r;   r4   Útr�   r‘   r’   r“   r   r”   s	      @@@@@@r   Útest_dealloc_other_threadz&TestGreenlet.test_dealloc_other_threadã   sF  ý€ ð ˆØˆä:C¿/¹/Ó:KÐ7Ü#Ÿ/™/Ó+ˆÜ&Ÿ_™_Ó.ÐÜ(Ÿ™Ó0Ð÷	ñ 	ô ×Ñ AÔ&ˆØ	�‰Œ	Ø7×<Ñ<¸RÔ@à×Ñ˜˜rÔ"Ø×Ñœ˜W› qÔ)Ø’AˆJÝ*ô �J‰JŒLð 	×Ñ˜˜rÔ"Ø×ÑÔØ×Ñ Ô"ð	Ø×Ñ˜T¤H×$9Ñ$9Ð#:Ô;à ×$Ñ$Ô&Ø�F‰F�2ŒJØ’Q�Øš‘
øð !×$Ñ$Ô&Ø�F‰F�2ŒJØ’Q�Øš‘
ús   Ä!E) Å)-Fc                 ó@  ‡ — ˆ fd„}t        |«      }|j                  «       }‰ j                  ||j                  u «       ‰ j                  |«       |j                  «       }‰ j	                  |«       ‰ j                  |d«       ‰ j                  |j                  d «       y )Nc                  óÂ   •— t        j                  d«      } ‰j                  | j                  d «       t	        j
                  «       j                  j                  | «       y)Nr   úmeaning of life)r   Ú	_getframer8   Úf_backr   r   r   r   )r4   r;   s    €r   Úf1z#TestGreenlet.test_frame.<locals>.f1"  sE   ø€ Ü—‘˜aÓ ˆAØ×Ñ˜QŸX™X tÔ,Ü×ÑÓ!×(Ñ(×/Ñ/°Ô2Ø$r   rš   )r(   r   Ú
assertTrueÚgr_frameÚassertFalser8   )r;   r�   r)   ÚframeÚfrom_gs   `    r   Ú
test_framezTestGreenlet.test_frame!  s}   ø€ ô	%ô
 ˜‹OˆØ—‘“
ˆØ�‰˜ §¡Ð+Ô,Ø�‰˜Ôà—‘“ˆØ×Ñ˜ÔØ×Ñ˜Ð!2Ô3Ø×Ñ˜Ÿ™ TÕ*r   c                 óê   — d„ }t        j                  |d¬«      }t        j                  |d¬«      }|j                  «        |j                  «        |j                  d«       |j                  d«       y )Nc                 óB   ‡ — t        ˆ fd„«      }|j                  «        y )Nc                  ó.   •— t        j                  ‰ «      S r#   )ÚtimeÚsleep©Úxs   €r   ú<lambda>z>TestGreenlet.test_thread_bug.<locals>.runner.<locals>.<lambda>3  s   ø€ ¤D§J¡J¨q£M€ r   r'   )rª   r)   s   ` r   Úrunnerz,TestGreenlet.test_thread_bug.<locals>.runner2  s   ø€ ÜÓ1Ó2ˆAØ�H‰H�Jr   )gš™™™™™É?©rk   Úargs)g333333Ó?ri   )rl   rm   rn   ro   )r;   r¬   Út1Út2s       r   Útest_thread_bugzTestGreenlet.test_thread_bug1  sU   € ò	ô ×Ñ V°&Ô9ˆÜ×Ñ V°&Ô9ˆØ
�‰Œ
Ø
�‰Œ
Ø
�‰�ŒØ
�‰��r   c                 ól   ‡ — ˆ fd„}t        |«      j                  dd¬«      }‰ j                  |d«       y )Nc                 óN   •— ‰j                  | d«       ‰j                  |d«       y)Nr6   r5   é*   )r8   )ra   r_   r;   s     €r   rB   z,TestGreenlet.test_switch_kwargs.<locals>.run=  s&   ø€ Ø×Ñ˜Q Ô"Ø×Ñ˜Q Ô"Ør   r6   r5   )ra   r_   r´   ©r(   r   r8   )r;   rB   rª   s   `  r   Útest_switch_kwargszTestGreenlet.test_switch_kwargs<  s4   ø€ ô	ô ˜Ó×#Ñ# a¨1Ð#Ó-ˆØ×Ñ˜˜BÕr   c                 óî   — d„ }t        |«      }| j                  ddi|j                  d«      «       | j                  dddif|j                  «       «       | j                  d|j                  «       «       y )Nc                 óÊ   — t        j                  «       j                  j                  | ¬«       t        j                  «       j                  j                  dd¬«       | | dz  fS )Nr©   r5   r0   ©r   r   r   r   r©   s    r   rB   z6TestGreenlet.test_switch_kwargs_to_parent.<locals>.runE  sR   € Ü×ÑÓ!×(Ñ(×/Ñ/°!Ð/Ô4Ü×ÑÓ!×(Ñ(×/Ñ/°°QÐ/Ô7Ø�a˜1‘f�9Ðr   rª   r0   )r5   )r0   é	   )r(   r8   r   )r;   rB   r)   s      r   Útest_switch_kwargs_to_parentz)TestGreenlet.test_switch_kwargs_to_parentD  sd   € ò	ô ˜ÓˆØ×Ñ˜#˜q˜ 1§8¡8¨A£;Ô/Ø×Ñ˜$  a Ð)¨1¯8©8«:Ô6Ø×Ñ˜ §¡£Õ,r   c                 óÊ  ‡‡‡— i Št        j                  «       Št        j                  «       Šˆˆˆfd„}t        j                  |¬«      }|j                  «        ‰j	                  d«       | j                  t        j                  «      5  ‰d   j                  «        d d d «       ‰j                  «        |j                  d«       ‰j                  «        y # 1 sw Y   Œ;xY w)Nc                  óf   •— t        d„ «      ‰d<   ‰ j                  «        ‰j                  d«       y )Nc                   ó   — y r#   r   r   r   r   r«   zITestGreenlet.test_switch_to_another_thread.<locals>.run.<locals>.<lambda>T  ó   � r   r)   ri   ©r(   rŽ   r�   ©Úcreated_eventÚdataÚ
done_events   €€€r   rB   z7TestGreenlet.test_switch_to_another_thread.<locals>.runS  ó)   ø€ Ü#¡LÓ1ˆD�‰IØ×ÑÔØ�O‰O˜BÕr   rj   ri   r)   )rl   r•   rm   rn   r�   rC   r   Úerrorr   rŽ   ro   Úclear)r;   rB   ÚthreadrÂ   rÃ   rÄ   s      @@@r   Útest_switch_to_another_threadz*TestGreenlet.test_switch_to_another_threadN  s£   ú€ ØˆÜ!Ÿ™Ó)ˆÜ—_‘_Ó&ˆ
ö	 ô ×!Ñ!¨Ô-ˆØ�‰ŒØ×Ñ˜2ÔØ×ÑœxŸ~™~Ó.ñ 	Ø�‰I×ÑÔ÷	à�‰ÔØ�‰�BŒà�
‰
�÷	ð 	ús   ÂCÃC"c                 óP   ‡ ‡— ˆˆ fd„}ˆ fd„Št        |«      j                  «        y )Nc                  óÌ   •— 	 t        d«      ‚#  t        j                  «       } t        ‰«      j	                  «        ‰j                  | t        j                  «       «       Y y xY w)NÚfun)Ú
ValueErrorr   r   r(   r   r8   )r   r[   r;   s    €€r   r4   z&TestGreenlet.test_exc_state.<locals>.fb  sK   ø€ ð;Ü  Ó'Ð'øð;ÜŸ<™<›>�Ü˜A“×%Ñ%Ô'Ø× Ñ  ¬3¯<©<«>Ö:ús
   ƒ ŽAA#c                  óN   •— ‰ j                  t        j                  «       d«       y )N)NNN)r8   r   r   r>   s   €r   r[   z&TestGreenlet.test_exc_state.<locals>.hj  s   ø€ Ø×ÑœSŸ\™\›^Ð-?Õ@r   r'   )r;   r4   r[   s   ` @r   Útest_exc_statezTestGreenlet.test_exc_statea  s    ù€ õ	;ô	Aô 	�A‹×ÑÕr   c                 ó´  — d„ }d„ }d„ }t        |«      }| j                  |j                  i «       |j                  «        | j                  |j                  d«       | j                  |j                  ddi«       |j                  |_        | j                  |j                  ddi«       | j                  t        ||«       | j                  t        ||d«       y )Nc                  ó6   — dt        j                  «       _        y ©Nr´   )r   r   Útestr   r   r   r4   z*TestGreenlet.test_instance_dict.<locals>.fp  s   € Ø)+ŒH×ÑÓ!Õ&r   c                 ó   — | ` y r#   ©Ú__dict__)r)   s    r   Údeldictz0TestGreenlet.test_instance_dict.<locals>.deldictr  s   € Ø‘
r   c                 ó   — || _         y r#   rÕ   )r)   rw   s     r   Úsetdictz0TestGreenlet.test_instance_dict.<locals>.setdictt  s	   € ØˆA�Jr   r´   rÓ   )r(   r8   rÖ   r   rÓ   rC   Ú	TypeError)r;   r4   r×   rÙ   r)   s        r   Útest_instance_dictzTestGreenlet.test_instance_dicto  s¬   € ò	,ò	ò	ä˜‹NˆØ×Ñ˜Ÿ™ RÔ(Ø	�‰Œ
Ø×Ñ˜Ÿ™ Ô$Ø×Ñ˜Ÿ™ f¨b \Ô2Ø—Z‘ZˆŒ
Ø×Ñ˜Ÿ™ f¨b \Ô2Ø×Ñœ) W¨aÔ0Ø×Ñœ) W¨a°Õ4r   c                 óp   ‡— g Šˆfd„}t        |«      }|j                  «        | j                  ‰dg«       y )Nc                  ó`   •— ‰ j                  t        t        j                  «       d«      «       y rA   )r   Úhasattrr   r   )Úhas_runs   €r   Úfuncz;TestGreenlet.test_running_greenlet_has_no_run.<locals>.func‚  s"   ø€ Ø�N‰NÜœ×+Ñ+Ó-¨uÓ5õr   Frµ   )r;   rà   r)   rß   s      @r   Ú test_running_greenlet_has_no_runz-TestGreenlet.test_running_greenlet_has_no_run€  s4   ø€ Øˆô	ô
 ˜ÓˆØ	�‰Œ
Ø×Ñ˜ 5 'Õ*r   c                 ó°   — dd l }| j                  t        |j                   t        «       «       | j                  t        |j                  t        «       «       y r   )ÚcopyrC   rÚ   r(   Údeepcopy)r;   rã   s     r   Útest_deepcopyzTestGreenlet.test_deepcopy‹  s5   € ÛØ×Ñœ) T§Y¡Y´³Ô>Ø×Ñœ) T§]¡]´K³MÕBr   c                 ó4  ‡‡‡— t        d„ «      Št        j                  «       Šg Šˆˆˆfd„}t        |‰¬«      }|j                  «        ~| j	                  ‰«       | j                  ‰d   ‰«       | j                  ‰d   j                  ‰«       ‰d d …= d Šd Šy )Nc                   ó   — y r#   r   r   r   r   r«   z;TestGreenlet.test_parent_restored_on_kill.<locals>.<lambda>‘  r¿   r   c                  ó  •— 	 ‰j                  «        y # t        j                  $ rc ‰j                  t        j                  «       j
                  «       ‰j                  t        j                  «       «       ‰ j                  «        Y y w xY wr#   )r   r   r   r   r   r   )ÚhubÚmainÚresults   €€€r   Úworkerz9TestGreenlet.test_parent_restored_on_kill.<locals>.worker”  s_   ø€ ðà—‘•øÜ×(Ñ(ò à—‘œh×1Ñ1Ó3×:Ñ:Ô;Ø—‘œh×1Ñ1Ó3Ô4Ø—
‘
–ð	ús   ƒ ”A3B
Â	B
r&   r   r   )r(   r   r   r   rž   rO   r   )r;   rì   r)   ré   rê   rë   s      @@@r   Útest_parent_restored_on_killz)TestGreenlet.test_parent_restored_on_kill�  sˆ   ú€ Ü™,Ó'ˆÜ×"Ñ"Ó$ˆØˆö	ô ˜ sÔ+ˆØ	�‰Œ
àØ�‰˜ÔØ�‰�f˜Q‘i Ô&Ø�‰�f˜Q‘i×&Ñ&¨Ô,ð ’1ˆIØˆØ‰r   c                 ó¨   — t        «       }t        d„ |¬«      }| j                  t        «      5  |j                  «        d d d «       y # 1 sw Y   y xY w)Nc                   ó   — y r#   r   r   r   r   r«   z9TestGreenlet.test_parent_return_failure.<locals>.<lambda>¯  r¿   r   r&   )r(   rC   rD   r   )r;   r*   rv   s      r   Útest_parent_return_failurez'TestGreenlet.test_parent_return_failure«  sA   € ä‹]ˆä™¨bÔ1ˆà×Ñœ~Ó.ñ 	Ø�I‰IŒK÷	÷ 	ñ 	ús   ®AÁAc                 ó†   —  G d„ dt         «      } |d„ «      }| j                  t        |j                  t        «       «       y )Nc                   ó   — e Zd Zd„ Zy)ú>TestGreenlet.test_throw_exception_not_lost.<locals>.mygreenletc                 óJ   — 	 t         ‚#  Y nxY wt        j                  | |«      S r#   )r„   r(   Ú__getattribute__©r;   Únames     r   rõ   zOTestGreenlet.test_throw_exception_not_lost.<locals>.mygreenlet.__getattribute__¶  s)   € ðÜ#�OøðÙúÜ"×3Ñ3°D¸$Ó?Ð?s   ‚ ˆN©r   r   r   rõ   r   r   r   Ú
mygreenletró   µ  s   „ ó@r   rù   c                   ó   — y r#   r   r   r   r   r«   z<TestGreenlet.test_throw_exception_not_lost.<locals>.<lambda>¼  r¿   r   )r(   rC   r   rK   )r;   rù   r)   s      r   Útest_throw_exception_not_lostz*TestGreenlet.test_throw_exception_not_lost´  s4   € ô	@œô 	@ñ ‘|Ó$ˆØ×Ñœ) Q§W¡W¬i«kÕ:r   c                 ó²  ‡‡‡— g Šd„ Šˆˆˆfd„}t        j                  |¬«      }|j                  «        |j                  d«       ~‰r| j	                  «        | j                  t        j                  «      5 }‰d   j                  t        «       d d d «       ‰s0t        j                  «      }| j                  |dk(  xs d|v «       n%| j                  t        j                  «      d«       t        ‰d   j                  d«      r;| j                  t         «      5  ‰d   j                  j#                  «        d d d «       ‰sKt        ‰d   j                  j$                  d«      rF‰d   j                  j$                  j#                  «        n| j'                  ‰d   j                  «       ~d Š‰d d …= d	| _        y # 1 sw Y   �Œ0xY w# 1 sw Y   Œ‘xY w)
Nc                  ó\   — t        j                  «       j                  j                  «        y r#   r¹   r   r   r   rì   zGTestGreenlet._do_test_throw_to_dead_thread_doesnt_crash.<locals>.workerÂ  ó   € Ü×ÑÓ!×(Ñ(×/Ñ/Õ1r   c                  ó¬   •— t        ‰«      } | j                  «        ‰j                  | «       ‰r%| j                  «        t        j                  «        y y r#   )r(   r   r   r   r   )r)   rë   Úwait_for_cleanuprì   s    €€€r   ÚcreatorzHTestGreenlet._do_test_throw_to_dead_thread_doesnt_crash.<locals>.creatorÅ  s?   ø€ Ü˜FÓ#ˆAØ�H‰HŒJØ�M‰M˜!ÔÙà—‘”
Ü×#Ñ#Õ%ð  r   rj   ri   r   úBcannot switch to a different thread (which happens to have exited)zCannot switchrÇ   T)rl   rm   rn   ro   Úwait_for_pending_cleanupsrC   r   rÆ   rK   r   rF   rG   rž   r8   rÞ   rŸ   ÚRuntimeErrorrÇ   Úf_localsrS   Úexpect_greenlet_leak)r;   r   r  r–   r$   Úsrë   rì   s    `    @@r   Ú*_do_test_throw_to_dead_thread_doesnt_crashz7TestGreenlet._do_test_throw_to_dead_thread_doesnt_crash¿  s•  ú€ àˆò	2ö	&ô ×Ñ GÔ,ˆØ	�‰Œ	Ø	�‰ˆrŒ
Øñ Ø×*Ñ*Ô,Ø×ÑœxŸ~™~Ó.ð 	'°#Ø�1‰I�O‰OœIÔ&÷	'ñ  Ü�C—M‘MÓ"ˆAØ�O‰OØÐYÑYò (Ø" aÐ'õð
 ×ÑÜ�C—M‘MÓ"ØTôô
 �6˜!‘9×%Ñ% wÔ/à×"Ñ"¤<Ó0ñ +Ø�q‘	×"Ñ"×(Ñ(Ô*÷+ñ  ä�v˜a‘y×)Ñ)×2Ñ2°GÔ<Ø�q‘	×"Ñ"×+Ñ+×1Ñ1Õ3à×Ñ˜f Q™i×0Ñ0Ô1àØˆØ’1ˆIð %)ˆÕ!÷C	'ñ 	'ú÷"+ð +ús   Á9G ÄGÇ G
ÇGc                 ó$   — | j                  «        y r#   ©r  r>   s    r   Ú&test_throw_to_dead_thread_doesnt_crashz3TestGreenlet.test_throw_to_dead_thread_doesnt_crashù  s   € à×7Ñ7Õ9r   c                 ó&   — | j                  d«       y rg   r
  r>   s    r   Ú+test_throw_to_dead_thread_doesnt_crash_waitz8TestGreenlet.test_throw_to_dead_thread_doesnt_crash_waitý  s   € Ø×7Ñ7¸Õ=r   c                 ó€   —  G d„ dt         «      } |«       }| j                  |j                  d«      d«       d| _        y )Nc                   ó   — e Zd Zd„ Zd„ Zd„ Zy)ú7TestGreenlet.test_recursive_startup.<locals>.convolutedc                 ó<   — t        j                  | «       d| _        y r   )r(   Ú__init__Úcountr>   s    r   r  z@TestGreenlet.test_recursive_startup.<locals>.convoluted.__init__  s   € Ü×$Ñ$ TÔ*Ø�•
r   c                 ó†   — |dk(  r'| j                   dk(  rd| _         | j                  d«       t        j                  | |«      S )NrB   r   r   é+   )r  r   r(   rõ   rö   s     r   rõ   zHTestGreenlet.test_recursive_startup.<locals>.convoluted.__getattribute__  s8   € Ø˜5’= T§Z¡Z°1¢_Ø!"�D”JØ—K‘K ”OÜ"×3Ñ3°D¸$Ó?Ð?r   c                 ó<   — 	 | j                   j                  |«       Œr#   ©r   r   )r;   rw   s     r   rB   z;TestGreenlet.test_recursive_startup.<locals>.convoluted.run  s   € ØØ—K‘K×&Ñ& uÔ-ð r   N)r   r   r   r  rõ   rB   r   r   r   Ú
convolutedr    s   „ òò@ó
.r   r  r´   r  T)r(   r8   r   r  )r;   r  r)   s      r   Útest_recursive_startupz#TestGreenlet.test_recursive_startup   s9   € ô	.œô 	.ñ ‹LˆØ×Ñ˜Ÿ™ "› rÔ*ð
 %)ˆÕ!r   c                 óL  ‡‡‡— t        j                  «       Š‰j                  «        t        j                  «       Š‰j                  «         G ˆˆfd„dt        «      }d„ }ˆˆˆfd„}t	        j
                  «       }t        |«      gŠ |«       ‰d   _        ‰d   j                  «        t        j                  |¬«      }|j                  «        ‰j                  «        ‰j                  «        | j                  t	        j
                  «       |«       |j                  d«       y )Nc                   ó   •— e Zd Zˆ ˆfd„Zy)ú;TestGreenlet.test_threaded_updatecurrent.<locals>.finalizedc                 óF   •— ‰j                  «        ‰j                  «        y r#   ©ÚreleaseÚacquire)r;   Úlock1Úlock2s    €€r   Ú__del__zCTestGreenlet.test_threaded_updatecurrent.<locals>.finalized.__del__  s   ø€ ð —‘”Ø—‘•r   N©r   r   r   r#  ©r!  r"  s   €€r   Ú	finalizedr    s   ø„ ö r   r&  c                  ó\   — t        j                  «       j                  j                  «        y r#   r¹   r   r   r   Údeallocatorz=TestGreenlet.test_threaded_updatecurrent.<locals>.deallocator%  rþ   r   c                  óÜ   •— ‰j                  «        t        j                  «        ‰ d= ‰j                  «        ‰j                  «        t        j                  «        ‰j                  «        y r   ©r   r   r   r  )r)   r!  r"  s   €€€r   Úfthreadz9TestGreenlet.test_threaded_updatecurrent.<locals>.fthread'  sF   ø€ Ø�M‰MŒOÜ×ÑÔ!Ø�!�Ø�M‰MŒOØ�M‰MŒOÜ×ÑÔ!Ø�M‰M�Or   r   rj   ri   )rl   ÚLockr   Úobjectr   r   r(   Úbombr   rm   rn   r  r8   ro   )	r;   r&  r(  r+  rê   r–   r)   r!  r"  s	         @@@r   Útest_threaded_updatecurrentz(TestGreenlet.test_threaded_updatecurrent  sË   ú€ ä—‘Ó ˆØ�‰Œä—‘Ó ˆØ�‰Œ÷	 œô 	 ò	2ö	ô ×"Ñ"Ó$ˆÜ˜Ó%Ð&ˆÙ“Kˆˆ!‰Œ	Ø	ˆ!‰�‰ŒÜ×Ñ GÔ,ˆØ	�‰Œ	à�‰ŒØ�‰Œð 	×Ñœ×,Ñ,Ó.°Ô5à	�‰ˆr�
r   c                 óä   ‡‡‡— g Šˆˆˆfd„Šd„ Št        ‰«      gŠ‰d   j                  «        t        ‰‰d   «      Š‰j                  «       }| j                  ‰«       | j                  |d«       y )Nc                  óœ  •— t        j                  «       j                  j                  «       } ‰d= t        j                  «       j                  ‰_        	 t        j                  «       j                  j                  | «       ‰j	                  t        j                  «       «       y # ‰j	                  t        j                  «       «       w xY wr   )r   r   r   r   r   )rw   Ú	initiatorr   rì   s    €€€r   rì   z>TestGreenlet.test_dealloc_switch_args_not_lost.<locals>.workerG  s‹   ø€ ä×'Ñ'Ó)×0Ñ0×7Ñ7Ó9ˆEà�q�	Ü'×2Ñ2Ó4×;Ñ;ˆIÔð3Ü×#Ñ#Ó%×,Ñ,×3Ñ3°EÔ:à—‘œH×/Ñ/Ó1Õ2ø�—‘œH×/Ñ/Ó1Õ2ús   Á-B& Â&%Cc                   ó   — yrÒ   r   r   r   r   r2  zATestGreenlet.test_dealloc_switch_args_not_lost.<locals>.initiatorT  ó   € Ør   r   r´   )r(   r   rž   r8   )r;   rw   r2  r   rì   s     @@@r   Ú!test_dealloc_switch_args_not_lostz.TestGreenlet.test_dealloc_switch_args_not_lostE  sk   ú€ Øˆö	3ò	ô ˜fÓ%Ð&ˆàˆq‰	×ÑÔÜ 	¨6°!©9Ó5ˆ	Ø× Ñ Ó"ˆØ�‰˜ÔØ×Ñ˜ Õ#r   c                 ó¸   ‡‡‡— d„ Š G d„ dt         «      } |«       Št        d¬«      Šˆˆˆfd„}t        |«      }| j                  |j	                  «       ‰«       y )Nc                 ó   —  | |i |¤Ž y r#   r   )rà   ra   Úks      r   Ú_applyz0TestGreenlet.test_tuple_subclass.<locals>._applym  s   € Ù�!ˆM�q‹Mr   c                   ó   — e Zd Zd„ Zy)ú1TestGreenlet.test_tuple_subclass.<locals>.mytuplec                 óp   — t        j                  «       j                  «        t        j	                  | «      S r#   )r   r   r   ÚtupleÚ__len__r>   s    r   r>  z9TestGreenlet.test_tuple_subclass.<locals>.mytuple.__len__q  s&   € Ü×#Ñ#Ó%×,Ñ,Ô.Ü—}‘} TÓ*Ð*r   N)r   r   r   r>  r   r   r   Úmytupler;  p  s   „ ó+r   r?  r´   )ra   c                  óf   •—  ‰ t        j                  «       j                  j                  ‰‰«       y r#   r¹   )r9  r®   Úkwargss   €€€r   Úswitchapplyz5TestGreenlet.test_tuple_subclass.<locals>.switchapplyv  s$   ø€ Ù”8×&Ñ&Ó(×/Ñ/×6Ñ6¸¸fÕEr   )r=  Údictr(   r8   r   )r;   r?  rB  r)   r9  r®   rA  s       @@@r   Útest_tuple_subclassz TestGreenlet.test_tuple_subclass_  sL   ú€ ò	ô	+”eô 	+ñ ‹yˆÜ˜”ˆö	Fä˜Ó$ˆØ×Ñ˜Ÿ™› VÕ,r   c                 ó¦   — t        dt        fdt        d„ «      i«      } G d„ d|«      } G d„ d|«      } |«        | j                  t        |«       y )NÚAbstractSubclassrB   c                  ó   — y r#   r   r>   s    r   r«   z7TestGreenlet.test_abstract_subclasses.<locals>.<lambda>  r¿   r   c                   ó   — e Zd Zy)ú:TestGreenlet.test_abstract_subclasses.<locals>.BadSubclassNr   r   r   r   ÚBadSubclassrI  �  ó   „ Ør   rJ  c                   ó   — e Zd Zd„ Zy)ú;TestGreenlet.test_abstract_subclasses.<locals>.GoodSubclassc                  ó   — y r#   r   r>   s    r   rB   z?TestGreenlet.test_abstract_subclasses.<locals>.GoodSubclass.run…  s   € Ør   N)r   r   r   rB   r   r   r   ÚGoodSubclassrM  „  s   „ ór   rO  )r   r(   r   rC   rÚ   )r;   rF  rJ  rO  s       r   Útest_abstract_subclassesz%TestGreenlet.test_abstract_subclasses{  sT   € Ü"ØÜˆNØ”NÑ#4Ó5Ð6ó8Ðô
	Ð*ô 	ô	Ð+ô 	ñ 	ŒØ×Ñœ) [Õ1r   c                 óª   ‡ ‡— t        j                  «       sy t        j                  «       d   Š‰dk  ry ˆˆ fd„}t        d«      D ]  } |«       sŒ y  y )Nr   é2   c                  óô  •‡	‡
‡‡— t        j                  «       Š
‰
j                  «        t        j                  «       Š‰j                  «        dgŠˆ
ˆfd„} t        j                  | ¬«      }|j	                  «         G ˆ
ˆˆfd„dt
        «      Š	 G ˆ	fd„dt
        «      }g }t        ‰dz  «      }t        j                  «       } |«       }|D ]>  }d }‰d	   r|j                  d
«        yt        «       }‰d	   r n>|j                  |«       Œ@ t        j                  «        ‰d	   r|j                  d
«       y‰j                  |j                  |«       |D ]  }‰j                  |j                  |«       Œ  y)NFc                  ón   •— ‰ j                  «        t        j                  «        ‰j                  «        y r#   r*  r%  s   €€r   Úanother_threadzWTestGreenlet.test_implicit_parent_with_threads.<locals>.attempt.<locals>.another_thread—  s!   ø€ Ø—‘”Ü×#Ñ#Ô%Ø—‘•r   rj   c                   ó   •— e Zd Zˆ ˆˆfd„Zy)úTTestGreenlet.test_implicit_parent_with_threads.<locals>.attempt.<locals>.gc_callbackc                 óP   •— ‰j                  «        ‰j                  «        d‰d<   y )NTr   r  )r;   r!  r"  Úrecycleds    €€€r   r#  z\TestGreenlet.test_implicit_parent_with_threads.<locals>.attempt.<locals>.gc_callback.__del__ž  s   ø€ Ø—M‘M”OØ—M‘M”OØ"&�H˜Q’Kr   Nr$  )r!  r"  rY  s   €€€r   Úgc_callbackrW  �  s   ø„ ÷'r   rZ  c                   ó   •— e Zd Zˆ fd„Zy)úPTestGreenlet.test_implicit_parent_with_threads.<locals>.attempt.<locals>.garbagec                 ó,   •— | | _          ‰«       | _        y r#   )ÚcycleÚcallback)r;   rZ  s    €r   r  zYTestGreenlet.test_implicit_parent_with_threads.<locals>.attempt.<locals>.garbage.__init__£  s   ø€ Ø!%�D”JÙ$/£M�D•Mr   N)r   r   r   r  )rZ  s   €r   Úgarbager\  ¢  s   ø„ õ2r   r`  r5   r   ri   T)rl   r,  r   rm   rn   r-  r:   r   r   ro   r(   r   r}   r~   r8   r   )rU  r–   r`  Úlrª   Úcurrentr)   Ú_ÚlastrZ  r!  r"  rY  ÚNr;   s            @@@@€€r   Úattemptz?TestGreenlet.test_implicit_parent_with_threads.<locals>.attempt‘  s9  ü€ Ü—N‘NÓ$ˆEØ�M‰MŒOÜ—N‘NÓ$ˆEØ�M‰MŒOØ�wˆHõ ô × Ñ ¨Ô7ˆAØ�G‰GŒI÷'ð 'œfô 'ö
2œ&ô 2ð ˆAÜ�a˜‘c“
ˆAÜ×)Ñ)Ó+ˆGÙ“	ˆAØò �Ø�Ø˜A’;à—F‘F˜2”JÙ Ü"“}�Ø˜A’;ÙØ—‘˜•ðô —
‘
”Ø˜A’;Ø—F‘F˜2”JØØ×Ñ˜TŸ[™[¨'Ô2Øò 4�Ø× Ñ  §¡¨7Õ3ð4àr   r7   )r}   Ú	isenabledÚget_thresholdr:   )r;   rf  rc  re  s   `  @r   Ú!test_implicit_parent_with_threadsz.TestGreenlet.test_implicit_parent_with_threads‹  sO   ù€ Ü�|‰|Œ~ØÜ×ÑÓ˜qÑ!ˆØˆrŠ6Øõ,	ôZ �q“ò 	ˆAÙ�yÙñ	r   c                 óx  ‡ ‡‡— ddl mŠ ddl mŠ  G d„ dt        «      }t	        j
                  |«      }g ‰ _        ˆˆˆ fd„}t        d«      D ]  } ||«      j                  «        Œ ‰ `t        r&‰ j                  t	        j
                  |«      |«       y ‰ j                  t	        j
                  |«      |«       y )Nr   ©r   )r   c                   ó   — e Zd Zy)úTTestGreenlet.test_issue_245_reference_counting_subclass_no_threads.<locals>.GreenletNr   r   r   r   ÚGreenletrm  Ë  rK  r   rn  c                  óœ   •— 	  ‰«       j                   j                  «        y # ‰ $ r# ‰j                  j                   ‰«       «       Y y w xY wr#   )r   r   Úgletsr   )r   r   r;   s   €€€r   Úgreenlet_mainzYTestGreenlet.test_issue_245_reference_counting_subclass_no_threads.<locals>.greenlet_mainÔ  s?   ø€ ð0Ù“×#Ñ#×*Ñ*Õ,øØò 0Ø—
‘
×!Ñ!¡*£,Ö/ð0ús   ƒ# £%AÁ
Ari   )r   r   r   r(   r   rc   rp  r:   r   r   ÚassertGreaterEqualr8   )r;   rn  Úinitial_refsrq  rc  r   r   s   `    @@r   Ú5test_issue_245_reference_counting_subclass_no_threadszBTestGreenlet.test_issue_245_reference_counting_subclass_no_threadsÂ  s™   ú€ õ 	(Ý)ô	”{ô 	ô —‘ xÓ0ˆð ˆŒ
ö	0ô �r“ò 	-ˆAÙ�]Ó#×*Ñ*Õ,ð	-ð ˆJÝ&ð ×#Ñ#¤C§O¡O°HÓ$=¸|ÕLà×ÑœSŸ_™_¨XÓ6¸ÕEr   z;The manylinux images appear to hang on this test on 3.13rc2c                 ó  ‡‡‡‡‡— ddl m} ddl m} ddlmŠ  G d„ dt
        «      Šg Š |«       Šˆfd„Šˆˆˆˆˆfd„}t        j                  ‰«      }g }|d	z   }t        rd
}t        |«      D ]5  } |«       } |||f¬«      }	|j                  |«       |	j                  «        Œ7 |D ]  }
|
j                  d«       Œ ‰d d …= ‰j                  «        | j                  «        | j                  t        j                  ‰«      |«       y )Nr   )rm   )r•   rk  c                   ó   — e Zd Zy)úSTestGreenlet.test_issue_245_reference_counting_subclass_threads.<locals>.MyGreenletNr   r   r   r   Ú
MyGreenletrw  ú  rK  r   rx  c                  óD   •—  ‰ «       j                   j                  «        y r#   r  rk  s   €r   rq  zVTestGreenlet.test_issue_245_reference_counting_subclass_threads.<locals>.greenlet_main   s   ø€ Ù‹L×Ñ×&Ñ&Õ(r   c                 óª   •—  ‰‰«      }‰j                  |«       |j                  «        ~| j                  «        ‰j                  d«        ‰«        y )Nri   )r   r   rŽ   r�   )Úgreenlet_running_eventÚminerx  r   rp  rq  Úref_cleareds     €€€€€r   Úthread_mainzTTestGreenlet.test_issue_245_reference_counting_subclass_threads.<locals>.thread_main  sH   ø€ Ù˜mÓ,ˆDØ�L‰L˜Ôà�K‰KŒMàà"×&Ñ&Ô(ð ×Ñ˜RÔ ñ �Lr   é-   rR  r­   ri   )rl   rm   r•   r   r   r(   r   rc   r   r:   r   rn   r�   rŽ   r  r8   )r;   rm   r•   r~  rs  Úthread_ready_eventsÚthread_countrc  ÚeventrÈ   rÄ   rx  r   rp  rq  r}  s              @@@@@r   Ú2test_issue_245_reference_counting_subclass_threadsz?TestGreenlet.test_issue_245_reference_counting_subclass_threadsì  sø   ü€ õ 	%Ý#å'ô	œô 	ð ˆÙ“gˆô	)÷	ð 	ô8 —‘ zÓ2ˆØ ÐØ# bÑ(ˆÝ&ð ˆLÜ�|Ó$ò 	ˆAÙ“GˆEÙ ;°e°XÔ>ˆFØ×&Ñ& uÔ-Ø�L‰L�Nð		ð .ò 	 ˆJØ�O‰O˜BÕð	 ð ’!ˆHØ�‰Ôð 	×&Ñ&Ô(Ø×ÑœŸ™¨Ó4°lÕCr   c                 ó²   — d„ }t        |«      }d„ }t        ||«      }| j                  t        «      5  |j                  «        d d d «       y # 1 sw Y   y xY w)Nc                   ó   — y)Né   r   r   r   r   Úno_argsz\TestGreenlet.test_falling_off_end_switches_to_unstarted_parent_raises_error.<locals>.no_args:  r4  r   c                   ó   — yrÒ   r   r   r   r   ÚleafzYTestGreenlet.test_falling_off_end_switches_to_unstarted_parent_raises_error.<locals>.leaf?  r4  r   )r(   rC   rÚ   r   )r;   r‡  Úparent_never_startedr‰  Úchilds        r   Ú>test_falling_off_end_switches_to_unstarted_parent_raises_errorzKTestGreenlet.test_falling_off_end_switches_to_unstarted_parent_raises_error9  sV   € ò	ô  +¨7Ó3Ðò	ô ˜DÐ"6Ó7ˆð ×ÑœyÓ)ñ 	Ø�L‰LŒN÷	÷ 	ñ 	ús   ³AÁAc                 ó‚   — d„ }t        |«      }d„ }t        ||«      }|j                  «       }| j                  |d«       y )Nc                 ó
   — | dfS ©Né   r   r©   s    r   Úone_argzUTestGreenlet.test_falling_off_end_switches_to_unstarted_parent_works.<locals>.one_argI  s   € Ø�r�7ˆNr   c                   ó   — yrÒ   r   r   r   r   r‰  zRTestGreenlet.test_falling_off_end_switches_to_unstarted_parent_works.<locals>.leafN  r4  r   )r´   r�  rµ   )r;   r‘  rŠ  r‰  r‹  rë   s         r   Ú7test_falling_off_end_switches_to_unstarted_parent_workszDTestGreenlet.test_falling_off_end_switches_to_unstarted_parent_worksH  sC   € ò	ô  +¨7Ó3Ðò	ô ˜DÐ"6Ó7ˆà—‘“ˆØ×Ñ˜ Õ*r   c                 óˆ  ‡—  G d„ dt         «      } |«       }g Št        ˆfd„|«      }| j                  t        «      5  |j                  «        d d d «       | j	                  ‰dg«       | j                  t        «      5  |j                  «        d d d «       | j	                  ‰dg«       y # 1 sw Y   Œ^xY w# 1 sw Y   Œ)xY w)Nc                   ó   — e Zd Zd„ Zy)úXTestGreenlet.test_switch_to_dead_greenlet_with_unstarted_perverse_parent.<locals>.Parentc                 ó   — |dk(  rt         ‚y rA   )r   rö   s     r   rõ   ziTestGreenlet.test_switch_to_dead_greenlet_with_unstarted_perverse_parent.<locals>.Parent.__getattribute__X  s   € Ø˜5’=Ü#�Oð !r   Nrø   r   r   r   ÚParentr–  W  s   „ ó$r   r˜  c                  ó&   •— ‰ j                  d«      S rÒ   ©r   r   s   €r   r«   zZTestGreenlet.test_switch_to_dead_greenlet_with_unstarted_perverse_parent.<locals>.<lambda>_  ó   ø€  D§K¡K°£O€ r   r´   )r(   rC   r   r   r8   )r;   r˜  rŠ  r‹  r   s       @r   Ú;test_switch_to_dead_greenlet_with_unstarted_perverse_parentzHTestGreenlet.test_switch_to_dead_greenlet_with_unstarted_perverse_parentV  s¬   ø€ ô	$”[ô 	$ñ  &›xÐØˆÜÓ3Ð5IÓJˆð ×ÑœyÓ)ñ 	Ø�L‰LŒN÷	ð 	×Ñ˜ ˜tÔ$à×ÑœyÓ)ñ 	Ø�L‰LŒN÷	à×Ñ˜ ˜tÕ$÷	ð 	ú÷
	ð 	ús   ¾B,Á?B8Â,B5Â8Cc                 ó   ‡— g Št        ˆfd„«      }t        ˆfd„«      }|j                  «        | j                  ‰dg«       ||_        |j                  «       }| j	                  |«       | j                  ‰ddg«       y )Nc                  ó&   •— ‰ j                  d«      S r�  rš  r   s   €r   r«   zDTestGreenlet.test_switch_to_dead_greenlet_reparent.<locals>.<lambda>m  s   ø€ °4·;±;¸r³?€ r   c                  ó&   •— ‰ j                  d«      S rÒ   rš  r   s   €r   r«   zDTestGreenlet.test_switch_to_dead_greenlet_reparent.<locals>.<lambda>n  r›  r   r´   r�  )r(   r   r8   r   rS   )r;   rŠ  r‹  rë   r   s       @r   Ú%test_switch_to_dead_greenlet_reparentz2TestGreenlet.test_switch_to_dead_greenlet_reparentk  sn   ø€ ØˆÜ*Ó+BÓCÐÜÓ3Ó4ˆà�‰ŒØ×Ñ˜ ˜tÔ$à+ˆŒà—‘“ˆØ×Ñ˜&Ô!Ø×Ñ˜  B˜xÕ(r   c                 ód  ‡‡— t        j                  «       Šˆfd„}ˆfd„Št        |«      }|j                  «        t        d„ «      }|j                  «        | j	                  |j
                  «       | j                  |j
                  j                  j                  d«       | j	                  |j
                  j                  «       | j                  |j
                  j                  j                  j                  d«       | j                  |j
                  j                  j                  «       y )Nc                  ó   •—  ‰ «        y r#   r   ©Úinners   €r   ÚouterzHTestGreenlet.test_can_access_f_back_of_suspended_greenlet.<locals>.outer  s   ø€ Ù�Gr   c                  óN   •— ‰ j                  t        j                  d«      «       y r   )r   r   r›   ©rê   s   €r   r¤  zHTestGreenlet.test_can_access_f_back_of_suspended_greenlet.<locals>.inner‚  s   ø€ Ø�K‰KœŸ™ aÓ(Õ)r   c                   ó   — y r#   r   r   r   r   r«   zKTestGreenlet.test_can_access_f_back_of_suspended_greenlet.<locals>.<lambda>‹  r¿   r   r¤  r¥  )r   r   r(   r   rN   rŸ   r8   Úf_codeÚco_namerœ   rS   )r;   r¥  ré   Ú	unrelatedr¤  rê   s       @@r   Ú,test_can_access_f_back_of_suspended_greenletz9TestGreenlet.test_can_access_f_back_of_suspended_greenlety  sÚ   ù€ ô ×"Ñ"Ó$ˆô	ô	*ô ˜%Ó ˆà�
‰
Œô  ¡Ó-ˆ	Ø×ÑÔð 	×Ñ˜SŸ\™\Ô*Ø×Ñ˜Ÿ™×,Ñ,×4Ñ4°gÔ>Ø×Ñ˜SŸ\™\×0Ñ0Ô1Ø×Ñ˜Ÿ™×,Ñ,×3Ñ3×;Ñ;¸WÔEà×Ñ˜#Ÿ,™,×-Ñ-×4Ñ4Õ5r   c                 ó¬  ‡‡‡— ddl mŠ ddlmŠ ˆˆˆfd„Št	        ‰«      }|j                  d«       |j                  }t        d«      D ]-  }| j                  |j                  d   |«       |j                  }Œ/ | j                  |j                  d   d«       | j                  |j                  «       | j                  |j                  d«      d	«       y )
Nr   )Úpartialr   )Ú_test_extension_cppc                 ó¢   •— | dkD  r| ‰j                   ‰‰| dz
  «      «      z  S t        j                  «       j                  j	                  «       S )Nr   r   )Ú	test_callr   r   r   r   )rŠ   r¯  r®  Úrecurses    €€€r   r²  z@TestGreenlet.test_get_stack_with_nested_c_calls.<locals>.recurseš  sJ   ø€ Ø�1ŠuØÐ.×8Ñ8¹ÀÈ!ÈaÉ%Ó9PÓQÑQÐQÜ×&Ñ&Ó(×/Ñ/×6Ñ6Ó8Ð8r   r7   rŠ   ri   i°  )Ú	functoolsr®  Ú r¯  r(   r   rŸ   r:   r8   r  rœ   rS   )r;   Úgrr¡   rp   r¯  r®  r²  s       @@@r   Ú"test_get_stack_with_nested_c_callsz/TestGreenlet.test_get_stack_with_nested_c_calls–  s¨   ú€ Ý%Ý)ö	9ô
 ˜Ó!ˆØ
�	‰	�!ŒØ—‘ˆÜ�q“ò 	!ˆAØ×Ñ˜UŸ^™^¨CÑ0°!Ô4Ø—L‘L‰Eð	!ð 	×Ñ˜Ÿ™¨Ñ,¨aÔ0Ø×Ñ˜%Ÿ,™,Ô'Ø×Ñ˜Ÿ™ 2›¨Õ-r   c                 ó4  ‡‡— t        j                  «       Šˆfd„}ˆfd„Št        |«      }|j                  «       }t        d„ «      }|j                  «        | j	                  |j
                  j                  d«       | j                  |j                  «       y )Nc                  ó<   •—  ‰ t        j                  d«      «       y r   )r   r›   r£  s   €r   r¥  z6TestGreenlet.test_frames_always_exposed.<locals>.outer¯  s   ø€ Ù”#—-‘- Ó"Õ#r   c                 ó(   •— ‰j                  | «       y r#   )r   )r¡   rê   s    €r   r¤  z6TestGreenlet.test_frames_always_exposed.<locals>.inner²  s   ø€ Ø�K‰K˜Õr   c                   ó   — y r#   r   r   r   r   r«   z9TestGreenlet.test_frames_always_exposed.<locals>.<lambda>º  r¿   r   r¥  )	r   r   r(   r   r8   r©  rª  rS   rœ   )r;   r¥  rµ  r¡   r«  r¤  rê   s        @@r   Útest_frames_always_exposedz'TestGreenlet.test_frames_always_exposed©  sx   ù€ ô ×"Ñ"Ó$ˆô	$ô	ô ˜ÓˆØ—	‘	“ˆô  ¡Ó-ˆ	Ø×ÑÔà×Ñ˜Ÿ™×-Ñ-¨wÔ7à×Ñ˜%Ÿ,™,Õ'r   N)F)4r   r   r   r<   r?   rI   rL   rQ   rT   r\   rd   rs   rx   r{   r€   r‹   ÚunittestÚskipIfr	   r   r—   r£   r±   r¶   r»   rÉ   rÏ   rÛ   rá   rå   rí   rð   rû   r   r  r  r  r  r/  r5  rD  rP  ri  rt  rƒ  rŒ  r“  rœ  r   r¬  r¶  r»  r   r   r   r-   r-   4   se  „ ò.òò1ò1ò7ò
!ò
'ò(Dò,1ò,ò8+òOò&ð6 €X‡_�_ØÒ&Ð&ØGóñ5óð5òn+ò 	ò ò-òò& ò5ò"	+òCò
ò6ò	;ð ò7)ó ð7)ðr ñ:ó ð:ò>ð ñ)ó ð)ò*-ò^$ò4-ò82ò 5òn(FðT €X‡_�_ØÒ&Ð&ØEóñDDóðDDòLò+ò%ò*)ò6ò:.ó&(r   r-   c                   óH   — e Zd Zd„ Zd„ Zd„ Zd„ Zd„ Zd„ Zd„ Z	d„ Z
d	„ Zd
„ Zy)ÚTestGreenletSetParentErrorsc                 ó
  ‡‡‡— i Št        j                  «       Št        j                  «       Šˆˆˆfd„}d„ }t        j                  |¬«      }|j                  «        ‰j	                  d«       t        |«      }|j                  «        | j                  t        «      5 }‰d   |_	        d d d «       ‰j                  «        |j                  d«       | j                  t        j                  «      d«       y # 1 sw Y   ŒPxY w)Nc                  óf   •— t        d„ «      ‰d<   ‰ j                  «        ‰j                  d«       y )Nc                   ó   — y r#   r   r   r   r   r«   zQTestGreenletSetParentErrors.test_threaded_reparent.<locals>.run.<locals>.<lambda>É  r¿   r   r)   ri   rÀ   rÁ   s   €€€r   rB   z?TestGreenletSetParentErrors.test_threaded_reparent.<locals>.runÈ  rÅ   r   c                  ó\   — t        j                  «       j                  j                  «        y r#   r¹   r   r   r   ÚblankzATestGreenletSetParentErrors.test_threaded_reparent.<locals>.blankÍ  rþ   r   rj   ri   r)   z&parent cannot be on a different thread)rl   r•   rm   rn   r�   r(   r   rC   rÍ   r   rŽ   ro   r8   rF   rG   )	r;   rB   rÄ  rÈ   r)   r$   rÂ   rÃ   rÄ   s	         @@@r   Útest_threaded_reparentz2TestGreenletSetParentErrors.test_threaded_reparentÃ  sÅ   ú€ ØˆÜ!Ÿ™Ó)ˆÜ—_‘_Ó&ˆ
ö	 ò
	2ô ×!Ñ!¨Ô-ˆØ�‰ŒØ×Ñ˜2ÔÜ˜ÓˆØ	�‰Œ
Ø×ÑœzÓ*ð 	!¨cØ˜C‘yˆAŒH÷	!à�‰ÔØ�‰�BŒà×Ñœ˜SŸ]™]Ó+Ð-UÕV÷	!ð 	!ús   ÂC9Ã9Dc                 óÐ  ‡— g Šˆfd„}t        j                  |¬«      }|j                  «        |j                  d«       | j	                  | j
                  dz   ¬«        G ˆfd„dt        «      } |d„ «      }| j                  t        j                  «      5 }|j                  «        d d d «       | j                  t        j                  «      d	«       ‰d d …= y # 1 sw Y   Œ4xY w)
Nc                  ó`   •— t        d„ «      } ‰j                  | «       | j                  «        y )Nc                   ó   — y r#   r   r   r   r   r«   zYTestGreenletSetParentErrors.test_unexpected_reparenting.<locals>.worker.<locals>.<lambda>ß  r¿   r   )r(   r   r   )r)   Úanothers    €r   rì   zGTestGreenletSetParentErrors.test_unexpected_reparenting.<locals>.workerÞ  s"   ø€ Ü™LÓ)ˆAØ�N‰N˜1ÔØ�H‰H�Jr   rj   ri   r   )Úinitial_main_greenletsc                   ó   •— e Zd Zˆ fd„Zy)úKTestGreenletSetParentErrors.test_unexpected_reparenting.<locals>.convolutedc                 óN   •— |dk(  r
‰d   | _         t        j                  | |«      S ©NrB   r   ©r   r(   rõ   ©r;   r÷   rÉ  s     €r   rõ   z\TestGreenletSetParentErrors.test_unexpected_reparenting.<locals>.convoluted.__getattribute__ú  ó(   ø€ Ø˜5’=Ø")¨!¡*�D”KÜ"×3Ñ3°D¸$Ó?Ð?r   Nrø   ©rÉ  s   €r   r  rÌ  ù  ó	   ø„ õ@r   r  c                   ó   — y r#   r   r   r   r   r«   zITestGreenletSetParentErrors.test_unexpected_reparenting.<locals>.<lambda>þ  r¿   r   r  )rl   rm   rn   ro   r  Úmain_greenlets_before_testr(   rC   r   rÆ   r   r8   rF   rG   )r;   rì   r–   r  r)   r$   rÉ  s         @r   Útest_unexpected_reparentingz7TestGreenletSetParentErrors.test_unexpected_reparentingÜ  sÂ   ø€ Øˆô	ô ×Ñ FÔ+ˆØ	�‰Œ	Ø	�‰ˆrŒ
ð& 	×&Ñ&¸d×>]Ñ>]Ð`aÑ>aÐ&Ôbö	@œô 	@ñ
 ‘|Ó$ˆØ×ÑœxŸ~™~Ó.ð 	°#Ø�H‰HŒJ÷	à×Ñœ˜SŸ]™]Ó+Ø]ô	_à’A‰J÷		ð 	ús   ÂCÃC%c                 ó  ‡‡‡— g Št        j                  «       Št        j                  «       Šˆˆˆfd„} G ˆfd„dt        «      }t        j                  |¬«      }|j	                  «        ‰j                  d«       	  |d„ «      }| j                  t        j                  «      5 }|j                  «        d d d «       | j                  dt        j                  «      «       | j                  dt        |j                  «      «       | j                  d	t        |j                  «      «       ‰j                  «        |j                  d«       ‰d d …= y # 1 sw Y   ŒŸxY w# ‰j                  «        |j                  d«       ‰d d …= w xY w)
Nc                  ó¢   •— t        d„ «      } ‰j                  | «       | j                  «        ‰j                  «        ‰j	                  d«       y )Nc                   ó   — y r#   r   r   r   r   r«   zhTestGreenletSetParentErrors.test_unexpected_reparenting_thread_running.<locals>.worker.<locals>.<lambda>  r¿   r   ri   )r(   r   r   rŽ   r�   )r)   rÉ  Úkeep_main_aliveÚswitched_to_greenlets    €€€r   rì   zVTestGreenletSetParentErrors.test_unexpected_reparenting_thread_running.<locals>.worker  s<   ø€ Ü™LÓ)ˆAØ�N‰N˜1ÔØ�H‰HŒJØ ×$Ñ$Ô&Ø× Ñ  Õ$r   c                   ó   •— e Zd Zˆ fd„Zy)úZTestGreenletSetParentErrors.test_unexpected_reparenting_thread_running.<locals>.convolutedc                 óN   •— |dk(  r
‰d   | _         t        j                  | |«      S rÎ  rÏ  rÐ  s     €r   rõ   zkTestGreenletSetParentErrors.test_unexpected_reparenting_thread_running.<locals>.convoluted.__getattribute__  rÑ  r   Nrø   rÒ  s   €r   r  rÝ    rÓ  r   r  rj   ri   c                   ó   — y r#   r   r   r   r   r«   zXTestGreenletSetParentErrors.test_unexpected_reparenting_thread_running.<locals>.<lambda>  r¿   r   z#Cannot switch to a different threadÚExpectedÚCurrent)rl   r•   r(   rm   rn   r�   rC   r   rÆ   r   rE   rF   rG   rŽ   ro   )	r;   rì   r  r–   r)   r$   rÉ  rÚ  rÛ  s	         @@@r   Ú*test_unexpected_reparenting_thread_runningzFTestGreenletSetParentErrors.test_unexpected_reparenting_thread_running  s%  ú€ ð ˆÜ(Ÿ™Ó0ÐÜ#Ÿ/™/Ó+ˆö	%ö	@œô 	@ô ×Ñ FÔ+ˆØ	�‰Œ	à×!Ñ! "Ô%ð	Ù™<Ó(ˆAà×"Ñ"¤8§>¡>Ó2ð °cØ—‘”
÷à�M‰MÐ?ÄÀSÇ]Á]ÓASÔTØ�M‰M˜*¤c¨#¯-©-Ó&8Ô9Ø�M‰M˜)¤S¨¯©Ó%7Ô8à×ÑÔ!Ø�F‰F�2ŒJàš‘
÷ð ûð ×ÑÔ!Ø�F‰F�2ŒJàš‘
ús%   Á>(E! Â&EÂ7A7E! ÅEÅE! Å!(F	c                 ó  — t        d„ «      }| j                  |j                  t        j                  «       «       | j                  t        «      5 }|`d d d «       | j                  t        j                  «      d«       y # 1 sw Y   Œ/xY w)Nc                   ó   — y r#   r   r   r   r   r«   zGTestGreenletSetParentErrors.test_cannot_delete_parent.<locals>.<lambda>*  r¿   r   úcan't delete attribute)
r(   rO   r   r   r   rC   rD   r8   rF   rG   )r;   rì   r$   s      r   Útest_cannot_delete_parentz5TestGreenletSetParentErrors.test_cannot_delete_parent)  sk   € Ü™\Ó*ˆØ�‰�f—m‘m¤X×%8Ñ%8Ó%:Ô;à×Ñœ~Ó.ð 	°#Ø�÷	à×Ñœ˜SŸ]™]Ó+Ð-EÕF÷	ð 	ús   ÁBÂB
c                 óÊ   — | j                  t        «      5 }t        j                  «       `d d d «       | j                  t        j                  «      d«       y # 1 sw Y   Œ/xY w)Nrå  ©rC   rD   r   r   r   r8   rF   rG   ©r;   r$   s     r   Ú!test_cannot_delete_parent_of_mainz=TestGreenletSetParentErrors.test_cannot_delete_parent_of_main1  sP   € Ø×Ñœ~Ó.ð 	-°#Ü×#Ñ#Ó%Ð,÷	-à×Ñœ˜SŸ]™]Ó+Ð-EÕF÷	-ð 	-ús   –AÁA"c                 ó^   — | j                  t        j                  «       j                  «       y r#   )rS   r   r   r   r>   s    r   Ú!test_main_greenlet_parent_is_nonez=TestGreenletSetParentErrors.test_main_greenlet_parent_is_none7  s   € à×Ñœ(×-Ñ-Ó/×6Ñ6Õ7r   c                 óÐ   ‡ — d„ }ˆ fd„}t        |«      }‰ j                  |«        ||«       |j                  «        ‰ j                  |«        ||«       |j                  «        y )Nc                  ó\   — t        j                  «       j                  j                  «        y r#   r¹   r   r   r   ÚbgzCTestGreenletSetParentErrors.test_set_parent_wrong_types.<locals>.bg<  s   € ä×ÑÓ!×(Ñ(×/Ñ/Õ1r   c                 óô   •— d d‰dfD ]b  }‰j                  t        «      5 }|| _        d d d «       ‰j                  t	        j
                  «      dt        |«      j                  z   «       Œd y # 1 sw Y   ŒGxY w)Nr   Ú42z4GreenletChecker: Expected any type of greenlet, not )rC   rÚ   r   r8   rF   rG   Útyper   )ÚgletÚpr$   r;   s      €r   ÚcheckzFTestGreenletSetParentErrors.test_set_parent_wrong_types.<locals>.check@  sy   ø€ Ø˜1˜d DÐ(ò _�Ø×&Ñ&¤yÓ1ð $°SØ"#�D”K÷$ð × Ñ Ü˜Ÿ™Ó&ØJÌTÐRSËW×M]ÑM]Ñ]õ_ñ	_÷$ð $ús    A.Á.A7	)r(   r    r   rž   )r;   rï  rõ  r)   s   `   r   Útest_set_parent_wrong_typesz7TestGreenletSetParentErrors.test_set_parent_wrong_types;  sW   ø€ ò	2ô	_ô ˜‹OˆØ×Ñ˜ÔÙˆaŒð 	
�‰Œ
Ø�‰˜ÔÙˆaŒð 	
�‰�
r   c                 óÈ   — t        d„ «      }| j                  t        «      5 }||_        d d d «       | j	                  t        j                  «      d«       y # 1 sw Y   Œ/xY w)Nc                   ó   — y r#   r   r   r   r   r«   z@TestGreenletSetParentErrors.test_trivial_cycle.<locals>.<lambda>X  r¿   r   úcyclic parent chain)r(   rC   rÍ   r   r8   rF   rG   )r;   ró  r$   s      r   Útest_trivial_cyclez.TestGreenletSetParentErrors.test_trivial_cycleW  sR   € Ü™<Ó(ˆØ×ÑœzÓ*ð 	¨cØˆDŒK÷	à×Ñœ˜SŸ]™]Ó+Ð-BÕC÷	ð 	ús   ¢AÁA!c                 óø   — | j                  t        «      5 }t        j                  «       t        j                  «       _        d d d «       | j                  t        j                  «      d«       y # 1 sw Y   Œ/xY w)Nz(cannot set the parent of a main greenletrè  ré  s     r   Útest_trivial_cycle_mainz3TestGreenletSetParentErrors.test_trivial_cycle_main]  s_   € à×Ñœ~Ó.ð 	A°#Ü+3×+>Ñ+>Ó+@ŒH×ÑÓ!Ô(÷	Aà×Ñœ˜SŸ]™]Ó+Ð-WÕX÷	Að 	Aús   –,A0Á0A9c                 ó  — t        d„ «      }t        d„ «      }t        d„ «      }||_        ||_        | j                  t        «      5 }||_        d d d «       | j	                  t        j                  «      d«       y # 1 sw Y   Œ/xY w)Nc                   ó   — y r#   r   r   r   r   r«   z?TestGreenletSetParentErrors.test_deeper_cycle.<locals>.<lambda>d  r¿   r   c                   ó   — y r#   r   r   r   r   r«   z?TestGreenletSetParentErrors.test_deeper_cycle.<locals>.<lambda>e  r¿   r   c                   ó   — y r#   r   r   r   r   r«   z?TestGreenletSetParentErrors.test_deeper_cycle.<locals>.<lambda>f  r¿   r   rù  )r(   r   rC   rÍ   r8   rF   rG   )r;   r*   rv   Úg3r$   s        r   Útest_deeper_cyclez-TestGreenletSetParentErrors.test_deeper_cyclec  st   € Ü™Ó&ˆÜ™Ó&ˆÜ™Ó&ˆàˆŒ	ØˆŒ	Ø×ÑœzÓ*ð 	¨cØˆBŒI÷	à×Ñœ˜SŸ]™]Ó+Ð-BÕC÷	ð 	ús   ÁA>Á>BN)r   r   r   rÅ  rÖ  râ  ræ  rê  rì  rö  rú  rü  r  r   r   r   r¿  r¿  Â  s<   „ òWò2'òR"òHGòGò8òò8DòYó	Dr   r¿  c                   óJ   — e Zd Z eed«      sd
d„Zd„ Zd„ Zd„ Zd„ Z	d„ Z
d	„ Zy)ÚTestReprÚassertEndsWithNc                 óL   — | j                  |j                  |«      |||f«       y r#   )rž   Úendswith)r;   r  ÚsuffixÚmsgs       r   r  zTestRepr.assertEndsWithr  s    € Ø�O‰O˜AŸJ™J vÓ.°°F¸CÐ0@ÕAr   c                 ób   — t        t        j                  «       «      }| j                  |d«       y )Nú current active started main>)Úreprr   r   r  ©r;   Úrs     r   Útest_main_while_runningz TestRepr.test_main_while_runningu  s&   € Ü”×$Ñ$Ó&Ó'ˆØ×Ñ˜AÐ>Õ?r   c                 ó’   ‡— t        j                  «       Šˆfd„}t        |«      }|j                  «       }| j	                  |d«       y )Nc                  ó   •— t        ‰ «      S r#   )r  r§  s   €r   rB   z-TestRepr.test_main_in_background.<locals>.run{  s   ø€ Ü˜“:Ðr   ú suspended active started main>)r   r   r(   r   r  )r;   rB   r)   r  rê   s       @r   Útest_main_in_backgroundz TestRepr.test_main_in_backgroundy  s>   ø€ Ü×"Ñ"Ó$ˆô	ô ˜ÓˆØ�H‰H‹JˆØ×Ñ˜AÐ@ÕAr   c                 óN   — t        t        «       «      }| j                  |d«       y )Nz	 pending>)r  r(   r  r  s     r   Útest_initialzTestRepr.test_initial‚  s   € Ü”“ÓˆØ×Ñ˜A˜{Õ+r   c                 ó&  ‡— t        j                  «       Š G ˆfd„dt        j                  «      } |«       }|j	                  «        |j                  d«       | j                  |j                  d«       | j                  |j                  d«       t        d«      D ]  }t        j                  d«       Œ t        d«      D ]N  }| j                  |j                  j                  «       t        |j                  «      }| j                  |d«       ŒP y )	Nc                   ó$   •— e Zd ZdxZZdZˆ fd„Zy)ú/TestRepr.test_main_from_other_thread.<locals>.TNc                 óŒ   •— t        ‰«      | _        t        j                  «       | _        t        | j                  «      | _        y r#   )r  Úoriginal_mainr   r   Ú	main_gletr~  )r;   rê   s    €r   rB   z3TestRepr.test_main_from_other_thread.<locals>.T.runŒ  s0   ø€ Ü%)¨$£Z�Ô"Ü!)×!4Ñ!4Ó!6�”Ü#'¨¯©Ó#7�Õ r   )r   r   r   r  r~  r  rB   r§  s   €r   ÚTr  ‰  s   ø„ Ø*.Ð.ˆM˜KØˆIõ8r   r  ri   r  r  r0   gü©ñÒMbP?z (thread exited) dead>)r   r   rl   rm   rn   ro   r  r  r~  r:   r§   r¨   rž   r  rZ   r  )r;   r  r–   rc  r  rê   s        @r   Útest_main_from_other_threadz$TestRepr.test_main_from_other_thread†  sÕ   ø€ Ü×"Ñ"Ó$ˆö	8”	× Ñ ô 	8ñ ‹CˆØ	�‰Œ	Ø	�‰ˆrŒ
à×Ñ˜AŸO™OÐ-NÔOØ×Ñ˜AŸM™MÐ+JÔKô �q“ò 	ˆAÜ�J‰J�uÕð	ô �q“ò 	=ˆAØ�O‰O˜AŸK™K×,Ñ,Ô-Ü�Q—[‘[Ó!ˆAØ×Ñ Ð#;Õ<ñ	=r   c                 ó  — t        d„ «      }|j                  «        | j                  t        |«      d«       | j	                  dt        |«      «       | j	                  dt        |«      «       | j	                  dt        |«      «       y )Nc                   ó   — y r#   r   r   r   r   r«   z$TestRepr.test_dead.<locals>.<lambda>ª  r¿   r   z dead>Ú	suspendedÚstartedÚactive)r(   r   r  r  ÚassertNotInrP   s     r   Ú	test_deadzTestRepr.test_dead©  se   € Ü™Ó%ˆØ	�‰Œ
Ø×ÑœD ›G XÔ.Ø×Ñ˜¤d¨1£gÔ.Ø×Ñ˜¤D¨£GÔ,Ø×Ñ˜¤4¨£7Õ+r   c                 óÌ   — t        d„ «      }t        d„ «      }t        j                  «       }|||fD ]0  }| j                  |›t        «       | j                  |›t        «       Œ2 y )Nc                   ó   — y r#   r   r   r   r   r«   z>TestRepr.test_formatting_produces_native_str.<locals>.<lambda>µ  r¿   r   c                   ó   — y r#   r   r   r   r   r«   z>TestRepr.test_formatting_produces_native_str.<locals>.<lambda>¶  r¿   r   )r(   r   r   ÚassertIsInstancerF   )r;   Úg_deadÚg_not_startedÚg_curr)   s        r   Ú#test_formatting_produces_native_strz,TestRepr.test_formatting_produces_native_str±  sf   € ô ™\Ó*ˆÜ#¡LÓ1ˆÜ×#Ñ#Ó%ˆà˜¨Ð-ò 		ˆAà×!Ñ!ÙÜôð ×!Ñ!ÙÜõñ		r   r#   )r   r   r   rÞ   r   r  r  r  r  r  r$  r,  r   r   r   r  r  o  s4   „ á�8Ð-Ô.ó	Bò@òBò,ò!=òF,ór   r  c                   ó   — e Zd Zd„ Zd„ Zd„ Zy)ÚTestMainGreenletc                 ó    — dt        t        j                  «       «      v sJ ‚t        t        j                  «       «      }dt        |«      vsJ ‚|S )Nrê   )r  r   r   rò  )r;   r–   s     r   Ú_check_current_is_mainz'TestMainGreenlet._check_current_is_mainÉ  sH   € àœœh×1Ñ1Ó3Ó4Ñ4Ð4Ð4ä”×$Ñ$Ó&Ó'ˆØœT !›WÑ$Ð$Ð$Øˆr   c                 ób   — | j                  «       }t        d|fi «      }| j                  |«       y )NÚsubclass)r0  rò  rN   )r;   Ú	main_typer2  s      r   Ú)test_main_greenlet_type_can_be_subclassedz:TestMainGreenlet.test_main_greenlet_type_can_be_subclassedÑ  s.   € Ø×/Ñ/Ó1ˆ	Ü˜
 Y L°"Ó5ˆØ×Ñ˜XÕ&r   c                 ót   — | j                  «        | j                  t        j                  «       t        «       y r#   )r0  r(  r   r   r(   r>   s    r   Útest_main_greenlet_is_greenletz/TestMainGreenlet.test_main_greenlet_is_greenletÖ  s'   € Ø×#Ñ#Ô%Ø×Ñœh×1Ñ1Ó3´[ÕAr   N)r   r   r   r0  r4  r6  r   r   r   r.  r.  Å  s   „ òò'ó
Br   r.  c                   ó<   — e Zd Zd„ Zd„ Zd„ Zd„ Zd„ Zd„ Zd„ Z	d„ Z
y	)
ÚTestBrokenGreenletsc                 óÌ   — d„ }t         j                  j                  |«      }d|_        | j	                  t
        d«      5  |j                  «        d d d «       y # 1 sw Y   y xY w)Nc                  ó   — t        d«      ‚)NzNever get here)ÚAssertionErrorr   r   r   rà   z<TestBrokenGreenlets.test_failed_to_initialstub.<locals>.funcá  s   € Ü Ð!1Ó2Ð2r   Tz;Failed to switch stacks into a greenlet for the first time.)r   Ú	_greenletÚUnswitchableGreenletÚforce_switch_errorÚassertRaisesRegexÚSystemErrorr   )r;   rà   r)   s      r   Útest_failed_to_initialstubz.TestBrokenGreenlets.test_failed_to_initialstubà  sY   € ò	3ô ×Ñ×3Ñ3°DÓ9ˆØ#ˆÔà×#Ñ#¤KØ$aócñ 	à�H‰HŒJ÷	÷ 	ñ 	ús   Á AÁA#c                 óº  ‡— g Šˆfd„}t         j                  j                  |«      }|j                  «        | j	                  ‰dg«       |j                  «        | j	                  ‰ddg«       d|_        | j                  t        d«      5  |j                  «        d d d «       d|_        |j                  «        | j	                  ‰g d¢«       y # 1 sw Y   Œ5xY w)Nc                  ó  •— ‰ j                  d«       t        j                  «       j                  j	                  «        ‰ j                  d«       t        j                  «       j                  j	                  «        ‰ j                  d«       y )Nr   r5   r0   r1   )Úrunss   €r   rà   zDTestBrokenGreenlets.test_failed_to_switch_into_running.<locals>.funcî  sZ   ø€ Ø�K‰K˜ŒNÜ×ÑÓ!×(Ñ(×/Ñ/Ô1Ø�K‰K˜ŒNÜ×ÑÓ!×(Ñ(×/Ñ/Ô1Ø�K‰K˜�Nr   r   r5   Tz0Failed to switch stacks into a running greenlet.F)r   r5   r0   )r   r<  r=  r   r8   r>  r?  r@  )r;   rà   r)   rD  s      @r   Ú"test_failed_to_switch_into_runningz6TestBrokenGreenlets.test_failed_to_switch_into_runningì  sº   ø€ Øˆô	ô ×Ñ×3Ñ3°DÓ9ˆØ	�‰Œ
Ø×Ñ˜ ˜sÔ#Ø	�‰Œ
Ø×Ñ˜  1˜vÔ&Ø#ˆÔà×#Ñ#¤KØ$VóXñ 	à�H‰HŒJ÷	ð  %ˆÔØ	�‰Œ
Ø×Ñ˜šyÕ)÷	ð 	ús   ÂCÃCc                 ó²   — | j                  d«      }| j                  d|j                  «       | j                  |j                  | j	                  «       «       y )Nzfail_slp_switch.pyzfail_slp_switch is running)ÚassertScriptRaisesrE   ÚoutputÚ
returncodeÚ,get_expected_returncodes_for_aborted_process©r;   Úexs     r   Ú&test_failed_to_slp_switch_into_runningz:TestBrokenGreenlets.test_failed_to_slp_switch_into_running  sA   € Ø×$Ñ$Ð%9Ó:ˆà�‰Ð2°B·I±IÔ>Ø�‰�b—m‘m T×%VÑ%VÓ%XÕYr   c                 óþ   — | j                  d«      }| j                  d|«       | j                  d|«       | j                  d|«       | j                  d|«       | j                  d|«       | j                  d|«       y )Nz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 g2©Ú
run_scriptrE   ©r;   rH  s     r   Ú#test_reentrant_switch_two_greenletsz7TestBrokenGreenlets.test_reentrant_switch_two_greenlets  sh   € à—‘Ð!?Ó@ˆØ�‰�k 6Ô*Ø�‰�g˜vÔ&Ø�‰�m VÔ,Ø�‰Ð/°Ô8Ø�‰Ð1°6Ô:Ø�‰Ð-¨vÕ6r   c                 óš   — | j                  dd¬«      }| j                  d|j                  «       | j                  d|j                  «       y )Nzfail_switch_three_greenlets.py)r   )Ú	exitcodesrÚ   zpositional arguments)rG  rE   rH  rK  s     r   Ú%test_reentrant_switch_three_greenletsz9TestBrokenGreenlets.test_reentrant_switch_three_greenlets  s@   € ð ×$Ñ$Ð%EÐQUÐ$ÓVˆà�‰�k 2§9¡9Ô-Ø�‰Ð,¨b¯i©iÕ8r   c                 óJ   — | j                  d«      }| j                  d|«       y )Nz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')]rP  rR  s     r   Ú&test_reentrant_switch_three_greenlets2z:TestBrokenGreenlets.test_reentrant_switch_three_greenlets2!  s)   € ð —‘Ð!BÓCˆØ�‰ð=ð õ		
r   c                 óJ   — | j                  d«      }| j                  d|«       y )Nz#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)]rP  rR  s     r   Ú4test_reentrant_switch_GreenletAlreadyStartedInPythonzHTestBrokenGreenlets.test_reentrant_switch_GreenletAlreadyStartedInPython3  s'   € Ø—‘Ð!FÓGˆà�‰ð1ð
 õ	
r   c                 óJ   — | j                  d«      }| j                  d|«       y )Nzfail_clearing_run_switches.pyz„RESULTS [('G.__getattribute__', 'run'), ('RunCallable', '__del__'), ('main: g.switch()', 'from RunCallable'), ('run_func', 'enter')]rP  rR  s     r   Ú*test_reentrant_switch_run_callable_has_delz>TestBrokenGreenlets.test_reentrant_switch_run_callable_has_del?  s'   € Ø—‘Ð!@ÓAˆØ�‰ðð õ	
r   N)r   r   r   rA  rE  rM  rS  rV  rX  rZ  r\  r   r   r   r8  r8  Ü  s+   „ ò
ò*ò8Zò7ò9ò
ò$

ó
r   r8  c                   óL   — e Zd Z ej                   eed«      d«      d„ «       Zy)Ú
TestModuleÚ_is_gil_enabledz,Needs 3.13 and above for sys._is_gil_enabledc                 óž   — t         r$| j                  t        j                  «       «       y | j	                  t        j                  «       «       y r#   )r   r    r   r_  rž   r>   s    r   Útest_no_gil_on_free_threadedz'TestModule.test_no_gil_on_free_threadedK  s3   € õ 'Ø×ÑœS×0Ñ0Ó2Õ3à�O‰OœC×/Ñ/Ó1Õ2r   N)r   r   r   r¼  Ú
skipUnlessrÞ   r   ra  r   r   r   r^  r^  I  s0   „ à€X×Ñ™ Ð&7Ó8ØGóIñ3óIñ3r   r^  Ú__main__)r}   r   r§   rl   r¼  Úabcr   r   r   r(   r´  r   r   r	   r
   r   Ú	leakcheckr   r„   r   r    r+   r-   r¿  r  r.  r8  r^  r   rê   r   r   r   ú<module>rf     sº   ðÛ 	Û 
Û Û Û å Ý ã Ý ,Ý Ý "Ý Ý Ý )Ý &ô	�	ô 	òòôK(�8ô K(ô\jD (ô jDôZSˆxô SôlB�xô Bô.k
˜(ô k
ôZ	3�ô 	3ð ˆzÒØ€H‡M�M…Oð r   