
    i\                         S SK r S SKrS SKrS SKrS SKrSSKJr  SSKJr  SSKJr   " S S\5      r	\
S:X  a  \R                  " 5         gg)	    N   )WIN)TestCase)_test_extension_cppc                   j    \ rS rSrS rS rS rS r\R                  " \
S5      S 5       rS rS	 rS
rg)CPPTests   c                     / n[        S5       HI  n[        R                  " [        R                  5      nUR	                  U5        UR                  U5        MK     [        U5       H%  u  p#U R                  UR	                  5       U5        M'     g )N   )rangegreenletr   test_exception_switchswitchappend	enumerateassertEqual)self	greenletsigs       I/var/www/ias/venv/lib/python3.13/site-packages/greenlet/tests/test_cpp.pyr   CPPTests.test_exception_switch   sn    	qA!!"5"K"KLAHHQKQ  i(DAQXXZ+ )    c                 b   SS K nSS KnUR                  R                  UR                  R	                  [
        5      S5      nUR                  U[        U[        5      (       d  UR                  OU/nUnU R                  [        R                  5       n[        R                  " US[        R                  S9  S S S 5        WR                  nU R!                  5       n	U R#                  UR$                  U	5        U R#                  SUR&                  5        UR&                  $ ! , (       d  f       Nn= f)Nr   zfail_cpp_exception.pyzutf-8)encodingstderrzfail_cpp_exception is running)ossyspathjoindirname__file__
executable
isinstancestr__name__assertRaises
subprocessCalledProcessErrorcheck_outputSTDOUT	exception,get_expected_returncodes_for_aborted_processassertIn
returncodeoutput)
r   targetr   r   scriptargs__traceback_info__excexexpected_exits
             r   _do_test_unhandled_exception%CPPTests._do_test_unhandled_exception   s    GGOOH%#
 z&RU?V?V\bc!z<<=## !(( > ]]IIKbmm]35ryyAyy >=s   %D  
D.c                 B    U R                  [        R                  5        g N)r8   r   test_exception_throw_nonstdr   s    r   &test_unhandled_nonstd_exception_aborts/CPPTests.test_unhandled_nonstd_exception_aborts.   s    ))*=*Y*YZr   c                 B    U R                  [        R                  5        g r;   )r8   r   test_exception_throw_stdr=   s    r   #test_unhandled_std_exception_aborts,CPPTests.test_unhandled_std_exception_aborts2   s    ))*=*V*VWr   z#XXX: This does not crash on Windowsc                 J    U R                  S5      nU R                  SU5        g )Nrun_as_greenlet_targetzThrown from an extension.)r8   r.   )r   r0   s     r   8test_unhandled_std_exception_as_greenlet_function_abortsACPPTests.test_unhandled_std_exception_as_greenlet_function_aborts6   s)     223KL
 (	
r   c                 &    U R                  S5        g )N*run_unhandled_exception_in_greenlet_aborts)r8   r=   s    r   +test_unhandled_exception_in_greenlet_aborts4CPPTests.test_unhandled_exception_in_greenlet_abortsD   s    ))*VWr   c                    S n[         R                  " 5         [        R                  " S5      n[	        S5       H7  nU R                  [        5         [        R                  " U5        S S S 5        M9     [         R                  " 5         [        R                  " S5      nXB-
  nU R                  SU5        g ! , (       d  f       M  = f)Nc                      [        S5      e)Nboom)
ValueError r   r   raiserECPPTests.test_leak_test_exception_switch_and_do_in_g2.<locals>.raiserJ   s    V$$r   r   i  r   )
gccollectobjgraphcountr   r'   rO   r   "test_exception_switch_and_do_in_g2r   )r   rQ   before_afterleakeds         r   ,test_leak_test_exception_switch_and_do_in_g25CPPTests.test_leak_test_exception_switch_and_do_in_g2I   s    	% 	


+tA"":.#FFvN /.  	

z*F# /.s   B77
C	rP   N)r&   
__module____qualname____firstlineno__r   r8   r>   rB   unittestskipIfr   rF   rJ   r\   __static_attributes__rP   r   r   r   r      sD    ,.[X __S?@

 A

X
$r   r   __main__)rS   r(   ra   r   rU    r   r   r   r   r&   mainrP   r   r   <module>rg      sD    	       !J$x J$Z zMMO r   