
    6\h?                       d dl mZ d dlZd dlmZ d dlZd dlZd dlZd dlm	Z	 d dl
Z
d dlmZ  ej        d            G d d	          Z G d
 d          Zd Zd Zd Zg de_        d Zg de_        d Zg de_        d Zg de_        d Zg de_        d Zg de_        d Zg de_        d Zd Zg de_        d Zd Zg d e_        d! Zd" Zd#ge_        d$ Z d% Z!g d&e!_        d' Z"g d(e"_        d) Z#g d*e#_        d+ Z$g d,e$_        d- Z%d. Z&g d/d0d1gd2z  z   d0d3gz   e&_         G d4 d5          Z' G d6 d7ej(                  Z)g d8Z* G d9 d:e)          Z+ej,         G d; d<e)                      Z- G d= d>ej(                  Z. G d? d@          Z/dA Z0dB Z1 G dC dDej(                  Z2 G dE dFej(                  Z3 G dG dHej(                  Z4e5dIk    r ej6                     dS dS )J    )supportN)	MagicMockwraps)import_helperT)modulec                   $    e Zd ZdZd Zd Zd ZdS )tracecontextz/Context manager that traces its enter and exit.c                 "    || _         || _        d S Noutputvalueselfr   r   s      @/opt/python-3.11.14/usr/lib/python3.11/test/test_sys_settrace.py__init__ztracecontext.__init__       


    c                 D    | j                             | j                   d S r   r   appendr   r   s    r   	__enter__ztracecontext.__enter__   s     4:&&&&&r   c                 F    | j                             | j                    d S r   r   r   exc_infos     r   __exit__ztracecontext.__exit__   s"    DJ;'''''r   N)__name__
__module____qualname____doc__r   r   r    r   r   r
   r
      sG        99  ' ' '( ( ( ( (r   r
   c                   $    e Zd ZdZd Zd Zd ZdS )asynctracecontextz>Asynchronous context manager that traces its aenter and aexit.c                 "    || _         || _        d S r   r   r   s      r   r   zasynctracecontext.__init__   r   r   c                 H   K   | j                             | j                   d S r   r   r   s    r   
__aenter__zasynctracecontext.__aenter__!   s$      4:&&&&&r   c                 J   K   | j                             | j                    d S r   r   r   s     r   	__aexit__zasynctracecontext.__aexit__$   s&      DJ;'''''r   N)r   r    r!   r"   r   r(   r*   r#   r   r   r%   r%      sG        HH  ' ' '( ( ( ( (r   r%   c                   K   | D ]}|W V  dS )z0Convert an iterable to an asynchronous iterator.Nr#   )iterablexs     r   	asynciterr.   '   s,         r   c                 <     t                      fd            }|S )Nc                     K   g fd}	  | i |d|i d {V 	 r%                                               d {V  $S S # r$                                               d {V  $w xY w)Nc                 Z    t          |           }                    |j                   |S r   )r.   r   aclose)r,   itcleanupss     r   wrapped_asynciterz;clean_asynciter.<locals>.wrapper.<locals>.wrapped_asynciter0   s)    8$$BOOBI&&&Ir   r.   pop)argskwargsr5   r4   tests      @r   wrapperz clean_asynciter.<locals>.wrapper-   s      	 	 	 	 		'tKvKK9JKKKKKKKKKK '$hllnn&&&&&&&&&  ' ' '( '$hllnn&&&&&&&&&  ' ' ' ' 's   A (A/r   )r:   r;   s   ` r   clean_asynciterr<   ,   s3    
4[[
' 
' 
' 
' [
' Nr   c                      dS N   r#   r#   r   r   basicr@   <   s    1r   )r   callr?   liner?   returnc                      d} ~ 	 d} d S r>   r#   r-   s    r   arigo_example0rI   K       	A		AAAr   )rA   rC      rD      rD      rD   rP   rF   c                      d} ~ 	 d} d S r>   r#   rH   s    r   arigo_example1rS   Y   rJ   r   c                      d} ~ 	 d} d S r>   r#   rH   s    r   arigo_example2rU   g   s    	A	 4r   )rA   rC   rK   rM      rD      rD   rY   rF   c                      d} ~ d} d S r>   r#   rH   s    r   one_instr_liner\   z   s    	A		AAAr   rA   rC   rK   rM   rN   rF   c                  <    d} t          d          D ]	}|rd} d} 
d S Nr?   rL   range)r-   as     r   no_pop_topsrd      s<    	A1XX   	AAAA	 r   )
rA   rC   rK   rM      rD   rK   rM   rV   rK   rL   rF   c                  $    d} | s	t            | 	d}d S r>   )bla)yr-   s     r   no_pop_blocksrk      s'    	A   	AAAr   rA   rC   rK   rV   rW   rF   c                  
    d} d S r>   r#   rH   s    r   calledro      s    	AAAr   c                  "    t                       d S r   )ro   r#   r   r   rB   rB      s    
HHHHHr   )rA   rC   rB   rD   rt   rF   rE   c                      t           r   	Exceptionr#   r   r   raisesry      s    
Or   c                  F    	 t                       d S # t          $ r Y d S w xY wr   )ry   rx   r#   r   r   
test_raiser{      s6       s    
  )rA   rC   rK   rq   rs   rt   	exceptionru   rL   r}   rM   rV   rm   c                 h    t          j        |            | t          j                    j        _        d S r   )syssettrace	_getframef_backf_trace	tracefuncs    r   _settrace_and_returnr      s)    L%.CMOO"""r   c                 $    t          |            d S r   )r   r   s    r   settrace_and_returnr      s    #####r   rE   c                 r    t          j        |            | t          j                    j        _        t
          r   )r   r   r   r   r   RuntimeErrorr   s    r   _settrace_and_raiser      s)    L%.CMOO"
r   c                 H    	 t          |            d S # t          $ r Y d S w xY wr   )r   r   r   s    r   settrace_and_raiser      s=    I&&&&&   s    
!!)r~   rM   rV   rm   c                  (    d} d}| |k    r| dz   }d S d S )NrP   r?   r#   )rc   bs     r   ireturn_exampler      s'    	A	AAvvaCr   rA   rC   rK   rM   rV   rm   c                  h    t          dd          } 	 d}	 | |         }|dz  }# t          $ r Y d S w xY w)Nr   rN   r?   rb   
IndexError)itemsir   s      r   tightloop_exampler      sV    !QKKE	aA!Q$!	   s   # 
11)rA   rC   rK   rM   rV   rO   rV   rO   rV   rO   rV   rO   )rP   r}   re   rX   rZ   c                  \    t          dd          } 	 d}| |         }	# t          $ r Y d S w xY w)Nr?   rW   r   r   )r   r   s     r   tighterloop_exampler     sG    !QKKE1X   s    
++)rA   rC   rK   rM   rV   rV   rV   rV   )rW   r}   rO   re   rf   rF   c               #       K   	 dV  	 d S # w xY wNTr#   r#   r   r   generator_functionr   $  s%      


					s    c                  d    t          t                                } t          d          D ]} | }d S )N
   )anyr   rb   )r-   rj   s     r   generator_exampler   *  s>      !!A 2YY   r   )
rA   rK   rB   rD   rD   r   rF   )r   rB   r   r}   rD   r   rF   rO   re   r   rQ   c                   (    e Zd ZddZd Zd Zd ZdS )TracerNc                 0    || _         || _        g | _        d S r   )trace_line_eventstrace_opcode_eventsevents)r   r   r   s      r   r   zTracer.__init__A  s    !2#6 r   c                 V    | j         | j         |_        | j        | j        |_        d S d S r   )r   f_trace_linesr   f_trace_opcodes)r   frames     r   _reconfigure_framezTracer._reconfigure_frameF  s8    !-"&"8E#/$($<E!!! 0/r   c                 |    |                      |           | j                            |j        |f           | j        S r   r   r   r   f_linenotracer   r   eventargs       r   r   zTracer.traceL  s;    &&&ENE2333zr   c                     |                      |           d dD              | j                            |j        |f           | j        S )Nc              3      K   | ]}|V  d S r   r#   ).0os     r   	<genexpr>z)Tracer.traceWithGenexp.<locals>.<genexpr>S  s"      qr   r?   r   r   s       r   traceWithGenexpzTracer.traceWithGenexpQ  sO    &&&CENE2333zr   )NN)r   r    r!   r   r   r   r   r#   r   r   r   r   @  sU           
= = =  
    r   r   c                      e Zd Zd Zd Ze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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!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/d- Z0d. Z1d/ Z2d0 Z3d1 Z4d2 Z5d3 Z6d4 Z7d5 Z8d6 Z9d7 Z:d8 Z;d9 Z<d: Z=d; Z>d< Z?d= Z@d> ZAd? ZBd@ ZCdA ZDdB ZEdC ZFeGjH        dD             ZIdE ZJeGjH        dF             ZKdG ZLdHS )ITraceTestCasec                     t          j                    | _        t          j                     |                     t
          j        t          j                               d S r   )gc	isenabledusing_gcdisable
addCleanupr   r   gettracer   s    r   setUpzTraceTestCase.setUp\  s<    

clnn55555r   c                 >    | j         rt          j                     d S d S r   )r   r   enabler   s    r   tearDownzTraceTestCase.tearDowna  s%    = 	IKKKKK	 	r   c                      t                      S )z@Helper to allow test subclasses to configure tracers differentlyr   r#   r   r   make_tracerzTraceTestCase.make_tracere  s     xxr   c           
          fd|D             }||k    rT|                      dd                    t          j        d |D             d |D                                 z              d S d S )Nc                 $    g | ]\  }}|z
  |fS r#   r#   )r   leline_offsets      r   
<listcomp>z0TraceTestCase.compare_events.<locals>.<listcomp>k  s&    <<<6Aq1{?A&<<<r   z"events did not match expectation:

c                 ,    g | ]}t          |          S r#   strr   r-   s     r   r   z0TraceTestCase.compare_events.<locals>.<listcomp>o  s    (I(I(IAQ(I(I(Ir   c                 ,    g | ]}t          |          S r#   r   r   s     r   r   z0TraceTestCase.compare_events.<locals>.<listcomp>p  s    (@(@(@AQ(@(@(@r   )failjoindifflibndiff)r   r   r   expected_eventss    `  r   compare_eventszTraceTestCase.compare_eventsj  s    <<<<V<<<_$$II5		'-(I(I(I(I(I(@(@(@(@(@B B C CCD D D D D %$r   c                     |                                  }t          j        |j                    |             t          j        d            |                     |j        j        |j        |           d S r   )r   r   r   r   r   __code__co_firstlinenor   )r   funcr   tracers       r   run_and_comparezTraceTestCase.run_and_comparer  sp    !!##V\"""TDM8"M6	3 	3 	3 	3 	3r   c                 <    |                      ||j                   d S r   )r   r   r   r   s     r   run_testzTraceTestCase.run_testz  s     T4;/////r   c                     |                                  } ||j                   t          j        d            |                     |j        j        |j        |j                   d S r   )r   r   r   r   r   r   r   r   )r   r   r   s      r   	run_test2zTraceTestCase.run_test2}  sg    !!##V\TDM8"M4;	8 	8 	8 	8 	8r   c                 X    t          j        d            t          j                    J d S r   r   r   r   r   s    r   test_set_and_retrieve_nonez(TraceTestCase.test_set_and_retrieve_none  s*    T|~~%%%%%r   c                     d }t          j        |           	 t          j                    |u sJ 	 t          j        d            d S # t          j        d            w xY w)Nc                      d S r   r#   r8   s    r   fnz4TraceTestCase.test_set_and_retrieve_func.<locals>.fn      Dr   r   )r   r   s     r   test_set_and_retrieve_funcz(TraceTestCase.test_set_and_retrieve_func  sn    	 	 	 	R	<>>R'''''LCLs   A Ac                 :    |                      t                     d S r   )r   r@   r   s    r   test_01_basiczTraceTestCase.test_01_basic  s    er   c                 :    |                      t                     d S r   )r   rI   r   s    r   test_02_arigo0zTraceTestCase.test_02_arigo0      n%%%%%r   c                 :    |                      t                     d S r   )r   rS   r   s    r   test_02_arigo1zTraceTestCase.test_02_arigo1  r  r   c                 :    |                      t                     d S r   )r   rU   r   s    r   test_02_arigo2zTraceTestCase.test_02_arigo2  r  r   c                 :    |                      t                     d S r   )r   r\   r   s    r   test_03_one_instrzTraceTestCase.test_03_one_instr  r  r   c                 :    |                      t                     d S r   )r   rk   r   s    r   test_04_no_pop_blocksz#TraceTestCase.test_04_no_pop_blocks  s    m$$$$$r   c                 :    |                      t                     d S r   )r   rd   r   s    r   test_05_no_pop_topsz!TraceTestCase.test_05_no_pop_tops  s    k"""""r   c                 :    |                      t                     d S r   )r   rB   r   s    r   test_06_callzTraceTestCase.test_06_call  s    dr   c                 :    |                      t                     d S r   )r   r{   r   s    r   test_07_raisezTraceTestCase.test_07_raise  s    j!!!!!r   c                 :    |                      t                     d S r   )r   r   r   s    r   test_08_settrace_and_returnz)TraceTestCase.test_08_settrace_and_return  s    *+++++r   c                 :    |                      t                     d S r   )r   r   r   s    r   test_09_settrace_and_raisez(TraceTestCase.test_09_settrace_and_raise  s    )*****r   c                 :    |                      t                     d S r   )r   r   r   s    r   test_10_ireturnzTraceTestCase.test_10_ireturn  s    o&&&&&r   c                 :    |                      t                     d S r   )r   r   r   s    r   test_11_tightloopzTraceTestCase.test_11_tightloop  s    '(((((r   c                 :    |                      t                     d S r   )r   r   r   s    r   test_12_tighterloopz!TraceTestCase.test_12_tighterloop  s    )*****r   c                 B   |                      t                     |                                 }t          j        |j                   t                       t          j        d            |                     t          j        j        |j	        t          j	                   d S r   )
r   r   r   r   r   r   r   r   r   r   )r   r   s     r   test_13_genexpzTraceTestCase.test_13_genexp  s    '(((
 !!##V+,,,T-6E"M+<+C	E 	E 	E 	E 	Er   c                 <    d }|                      |g d           d S )Nc                  
    d} dS )NTFr   r#   rH   s    r   onlinersz2TraceTestCase.test_14_onliner_if.<locals>.onliners  s    Q1r   )rA   rC   rM   r^   r   )r   r  s     r   test_14_onliner_ifz TraceTestCase.test_14_onliner_if  sG    	 	 	 	  	 	 	 	 	r   c                 r    d }|                      |g d           d }|                      |g d           d S )Nc                  *    t          d          D ]} d S NrL   ra   rH   s    r   for_examplez0TraceTestCase.test_15_loops.<locals>.for_example  s$    1XX   r   )rA   rC   rK   rC   rK   rC   rE   c                  0    d} | dk    r| dz  } | dk    d S d S )NrL   r   r?   r#   rH   s    r   while_examplez2TraceTestCase.test_15_loops.<locals>.while_example  s,    Aa%%Q a%%%%%%r   )rA   rK   rM   rV   rM   rV   rM   r^   r  )r   r$  r&  s      r   test_15_loopszTraceTestCase.test_15_loops  s    	 	 	 	  	 	 		 	 	
 	  		 		 		 		 		r   c                 f    i }t          d|           |                     |d         g d           d S )Na  def f():
































































































































































































































































    passf)rA   )  rD   )r*  rF   execr   )r   	namespaces     r   test_16_blank_linesz!TraceTestCase.test_16_blank_lines  sP    	3Y???cN  	 	 	 	 	r   c                 <    d }|                      |ddg           d S )Nc                  :    d t          j                    _        d} d S r#  )r   r   r   )linenos    r   r   z0TraceTestCase.test_17_none_f_trace.<locals>.func  s    &*CMOO#FFFr   rA   rC   r  r   s     r   test_17_none_f_tracez"TraceTestCase.test_17_none_f_trace  sB    	 	 	 	T	 	 	 	 	r   c                 <    d }|                      |g d           d S )Nc                  \    	 	 t           # t           $ r}  d } ~ ww xY w# t           $ r Y d S w xY wr   rw   )r   r-   rj   s      r   r   z4TraceTestCase.test_18_except_with_name.<locals>.func  sW    $#O  $ $ $$    s   
 
 
++)
rA   rC   rK   rM   rN   r}   rV   rO      rD   )	   rD   )r8  rF   r  r   s     r   test_18_except_with_namez&TraceTestCase.test_18_except_with_name  sF    		 		 		 	T	 	 	
	 
	 
	 
	 
	r   c                 <    d }|                      |g d           d S )Nc                  H    	 	 t           # d} w xY w# t           $ r d}Y d S w xY w)N	Something   rw   )rj   r   s     r   r   z7TraceTestCase.test_19_except_with_finally.<locals>.func  sE    $#O#AOOOO   s   
  !!)	rA   rC   rK   rM   r5  rO   re   rX   rZ   r  r   s     r   test_19_except_with_finallyz)TraceTestCase.test_19_except_with_finally  sF    	 	 	 	T  		 		 		 		 		r   c                      G d d          fdfd}|                                  }g d}	  ||j                   n# t          $ r Y nw xY w|                     j        j        |j        |           d S )Nc                        e Zd Zd Zd Zd ZdS )BTraceTestCase.test_20_async_for_loop.<locals>.AsyncIteratorWrapperc                 .    t          |          | _        d S r   )iter_it)r   objs     r   r   zKTraceTestCase.test_20_async_for_loop.<locals>.AsyncIteratorWrapper.__init__)  s    99r   c                     | S r   r#   r   s    r   	__aiter__zLTraceTestCase.test_20_async_for_loop.<locals>.AsyncIteratorWrapper.__aiter__,      r   c                 Z   K   	 t          | j                  S # t          $ r t          w xY wr   )nextrD  StopIterationStopAsyncIterationr   s    r   	__anext__zLTraceTestCase.test_20_async_for_loop.<locals>.AsyncIteratorWrapper.__anext__/  s:      ->>)$ - - -,,-s    *N)r   r    r!   r   rG  rM  r#   r   r   AsyncIteratorWrapperrA  (  sA        % % %  - - - - -r   rN  c                  <   K    d          2 3 d {V } | }
6 d}d S )Nabc*   r#   )letterr-   rj   rN  s      r   
doit_asyncz8TraceTestCase.test_20_async_for_loop.<locals>.doit_async5  sO       4 4U ; ;       f !<AAAs   c                                  }	 t          j        |            |                    d            t          j        d            d S # t          j        d            w xY wr   )r   r   send)r   r-   rS  s     r   runz1TraceTestCase.test_20_async_for_loop.<locals>.run:  s^    
A#V$$$tT"""""T""""s   )A A")(rA   rC   )irB   )rD   )rW  rF   irB   rD   rZ  rF   r   r   r   r   r?   r}   rK   rC   r   r   r   r   r\  rK   rC   r   r   r   r   r\  rK   rC   r   r   r   r   rr   rD   rs   r|   ru   r\  rM   r^   )r   r   rx   r   r   r   r   )r   rV  r   r   rN  rS  s       @@r   test_20_async_for_loopz$TraceTestCase.test_20_async_for_loop'  s    	- 	- 	- 	- 	- 	- 	- 	-	 	 	 	 	
	# 	# 	# 	# 	# !!##( ( (R	C 	 	 	D	J/>"M6	3 	3 	3 	3 	3s   A 
AAc                    d fd}|                                  } |            }	 t          j        |j                   |                    d            n# t
          $ r Y nw xY wt          j        d            n# t          j        d            w xY wg d}|                     |j        j        |j	        |           d S )Nc                8   K   t          |           D ]}|W V  d S r   ra   )nr   s     r   arangezGTraceTestCase.test_async_for_backwards_jump_has_no_line.<locals>.aranget  s2      1XX   r   c                  F   K    d          2 3 d {V } | dk    r d S 6 d S )NrN   d   r#   )r   rb  s    r   r)  zBTraceTestCase.test_async_for_backwards_jump_has_no_line.<locals>.fw  sU      !6!99       as77EE  %99s    )rA   rC   rq   rs   r   r   r\  rK   rC   r   rB   rs   r   r   r\  rK   rC   re  rs   r   r   r\  rK   rC   re  rs   ru   r\  rE   )
r   r   r   r   rU  rx   r   r   r   r   )r   r)  r   coror   rb  s        @r   )test_async_for_backwards_jump_has_no_linez7TraceTestCase.test_async_for_backwards_jump_has_no_lines  s    	 	 		 	 	 	 	
 !!##qss	L&&&IIdOOOO 	 	 	D	 LCL
 
 
< 	AJ5"M6	3 	3 	3 	3 	3s)   .A A= 
A%"A= $A%%A= =Bc                 <    d }|                      |g d           d S )Nc                      	 d S r   r#   r#   r   r   r   z1TraceTestCase.test_21_repeated_pass.<locals>.func  s
    Dr   rA   rC   rK   rg   r  r   s     r   test_21_repeated_passz#TraceTestCase.test_21_repeated_pass  sF    	 	 	 	T  	 	 	 	 	r   c                 <    d }|                      |g d           d S )Nc                  "    	 dD ]} dS #  Y dS xY w)Nr#   r?   rL   r#   r   s    r   r   z3TraceTestCase.test_loop_in_try_except.<locals>.func  s)    !!AAqqqs   	 r]   r  r   s     r   test_loop_in_try_exceptz%TraceTestCase.test_loop_in_try_except  sF    	 	 	 	T  	 	 	 	 	r   c                 B    fd|                      g d           d S )Nc                  D    	 	 	 	 	  j         dk    r	 n#  Y nxY wd S # w xY wNFFred)r   r   s   r   r   z8TraceTestCase.test_try_except_no_exception.<locals>.func  sI      =F** s     	rA   rC   rK   re   rX   r   rD      rD      rD   rz  rF   r  r   s    @r   test_try_except_no_exceptionz*TraceTestCase.test_try_except_no_exception  Q    	 	 	 	 	  	T  		 		 		 		 		r   c                 <    d }|                      |g d           d S )Nc                  R    	 	 	 	 t           #  Y nxY w	 n# w xY wn#  Y nxY wd S # w xY wr   rw   r#   r   r   r   z6TraceTestCase.test_try_exception_in_else.<locals>.func  sU     #O	AA
 BBBBBs(       $ $ &)rA   rC   rK   rM   rX   r6  )r7  r}   rv  rw     rD   ry  r{  r  r   s     r   test_try_exception_in_elsez(TraceTestCase.test_try_exception_in_else  sF    	 	 	  	T  	 	 	 	 	r   c                 <    d }|                      |g d           d S )Nc                  `    t          d          D ]} t          d          D ]}| |z   }|dk    S )NrL   r?   ra   )r   jrc   s      r   r   z-TraceTestCase.test_nested_loops.<locals>.func  sE    1XX  q  AAAA6Mr   )rA   rC   rK   rM   rK   rM   rK   rC   rK   rM   rK   rM   rK   rC   rV   rm   r  r   s     r   test_nested_loopszTraceTestCase.test_nested_loops   sF    	 	 	 	T  	 	 	 	 	r   c                 <    d }|                      |g d           d S )Nc                  H    ddg} | r|                                  }|rn| d}|S )Nr?   r   c   r6   )seqra  s     r   r   z)TraceTestCase.test_if_break.<locals>.func  sA    a&C GGII   
 Hr   )rA   rC   rK   rM   rV   rK   rM   rV   rO   r6  r7  rF   r  r   s     r   test_if_breakzTraceTestCase.test_if_break  sF    	 	 	 	T
 
 
	 	 	 	 	r   c                 <    d }|                      |g d           d S )Nc                      d\  } }}}	 t          d          D ]}	 d} |dk    r	 d} nd} d}# d}w xY wn	#  d}Y nxY w| dk    r|dk    r|dk    sJ d S )	N)r?   r?   r?   r  rN   rP   r   r   r7  r  r?   ra   )rc   cdr   s       r   r   z6TraceTestCase.test_break_through_finally.<locals>.func5  s    $JAq!Q
q  Aq55!  B66a2gg!q&&&0&&s    5 -5 -5 15 ;)rA   rC   rK   rM   rV   rO   re   r6  rv  rM   rV   rO   re   rX   rv     rD   r  rF   r  r   s     r   test_break_through_finallyz(TraceTestCase.test_break_through_finally3  sF    	1 	1 	1 	T  	 	 	 	 	r   c                 <    d }|                      |g d           d S )Nc                      d\  } }}}}	 t          d          D ]}	 d} |dk    r	 d}d}d}# d}w xY wn	#  d}Y nxY w| |||fdk    sJ d S )	N)r?   r?   r?   r?   r  rL   rP   r   r   r7  r  )rP   r7  r   r?   ra   )rc   r   r  r  r   s        r   r   z9TraceTestCase.test_continue_through_finally.<locals>.funcY  s    *MAq!Q
q  Aq55$  Bq!Q<=000000s    5 -5 -5 15 ;)rA   rC   rK   rM   rV   rO   re   r6  rv  rM   rV   rO   re   rX   rv  rM   r  r  r  r   s     r   test_continue_through_finallyz+TraceTestCase.test_continue_through_finallyW  sF    	1 	1 	1 	T  	 	 	 	 	r   c                 <    d }|                      |g d           d S )Nc                      	 	 dS # w xY wr#  r#   r#   r   r   r   z7TraceTestCase.test_return_through_finally.<locals>.func~  s    s   rl   r  r   s     r   test_return_through_finallyz)TraceTestCase.test_return_through_finally|  sF    	 	 	 	T  	 	 	 	 	r   c                 <    d }|                      |g d           d S )Nc                  D    	 ddz   n# t           $ r Y nw xY wdS #  Y dS xY w)NrL   r   rf   )r   r#   r   r   r   z;TraceTestCase.test_try_except_with_wrong_type.<locals>.func  sH    !    qqqqqqqqs     
  )rA   rC   rK   r~   rM   re   r   r  r   s     r   test_try_except_with_wrong_typez-TraceTestCase.test_try_except_with_wrong_type  sF    	 	 	 	T  	 	 	 	 	r   c                 <    d }|                      |g d           d S )Nc                  D    d} dg}|r|                                  | r	 d S r>   r6   TRUEr-   s     r   r   z3TraceTestCase.test_break_to_continue1.<locals>.func  s;    DA  	 r   )
rA   rC   rK   rM   rV   rO   re   rX   rM   r^   r  r   s     r   test_break_to_continue1z%TraceTestCase.test_break_to_continue1  sF    	 	 	 	T	 	 	
	 
	 
	 
	 
	r   c                 <    d }|                      |g d           d S )Nc                  L    d} dg}|r|                                  | rn|d S d S r>   r6   r  s     r   r   z3TraceTestCase.test_break_to_continue2.<locals>.func  sO    DA        r   )	rA   rC   rK   rM   rV   rO   re   rM   r^   r  r   s     r   test_break_to_continue2z%TraceTestCase.test_break_to_continue2  sF    	 	 	 	T  		 		 		 		 		r   c                 <    d }|                      |g d           d S )Nc                      d} | r| r	 d S d S r>   r#   )r  s    r   r   z/TraceTestCase.test_break_to_break.<locals>.func  s)    D   r   )rA   rC   rK   rM   rV   rO   rQ   r  r   s     r   test_break_to_breakz!TraceTestCase.test_break_to_break  sF    	 	 	 	T  	 	 	 	 	r   c                 <    d }|                      |g d           d S )Nc                  :    dx} }| dk    r|dk    rd}d S d}d S d}d S )Nr?   rW   rf   r7  r#   )rc   r   r-   rj   zs        r   r   z+TraceTestCase.test_nested_ifs.<locals>.func  s8    IAAvv66AAAAAAr   r   r  r   s     r   test_nested_ifszTraceTestCase.test_nested_ifs  sF    	 	 	 	T  	 	 	 	 	r   c                 V    fd}dxd|                      |g d           d S )Nc                  V     rrr	t           rdS d S d S dS t          r	t          rdS d S d S )NFT)DEF)ABCs   r   r   z4TraceTestCase.test_nested_ifs_with_and.<locals>.func  sk      ! ) )#(5) )) ) !5 q t   r   TFr]   r  )r   r   r  r  r  s     @@@r   test_nested_ifs_with_andz&TraceTestCase.test_nested_ifs_with_and  sk    		 		 		 		 		 		 		 AT  	 	 	 	 	r   c                 <    d }|                      |g d           d S )Nc                  d    d} 	 ddz   n$# t           $ r | dk    rt                      Y nw xY wd}d S )NhellorN   r   raiserY   )ZeroDivisionError
ValueError)r-   r)  s     r   r   z.TraceTestCase.test_nested_try_if.<locals>.func  sW    A'!$ ' ' '<<$,,&  <' AAAs   
 ++	rA   rC   rK   rM   r5  rV   rO   rX   rZ   r  r   s     r   test_nested_try_ifz TraceTestCase.test_nested_try_if	  F    	 	 	 	T  		 		 		 		 		r   c                 \     G d d          fd}|                      |g d           d S )Nc                       e Zd Zd Zd ZdS ).TraceTestCase.test_if_false_in_with.<locals>.Cc                     | S r   r#   r   s    r   r   z8TraceTestCase.test_if_false_in_with.<locals>.C.__enter__"  rH  r   c                      d S r   r#   r   s    r   r   z7TraceTestCase.test_if_false_in_with.<locals>.C.__exit__$      r   Nr   r    r!   r   r   r#   r   r   r  r  !  2              r   r  c                  P                  5  	 d d d            d S # 1 swxY w Y   d S r   r#   r  s   r   r   z1TraceTestCase.test_if_false_in_with.<locals>.func'  sx                       s   )rA   rC   r   rB   r   r   rK   rC   rq   rs   ru   rE   r  )r   r   r  s     @r   test_if_false_in_withz#TraceTestCase.test_if_false_in_with  sy    	 	 	 	 	 	 	 		 	 	 	 	
 	T
 
 
	 	 	 	 	r   c                 <    d }|                      |g d           d S )Nc                  8    	 d S # t           $ r t           Y d S w xY wr   )rx   Xr#   r   r   r   z7TraceTestCase.test_if_false_in_try_except.<locals>.func;  s7        s   rj  r  r   s     r   test_if_false_in_try_exceptz)TraceTestCase.test_if_false_in_try_except9  sF    	 	 	 	T  	 	 	 	 	r   c                 <    d }|                      |g d           d S )Nc                        G d d          } d S )Nc                   &    e Zd Zddk     rdZdS dZdS )DTraceTestCase.test_implicit_return_in_class.<locals>.func.<locals>.ArN   r8  r?   rL   N)r   r    r!   rc   r#   r   r   r  r  K  s%        q55AAAAAAr   r  r#   )r  s    r   r   z9TraceTestCase.test_implicit_return_in_class.<locals>.funcJ  s4             r   rA   rC   )r?   rB   rC   rK   rM   r^   rE   r  r   s     r   test_implicit_return_in_classz+TraceTestCase.test_implicit_return_in_classH  sF    	 	 	 	T  	 	 	 	 	r   c                 <    d }|                      |g d           d S )Nc                  \    	 	 d S # t           $ r} Y d } ~ d S d } ~ ww xY w# t           $ r Y d S w xY wr   rw   exs    r   r   z+TraceTestCase.test_try_in_try.<locals>.func\  s_    D    DDDDD   s   
  
++r]   r  r   s     r   test_try_in_tryzTraceTestCase.test_try_in_try[  sF    	 	 	 	T  	 	 	 	 	r   c                 r    d }|                      |g d           d }|                      |g d           d S )Nc                  f    	 	 t           # t          $ r} Y d } ~ d S d } ~ ww xY w# t           $ r Y d S w xY wr   )	TypeErrorr  r  s    r   r   z:TraceTestCase.test_try_in_try_with_exception.<locals>.funcn  s_    #O!   AAAAA      
 
" " 
00	rA   rC   rK   rM   r5  rV   re   rX   rZ   c                  f    	 	 t           # t           $ r} Y d } ~ d S d } ~ ww xY w# t          $ r Y d S w xY wr   r  r  r  s    r   r   z:TraceTestCase.test_try_in_try_with_exception.<locals>.func  s`    $$!   AAAAA   r  )rA   rC   rK   rM   r5  rV   rO   rQ   r  r   s     r   test_try_in_try_with_exceptionz,TraceTestCase.test_try_in_try_with_exceptionl  s    	 	 	 	T  		 		 			 	 	 	T  	 	 	 	 	r   c                 >    dd}|                      |g d           d S )Nr   r?   c                     |r
| r|rd S d S d S d S r   r#   )rc   pr  s      r   r   z/TraceTestCase.test_if_in_if_in_if.<locals>.func  s5       	  r   rj  )r   r?   r?   r  r   s     r   test_if_in_if_in_ifz!TraceTestCase.test_if_in_if_in_if  sK    	 	 	 	 	T  	 	 	 	 	r   c                      G d d          fd}fd}|                      |g d           |                      |g d           d S )Nc                       e Zd Zd Zd ZdS )-TraceTestCase.test_early_exit_with.<locals>.Cc                     | S r   r#   r   s    r   r   z7TraceTestCase.test_early_exit_with.<locals>.C.__enter__  rH  r   c                      d S r   r#   r   s    r   r   z6TraceTestCase.test_early_exit_with.<locals>.C.__exit__  r  r   Nr  r#   r   r   r  r    r  r   r  c                  Z    dD ]&}              5  	 d d d             n# 1 swxY w Y   'd S )Nr?   rL   r#   )r   r  s    r   
func_breakz6TraceTestCase.test_early_exit_with.<locals>.func_break  s      QSS                  Ds   #	#	c                  P                  5  	 d d d            d S # 1 swxY w Y   d S r   r#   r  s   r   func_returnz7TraceTestCase.test_early_exit_with.<locals>.func_return  sv                       s   )rA   rC   rK   r  r   r   rM   rK   rq   rs   ru   rV   rm   )rA   rC   )rW  rB   )rD   )r  rF   rK   rC   rX  rY  r[  rE   r  )r   r  r  r  s      @r   test_early_exit_withz"TraceTestCase.test_early_exit_with  s    	 	 	 	 	 	 	 		 	 	 	 		 	 	 	 	 	Z  	 	 	 	[
 
 
	 	 	 	 	r   c                 H    d fd}|                      |g d           d S )Nc                 >    | r	 d| dz
  z   n# t           $ r Y nw xY w| S r>   r  rH   s    r   fooz;TraceTestCase.test_flow_converges_on_same_line.<locals>.foo  sC     q1uIII(   DHs    
c                  B    t          d          D ]}  |            d S r#  ra   )r   r  s    r   r   z<TraceTestCase.test_flow_converges_on_same_line.<locals>.func  s1    1XX  A r   )rA   rC   rK   rZ  rB   irD   rs   ru   rC   rK   r  r  )r   rD   r   )r   r}   r   r]  rs   ru   rC   rE   r  )r   r   r  s     @r    test_flow_converges_on_same_linez.TraceTestCase.test_flow_converges_on_same_line  s`    	 	 		 	 	 	 	 	T  	 	 	 	 	r   c                 <    d }|                      |g d           d S )Nc                  L    d} 	 d| z   n# t           $ r}| r Y d }~nd }~ww xY wdS )Nr   r?   doner  )r-   errors     r   r   zCTraceTestCase.test_no_tracing_of_named_except_cleanup.<locals>.func  sa    A!$         6s   
 
!!r  r  r   s     r   'test_no_tracing_of_named_except_cleanupz5TraceTestCase.test_no_tracing_of_named_except_cleanup  sF    	 	 	 	T	 	 			 		 		 		 		r   c                 \     G d d          fd}|                      |g d           d S )Nc                       e Zd Zd Zd ZdS )DTraceTestCase.test_tracing_exception_raised_in_with.<locals>.NullCtxc                     | S r   r#   r   s    r   r   zNTraceTestCase.test_tracing_exception_raised_in_with.<locals>.NullCtx.__enter__  rH  r   c                     d S r   r#   )r   excinfos     r   r   zMTraceTestCase.test_tracing_exception_raised_in_with.<locals>.NullCtx.__exit__  r  r   Nr  r#   r   r   NullCtxr    r  r   r  c                  |    	               5  ddz   d d d            d S # 1 swxY w Y   d S # t           $ r Y d S w xY wNr?   r   r  )r  s   r   r   zATraceTestCase.test_tracing_exception_raised_in_with.<locals>.func  s    WYY  aCC                 $   s$   
-  - $- $- 
;;)rA   rC   rK   r  r   r   rM   r5  rK   rq   rs   ru   rV   rO   rQ   r  )r   r   r  s     @r   %test_tracing_exception_raised_in_withz3TraceTestCase.test_tracing_exception_raised_in_with  sy    	 	 	 	 	 	 	 		 	 	 	 	 	T  	 	 	 	 	r   c                 B    fd|                      g d           d S )Nc                  v    	 n!# xg ct           % x n nn X x Y ncY w xY w	 	 	  j        dk    r	 d S # w xY wrr  )rx   r   rt  s   r   r   z=TraceTestCase.test_try_except_star_no_exception.<locals>.func0  sx      I      =F**s   6 "6 8ru  r  r   s    @r   !test_try_except_star_no_exceptionz/TraceTestCase.test_try_except_star_no_exception.  r}  r   c                 <    d }|                      |g d           d S )Nc                  d    	 n'# xg ct           % x} d } ~ nd } ~  nn X x Y ncY w xY w	 d S # w xY wr   rw   r   s    r   r   zCTraceTestCase.test_try_except_star_named_no_exception.<locals>.funcM  sf      I     s   - '	- /)rA   rC   rK   re   r6  r  r  r   s     r   'test_try_except_star_named_no_exceptionz5TraceTestCase.test_try_except_star_named_no_exceptionK  sF    	 	 	 	T  	 	 	 	 	r   c                 <    d }|                      |g d           d S )Nc                  r    	 t          d          # xg ct           % x n nn X x Y ncY w xY wd S # w xY wr#  r  r#   r   r   r   zATraceTestCase.test_try_except_star_exception_caught.<locals>.funca  sc     mm#  J    
 s    /4 6rA   rC   rK   r~   rM   rV   r6  r  r  r   s     r   %test_try_except_star_exception_caughtz3TraceTestCase.test_try_except_star_exception_caught_  F    	 	 	 	T  	 	 	 	 	r   c                 <    d }|                      |g d           d S )Nc                  ~    	 t          d          # xg ct           % x} d } ~ nd } ~  nn X x Y ncY w xY wd S # w xY wr#  r  r  s    r   r   zGTraceTestCase.test_try_except_star_named_exception_caught.<locals>.funcw  sl     mm#  J    
 s    5: <r  r  r   s     r   +test_try_except_star_named_exception_caughtz9TraceTestCase.test_try_except_star_named_exception_caughtu  r  r   c                 <    d }|                      |g d           d S )Nc                      	 	 t          d          # xg ct          % x n nn X x Y d S cY w xY w# t           $ r Y d S w xY wNrN   r  r#   r   r   r   zETraceTestCase.test_try_except_star_exception_not_caught.<locals>.func  s    $Q--'  	    A       s    14 4 
AAr  r  r   s     r   )test_try_except_star_exception_not_caughtz7TraceTestCase.test_try_except_star_exception_not_caught  r  r   c                 <    d }|                      |g d           d S )Nc                      	 	 t          d          # xg ct          % x} d } ~ nd } ~  nn X x Y d S cY w xY w# t           $ r Y d S w xY wr  r  r  s    r   r   zKTraceTestCase.test_try_except_star_named_exception_not_caught.<locals>.func  s    $Q--'  	    AAAA       s    7: : 
AAr  r  r   s     r   /test_try_except_star_named_exception_not_caughtz=TraceTestCase.test_try_except_star_named_exception_not_caught  r  r   c                 <    d }|                      |g d           d S )Nc                     	 	 t          dt          d          t          d          g          # xg ct          % x} d } ~ nd } ~  nn t          % x n nn t          % x   n X x Y ncY w xY wnh# xg ct          % xM 	 t          d          # xg ct          % x n nn t          % x} d } ~ nd } ~  nn X x Y ncY w xY wn nn X x Y ncY w xY wdS )NegrP   zbad typerz  r   )ExceptionGroupr  r  OSErrorr  s    r   r   z7TraceTestCase.test_try_except_star_nested.<locals>.func  s   	(#A	*(=(=>@ @ @  	    AAAA    A"      J    #B--'      B!    BBBB 1s9   ,/ 4A2#A$	$	A2-A6 6CB/CC	C)rA   rC   rK   rM   rV   rO   rM   r5  re   rX   r6  rv  rw  r  r  ry  )rz  r}   )   rD   )   rD   )   rD   )   rD   )r(  rF   r  r   s     r   test_try_except_star_nestedz)TraceTestCase.test_try_except_star_nested  sF    	 	 	* 	T  	 	 	 	 	r   c                 <    d }|                      |g d           d S )Nc                      	 d  d S )Nc                     dS r#  r#   rH   s    r   <lambda>zATraceTestCase.test_notrace_lambda.<locals>.func.<locals>.<lambda>  s    a r   r#   r#   r   r   r   z/TraceTestCase.test_notrace_lambda.<locals>.func  s    KKAr   r]   r  r   s     r   test_notrace_lambdaz!TraceTestCase.test_notrace_lambda  sF    	 	 	
 	T  	 	 	 	 	r   c                 <    d }|                      |g d           d S )Nc                        G d d          } d S )Nc                       e Zd ZdZd ZdS )PTraceTestCase.test_class_creation_with_docstrings.<locals>.func.<locals>.Class_1z the docstring. 2c                     d| _         dS )z Another docstring. 4rP   N)rc   r   s    r   r   zYTraceTestCase.test_class_creation_with_docstrings.<locals>.func.<locals>.Class_1.__init__  s    DFFFr   N)r   r    r!   r"   r   r#   r   r   Class_1r2    s)        ''    r   r4  r#   )r4  s    r   r   z?TraceTestCase.test_class_creation_with_docstrings.<locals>.func  s4             r   r  r  r   s     r   #test_class_creation_with_docstringsz1TraceTestCase.test_class_creation_with_docstrings  sF    	 	 	 	T  	 	 	 	 	r   c                 @   t          j        d          }d fd}g d}g }|                    |            |             t          j        d            |j        j        fd|D             }|                     ||           |                     ||           d S )N	_testcapic               3      K   dV  d S r>   r#   r#   r   r   genzFTraceTestCase.test_no_line_event_after_creating_generator.<locals>.gen  s      GGGGGr   c                  "                 D ]} d S r   r#   )_r9  s    r   r   zGTraceTestCase.test_no_line_event_after_creating_generator.<locals>.func  s'       r   )rA   rK   rC   rq   rs   ru   rV   rC   )rt   rB   ru   rE   c                 <    g | ]\  }}}|z
  t           |         fS r#   )EVENT_NAMES)r   whatrD   r   
start_lines       r   r   zMTraceTestCase.test_no_line_event_after_creating_generator.<locals>.<listcomp>,  s=     
 
 
!tS *_k$/0
 
 
r   )	r   import_modulesettrace_to_recordr   r   r   r   assertEqualr   )r   r7  r   EXPECTED_EVENTSr   r9  r?  s        @@r   +test_no_line_event_after_creating_generatorz9TraceTestCase.test_no_line_event_after_creating_generator  s    
 "/<<		 	 		 	 	 	 	
 
 
  $$V,,,ddfffcl46H6H6H]1

 
 
 
%+
 
 
 	111T?33333r   c                    dfd}	 |t          j                    _        t          j        |           t	          g            |                     d           n|# t          $ ro}d}|j        }|r#|j        j	        j
        dk    r|dz  }|j        }|#|dk    r|                     d           n|dk    r|                     d           Y d }~nd }~ww xY wt          j        d            d S # t          j        d            w xY w)	NFc                 (    s	dt           t          S r   )rx   r  )r   r   r   raiseds      r   
error_oncez5TraceTestCase.test_settrace_error.<locals>.error_once7  s      Lr   No exception raisedr   test_settrace_errorr?   Traceback is missing frame"Traceback has frame more than once)r   r   r   r   lenr   rx   __traceback__tb_framef_codeco_nametb_next)r   rH  r  counttbrG  s        @r   rJ  z!TraceTestCase.test_settrace_error4  s?   	 	 	 	 		&0CMOO#L$$$GGG II+,,,,  
	@ 
	@ 
	@E!B  ;%-1FFFQJEZ    zz		67777		>???
	@ LCLs0   ;A C- 
C%A%C
C- CC- -Dc                    t          j        d          }	 |                    g            t          g            |                     d           n|# t
          $ ro}d}|j        }|r#|j        j        j	        dk    r|dz  }|j
        }|#|dk    r|                     d           n|dk    r|                     d           Y d }~nd }~ww xY wt          j        d            d S # t          j        d            w xY w)Nr7  rI  r   test_testcapi_settrace_errorr?   rK  rL  )r   r@  settrace_to_errorrM  r   rx   rN  rO  rP  rQ  rR  r   r   )r   r7  r  rS  rT  s        r   rV  z*TraceTestCase.test_testcapi_settrace_errorR  s(    "/<<		''+++GGG II+,,,,  
	@ 
	@ 
	@E!B  ;%-1OOOQJEZ    zz		67777		>???
	@ LCLs/   $A C" 
C	A%C?C" C		C" "C8c                 |    i }t          dddz  d|           |d         }g d}|                     ||           d S )Nzdef f():              # line 0
            x = 0                     # line 1
            y = 1                     # line 2
            r   i   zn                        # lines 3 through (1 << 16)
            x += 1                    #
            returnr)  )rA   rC   rK   )i  rD   )  rD   )rY  rF   r+  )r   r  r)  rC  s       r   test_very_large_functionz&TraceTestCase.test_very_large_functionk  so    
 ))),
 ./	0 	0 	0 cF
 
 
 	Q00000r   N)Mr   r    r!   r   r   staticmethodr   r   r   r   r   r   r   r   r   r  r  r  r	  r  r  r  r  r  r  r  r  r  r   r'  r.  r2  r9  r>  r^  rg  rk  ro  r|  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r)  r.  r5  r   cpython_onlyrD  rJ  rV  rZ  r#   r   r   r   r   X  s}       6 6 6
     \D D D3 3 30 0 08 8 8& & &    & & && & && & && & &% % %# # #  " " ", , ,+ + +' ' ') ) )+ + +E E E
 
 
  >      0  *J3 J3 J3X23 23 23h	 	 	  "  :  @  4  2" " "H# # #J    &  .  .  $  (  .  ,  4    &  "' ' 'R  ", , ,\" " "H  ,  @  :  (  ,  ,  ,  ,- - -^    & )4 )4 )4V  <   01 1 1 1 1r   r   )rB   r}   rD   rF   c                   8     e Zd ZdZ fdZed             Z xZS )SkipLineEventsTraceTestCasez8Repeat the trace tests, but with per-line events skippedc                 f    d |D             }t                                          |||           d S )Nc                 *    g | ]}|d          dk    |S rC   r#   r   r   s     r   r   z>SkipLineEventsTraceTestCase.compare_events.<locals>.<listcomp>  s!    III!!A$&..A...r   )superr   )r   r   r   r   skip_line_events	__class__s        r   r   z*SkipLineEventsTraceTestCase.compare_events  s:    IIIII{F4DEEEEEr   c                  "    t          d          S )NF)r   r   r#   r   r   r   z'SkipLineEventsTraceTestCase.make_tracer  s    ....r   r   r    r!   r"   r   r[  r   __classcell__rd  s   @r   r^  r^    s^        BBF F F F F / / \/ / / / /r   r^  c                   8     e Zd ZdZ fdZed             Z xZS )TraceOpcodesTestCasez;Repeat the trace tests, but with per-opcodes events enabledc                     d |D             }t          |          dk    r2|                     t          |          t          |          d           t                                          |||           d S )Nc                 *    g | ]}|d          dk    |S )r?   opcoder#   ra  s     r   r   z7TraceOpcodesTestCase.compare_events.<locals>.<listcomp>  s&    DDDA1Q483C3Ca3C3C3Cr   r?   z)No 'opcode' events received by the tracer)msg)rM  
assertLessrb  r   )r   r   r   r   skip_opcode_eventsrd  s        r   r   z#TraceOpcodesTestCase.compare_events  s}    DDDDDv;;??OOC 233S[[ K  M M M{,>PPPPPr   c                  "    t          d          S )NT)r   r   r#   r   r   r   z TraceOpcodesTestCase.make_tracer  s    $////r   rf  rh  s   @r   rj  rj    s^        EEQ Q Q Q Q 0 0 \0 0 0 0 0r   rj  c                   P    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S )RaisingTraceFuncTestCasec                 h    |                      t          j        t          j                               d S r   r   r   r   r   r   s    r   r   zRaisingTraceFuncTestCase.setUp  s$    clnn55555r   c                 4    || j         k    rt          | j        S )zXA trace function that raises an exception in response to a
        specific trace event.)raiseOnEventr  r   r   s       r   r   zRaisingTraceFuncTestCase.trace  s      D%%%:r   c                 .    | j         dk    r	d}d|z  }dS dS )zThe function to trace; raises an exception if that's the case
        we're testing, so that the 'exception' trace event fires.r}   r   r?   N)rw  )r   r-   rj   s      r   r)  zRaisingTraceFuncTestCase.f  s)     ++A!AAA1r   c                 T   || _         	 t          t          j                    dz             D ]U}t          j        | j                   	 |                                  |                     d           F# t          $ r Y Rw xY wdS # t          $ r |                     d           Y dS w xY w)zTTests that an exception raised in response to the given event is
        handled OK.r?   zexception not raised!zrecursion counter not resetN)
rw  rb   r   getrecursionlimitr   r   r)  r   r  r   )r   r   r   s      r   run_test_for_eventz+RaisingTraceFuncTestCase.run_test_for_event  s     "
	53022Q677 7 7TZ(((7FFHHH II56666 "   D	7 7  	5 	5 	5II3444444	5s5   >B A2B 2
A?<B >A??B B'&B'c                 0    |                      d           d S )NrB   r{  r   s    r   	test_callz"RaisingTraceFuncTestCase.test_call      '''''r   c                 0    |                      d           d S NrD   r}  r   s    r   	test_linez"RaisingTraceFuncTestCase.test_line  r  r   c                 0    |                      d           d S )NrF   r}  r   s    r   test_returnz$RaisingTraceFuncTestCase.test_return  s    )))))r   c                 0    |                      d           d S Nr}   r}  r   s    r   test_exceptionz'RaisingTraceFuncTestCase.test_exception  s    ,,,,,r   c                     d fdt          j                   	               |                     d           d S # t          $ r dd l} |j                     Y d S w xY w)Nc                  H    t          d          D ]} t          |            d S )NrP   )rb   printrn  s    r   r)  z4RaisingTraceFuncTestCase.test_trash_stack.<locals>.f  s.    1XX  a r   c                 b    |dk    r'| j         j        j        dz   k    rt          d          S )NrD   rL   zi am crashing)r   r   r   r   )r   whyextrar)  gs      r   r  z4RaisingTraceFuncTestCase.test_trash_stack.<locals>.g  s6    v!*";a"???"?333Hr   zexception not propagatedr   )r   r   r   r   r   collect)r   r   r)  r  s     @@r   test_trash_stackz)RaisingTraceFuncTestCase.test_trash_stack  s    	 	 		 	 	 	 	 	 	Q	2ACCC II011111  	 	 	IIIBJLLLLLL	s   
A A#"A#c                      d } fdt          j                    }	 t          j                   	  |             n# t          $ r Y nw xY wt          j        |           d S # t          j        |           w xY w)Nc                      d} | j          d S )Nr   )no_such_attrrH   s    r   r)  z<RaisingTraceFuncTestCase.test_exception_arguments.<locals>.f  s    ANNNNr   c                 V    |dk    r!|\  }}}                     |t                     S r  )assertIsInstancerx   )r   r   r   typer}   r   r  r   s         r   r  z<RaisingTraceFuncTestCase.test_exception_arguments.<locals>.g  s5    $$),&i%%i;;;Hr   )r   r   r   AttributeError)r   r)  existingr  s   `  @r   test_exception_argumentsz1RaisingTraceFuncTestCase.test_exception_arguments  s    	 	 		 	 	 	 	 	 <>>	#LOOO!    L"""""CL""""s-   A& 
A  A&  
A
A& AA& &A<c                    t          d          fdd }|                     t                     5 }t          j                    |             d d d            n# 1 swxY w Y   |                     |j                   d S )NzBOOM!c                 &    |dk    rd| _         S )NrD   T)r   )r   r   r   r}   r   s      r   r   zRRaisingTraceFuncTestCase.test_line_event_raises_before_opcode_event.<locals>.trace  s    $(E!Lr   c                      d S r   r#   r#   r   r   r)  zNRaisingTraceFuncTestCase.test_line_event_raises_before_opcode_event.<locals>.f  r   r   )r  assertRaisesr   r   assertIsr}   )r   r)  caughtr}   r   s      @@r   *test_line_event_raises_before_opcode_eventzCRaisingTraceFuncTestCase.test_line_event_raises_before_opcode_event  s    w''		 	 	 	 	 	
	 	 	z** 	fLACCC	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	f&	22222s   A  A$'A$N)r   r    r!   r   r   r)  r{  r~  r  r  r  r  r  r  r#   r   r   rs  rs    s        6 6 6    5 5 5"( ( (( ( (* * *- - -2 2 2,# # #,3 3 3 3 3r   rs  c                   $    e Zd ZdZ	 	 ddZd ZdS )
JumpTracerz>Defines a trace function that jumps from one place to another.rD   Fc                     |j         | _        || _        || _        || _        |rd n| j        j        | _        d| _        d S )NF)r   codejumpFromjumpTor   r   	firstLiner  )r   functionr  r  r   	decorateds         r   r   zJumpTracer.__init__  sA    %	 
!*H	0H			r   c                    | j         rd S | j        %|j        | j        k    r|dk    r|j        dz
  | _        || j        k    r| j        |j        | j        | j        z   k    rh|}|)|j        | j        k    r|j        }||j        | j        k    |9	 | j        | j        z   |_        n# t          $ r | j        |_        Y nw xY wd| _         | j
        S )NrD   r?   T)r  r  rP  r  r   r   r  r   r  r  r   )r   r   r   r   r)  s        r   r   zJumpTracer.trace   s    9 	F
 N"u|ty'@'@"^a/DNTZDN$>$.4="@@@A-AH	$9$9H -AH	$9$9}1%)^dk%AENN  1 1 1%)[ENNN1 	zs   B% %B>=B>N)rD   F)r   r    r!   r"   r   r   r#   r   r   r  r    sC        HH9?        r   r  c                     	 |                      d           d S # t          $ r/}|                      dt          |          v            Y d }~d S d }~ww xY w)NrL   integer)r   r  r   r   r   s     r   no_jump_to_non_integersr  :  sm    +a + + +i3q66)*********+s    
A$AAc                      	 t          j                    j        } | j        | _        t	          d          # t
          $ r}dt          |          vr Y d }~d S d }~ww xY w)Nz'Trace-function-less jump failed to failr   )r   r   r   r   AssertionErrorr  r   )previous_framer   s     r   no_jump_without_trace_functionr  B  s}    
H/"0"9 FGGG     #a&&   !     s   $5 
AAAc                      e Zd Zd Zd Z	 	 ddZ	 	 ddZddZdd	Z ed
ddg          d             Z	 edd
g d          d             Z
 ed
ddg          d             Z eddg d          d             Z ed
ddg          d             Z eddg d          d             Z eddddg          d             Z edd
g d          d             Z eddddg          ed                         Z eddg d          ed                         Z ed
ddg          d             Z eddg d           d!             Z edd"dd"g          d#             Z edd$dd$ged%f          d&             Z edd'dd'ged%f          d(             Z edd'ddged)f          d*             Z eddd
ged+f          d,             Z eddddg          d-             Z eddg d.          d/             Z eddd
dg          d0             Z eddd
dg          d1             Z  edd
g d2          d3             Z! edd
g d2          d4             Z" edddg          d5             Z# edd
g d6          d7             Z$ edddg          d8             Z% edd
g d9          d:             Z& edd$g d;          d<             Z' edd$g d;          d=             Z( eddg d>          d?             Z) edd
g d@          dA             Z* eddg dB          dC             Z+ eddg dB          dD             Z, eddg dE          dF             Z- eddg dE          dG             Z. eddg dH          dI             Z/ eddg dH          dJ             Z0 eddg dK          dL             Z1 eddg dK          dM             Z2 edNd'g dO          dP             Z3 eddg dQ          dR             Z4 eddg dQ          dS             Z5 eddg dT          dU             Z6 eddNg dV          dW             Z7 ed
d$d$dNg          dX             Z8 ed
d$d$dNg          dY             Z9 eddd
ged+f          dZ             Z: edd[d
ged\f          d]             Z; edddged^f          d_             Z< edddged^f          d`             Z= edddged^f          da             Z> edddged^f          db             Z? ed
dg edcf          dd             Z@ ed
dg edcf          de             ZA eddddgedcf          df             ZB eddddgedgf          dh             ZC ed
dg edif          dj             ZD ed
dg edif          dk             ZE eddg dledif          dm             ZF eddg dledif          dn             ZG ed
dddg          do             ZH eddg dp          dq             ZI ed
ddg          dr             ZJ eddg ds          dt             ZK edd$g d;          du             ZL ed
ddg          dv             ZM eddg dw          dx             ZN edd
g dy          dz             ZO ed
dg ed{f          d|             ZP ed
dg ed{f          d}             ZQ eddg d~ed{f          d             ZR edddged{f          d             ZS ed$d
g d          d             ZT ed$d
g d          d             ZU eddg d          d             ZV eddg d          d             ZW edd$ddged+f          d             ZX ed$dd
dgedcf          d             ZY ed$dd
dgedcf          d             ZZd Z[d Z\d Z]d Z^ eddd
gdedf          d             Z_ edd
d
gdedf          d             Z` edd
d
gd)edf          d             Za eddddgd          d             Zb eddd
dg          d             Zc edd
g           d             Zd edNdg d          d             Ze eddd
dg          d             Zf edd
g           d             Zg edNdg d          d             Zh edd$g edif          d             Zi eddNg edif          d             Zj edd$g edif          d             Zk eddd
dg          d             Zl eddg d          d             Zm enjo        d          d             Zp eddd
dg          d             ZqdS )JumpTestCasec                     |                      t          j        t          j                               t          j        d            d S r   ru  r   s    r   r   zJumpTestCase.setUpQ  4    clnn555Tr   c                     ||k    r=|                      dt          |          z   dz   dz   t          |          z              d S d S )NzOutputs don't match:
Expected: r   z
Received: )r   repr)r   expectedreceiveds      r   compare_jump_outputz JumpTestCase.compare_jump_outputU  sf    xII $&*8nn57;<#$&*8nn5 6 6 6 6 6  r   NrD   Fc                 ~   |}t          |d          r|j        }t          |d          t          |||||          }	t          j        |	j                   g }
| ||
           n- | j        | 5   ||
           d d d            n# 1 swxY w Y   t          j        d            |                     ||
           d S N__wrapped__)hasattrr  r  r   r   r   assertRaisesRegexr  r   r   r  r  r  r  r   r  wrappedr   r   s              r   r   zJumpTestCase.run_test[  s   g}-- 	*)G g}-- 	* GXvuiHHV\"""=DLLLL''/  V              T  622222s   0BBBc                    |}t          |d          r|j        }t          |d          t          |||||          }	t          j        |	j                   g }
|t          j         ||
                     n? | j        | 5  t          j         ||
                     d d d            n# 1 swxY w Y   t          j        d            t          j	        d            | 
                    ||
           d S r  )r  r  r  r   r   r   asynciorV  r  set_event_loop_policyr  r  s              r   run_async_testzJumpTestCase.run_async_testl  s=   g}-- 	*)G g}-- 	* GXvuiHHV\"""=KV%%%%''/ * *DDLL)))* * * * * * * * * * * * * * *T%d+++  622222s   B,,B03B0c                 "      fd}|S )zqDecorator that creates a test that makes a jump
        from one place to another in the following code.
        c                 H     t                      fd            }|S )Nc           	      @    |                      d           d S NT)r  r   r  )r   r   r  r   r  r   r  r  s    r   r:   z7JumpTestCase.jump_test.<locals>.decorator.<locals>.test  s<    dHfh$)$  H H H H Hr   r   r   r:   r  r   r  r  r  s   ` r   	decoratorz)JumpTestCase.jump_test.<locals>.decorator  W    4[[H H H H H H H H H [H Kr   r#   r  r  r  r  r   r  s   ````` r   	jump_testzJumpTestCase.jump_test~  <    	 	 	 	 	 	 	 	 	 r   c                 "      fd}|S )z~Decorator that creates a test that makes a jump
        from one place to another in the following asynchronous code.
        c                 H     t                      fd            }|S )Nc           	      @    |                      d           d S r  )r  r  s    r   r:   z=JumpTestCase.async_jump_test.<locals>.decorator.<locals>.test  s>    ##D(FH$)$ $ H H H H Hr   r   r  s   ` r   r  z/JumpTestCase.async_jump_test.<locals>.decorator  r  r   r#   r  s   ````` r   async_jump_testzJumpTestCase.async_jump_test  r  r   r?   rN   c                     |                      d           |                      d           |                      d           d S Nr?   rL   rN   r   r   s    r   test_jump_simple_forwardsz&JumpTestCase.test_jump_simple_forwards  >    aaar   rL   )r?   r?   rL   c                 Z    |                      d           |                      d           d S r`   r  r  s    r   test_jump_simple_backwardsz'JumpTestCase.test_jump_simple_backwards  ,    aar   rW   rP   c                 f    d }||                      d           d S |                      d           d S NrN   rP   r  r   r-   s     r   test_jump_is_none_forwardsz'JumpTestCase.test_jump_is_none_forwards  s<    9MM!MM!r   rf   )rN   rP   rf   c                     d }||                      d           n|                      d           |                      d           d S NrN   rP   rf   r  r  s     r   test_jump_is_none_backwardsz(JumpTestCase.test_jump_is_none_backwards  sK    9MM!MM!ar   c                 f    d }||                      d           d S |                      d           d S r  r  r  s     r   test_jump_is_not_none_forwardsz+JumpTestCase.test_jump_is_not_none_forwards  s<    =MM!MM!r   )rP   rP   rf   c                     d }||                      d           n|                      d           |                      d           d S r  r  r  s     r   test_jump_is_not_none_backwardsz,JumpTestCase.test_jump_is_not_none_backwards  sK    =MM!MM!ar   c                     dD ]1}|                      d           dD ]}|                      d           2|                      d           d S )Nr  rL   rN   rW   rP   r  r   r   r  s      r   test_jump_out_of_block_forwardsz,JumpTestCase.test_jump_out_of_block_forwards  sd     	! 	!AMM! ! !a    !ar   )r?   rN   rP   r?   rN   rP   rf   rY   c                     |                      d           dD ]F}|                      d           dD ]}|                      d           |                      d           G|                      d           d S )Nr?   r   rN   )rL   rP   rf   rY   r  r  s      r    test_jump_out_of_block_backwardsz-JumpTestCase.test_jump_out_of_block_backwards  s    a 	 	AMM! ! !a    MM!ar   c                    K   dD ]W} |ddg          2 3 d {V }|                      d           |                      d           26 |                      d           Xd S )Nr   r?   rL   rN   rW   rP   r  r   r.   r   s      r   )test_jump_out_of_async_for_block_forwardsz6JumpTestCase.test_jump_out_of_async_for_block_forwards  s        	 	A$9aV,, ! ! ! ! ! ! !aa   a     - MM!		 	s   A)rL   rW   rL   rW   rP   rf   c                    K   dD ]k}|                      d            |dg          2 3 d {V }|                      d           |                      d           26 |                      d           ld S )Nr   rL   r?   rW   rP   rf   r  r  s      r   *test_jump_out_of_async_for_block_backwardsz7JumpTestCase.test_jump_out_of_async_for_block_backwards  s        	 	AMM!$9aS>> ! ! ! ! ! ! !aa   a     * MM!	 	s   Ac                 Z    |                      d           |                      d           d S )Nr?   rN   r  r  s    r   test_jump_to_codeless_linez'JumpTestCase.test_jump_to_codeless_line  s,    aar   )r?   rL   rN   c                     |                      d           |                      d           |                      d           d S r  r  r  s    r   test_jump_to_same_linez#JumpTestCase.test_jump_to_same_line  r  r   r8  c                    	 |                      d           |                      d           	 |                      d           |                      d           n# |                      d           w xY w|                      d           d S # |                      d           	 |                      d           |                      d           n# |                      d           w xY w|                      d           w xY w)NrL   rW   rf   r7  r8  r  r  s    r   test_jump_in_nested_finallyz(JumpTestCase.test_jump_in_nested_finally  s    	MM!MM!!a   a    a    MM! MM!!a   a    a    MM!s.   B	 A A/	C; C5C;C""C;rY    c                     	 |                      d           ddz   	 |                      d           |                      d           d S # |                      d           |                      d           w xY w)NrL   r?   r   rf   rY   r  r  s    r   test_jump_in_nested_finally_2z*JumpTestCase.test_jump_in_nested_finally_2  s|    	MM!aCCMM!MM! MM!MM!s   A	 	,A5rx  c                    	 |                      d           ddz   	 |                      d           	 |                      d           |                      d           n# |                      d           w xY w|                      d           d S # |                      d           	 |                      d           |                      d           n# |                      d           w xY w|                      d           w xY w)NrL   r?   r   rf   r7  r   rx  r  r  s    r   test_jump_in_nested_finally_3z*JumpTestCase.test_jump_in_nested_finally_3  s   
	MM!aCCMM!"a   b!!!!b!!!!MM" MM!"a   b!!!!b!!!!MM"s.   B A A5D&C;DC((Dr}   c                     	 |                      d           |                      d           |                      d           d S # |                      d           |                      d            Y d S xY wNrL   rW   rP   r  r  s    r   5test_no_jump_over_return_try_finally_in_finally_blockzBJumpTestCase.test_no_jump_over_return_try_finally_in_finally_block  s{    
	MM!MM!MM!F MM!MM!FFF
 DD   A ,A2afterc                 Z    |                      d           	 |                      d           )Nr?   TrN   r  r  s    r    test_no_jump_infinite_while_loopz-JumpTestCase.test_no_jump_infinite_while_loop,  s0    a	MM!	r   c                     d}|                      d           |dk    r"|                      d           |dz  }|dk     d S d S )Nr?   rL   rW   r  r   r   s     r   #test_jump_forwards_into_while_blockz0JumpTestCase.test_jump_forwards_into_while_block3  sP    a1ffMM!FA 1ffffffr   )rN   rN   rN   rP   c                     d}|dk    r |                      d           |dz  }|dk     |                      d           d S )Nr?   rL   rN   rP   r  r  s     r   $test_jump_backwards_into_while_blockz1JumpTestCase.test_jump_backwards_into_while_block;  sP    1ffMM!FA 1ff 	ar   c                     t          | d          5  |                     d           d d d            n# 1 swxY w Y   |                     d           d S r  r
   r   r  s    r   $test_jump_forwards_out_of_with_blockz1JumpTestCase.test_jump_forwards_out_of_with_blockC      &!$$ 	 	MM!	 	 	 	 	 	 	 	 	 	 	 	 	 	 	a   377c                    K   t          | d          4 d {V  |                     d           d d d           d {V  n# 1 d {V swxY w Y   |                     d           d S r  r%   r   r  s    r   *test_jump_forwards_out_of_async_with_blockz7JumpTestCase.test_jump_forwards_out_of_async_with_blockI        $VQ// 	 	 	 	 	 	 	 	MM!	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	a   A
AA)r?   rL   r?   rL   rN   rt   c                     |                      d           t          | d          5  |                      d           d d d            d S # 1 swxY w Y   d S r  r   r
   r  s    r   %test_jump_backwards_out_of_with_blockz2JumpTestCase.test_jump_backwards_out_of_with_blockO      a&!$$ 	 	MM!	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	   A		AAc                    K   |                      d           t          | d          4 d {V  |                      d           d d d           d {V  d S # 1 d {V swxY w Y   d S r  r   r%   r  s    r   +test_jump_backwards_out_of_async_with_blockz8JumpTestCase.test_jump_backwards_out_of_async_with_blockU        a$VQ// 	 	 	 	 	 	 	 	MM!	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	   A
A!$A!c                     	 |                      d           |                      d           n# |                      d           w xY w|                      d           d S r  r  r  s    r   +test_jump_forwards_out_of_try_finally_blockz8JumpTestCase.test_jump_forwards_out_of_try_finally_block[  ^    	MM!MM!FMM!a	   - A)r?   r?   rN   rP   c                     |                      d           	 |                      d           |                      d           d S # |                      d           w xY wNr?   rN   rP   r  r  s    r   ,test_jump_backwards_out_of_try_finally_blockz9JumpTestCase.test_jump_backwards_out_of_try_finally_blockc  [    a	MM!MM!FMM!   A Ac                     	 |                      d           n#  |                      d            xY w|                      d           d S NrL   rW   rf   r  r  s    r   *test_jump_forwards_out_of_try_except_blockz7JumpTestCase.test_jump_forwards_out_of_try_except_blockk  R    	MM!	MM!a    0)r?   r?   rN   c                     |                      d           	 |                      d           d S #  |                      d            xY wr%  r  r  s    r   +test_jump_backwards_out_of_try_except_blockz8JumpTestCase.test_jump_backwards_out_of_try_except_blockt  O    a	MM!	MM!	   . A)rW   rY   r7  c                     	 ddz   nZ# t           $ r- |                     d           |                     d           Y n$t          $ r |                     d           Y nw xY w|                     d           d S Nr?   r   rW   rP   rY   r7  r  r   FloatingPointErrorr  s    r   test_jump_between_except_blocksz,JumpTestCase.test_jump_between_except_blocks}  s    	aCCC  	 	 	MM!MM!! 	 	 	MM!	as    4AAAc                    	 ddz   n:# t           $ r- |                     d           |                     d           Y nw xY w|                     d           n# |                     d           w xY w|                     d           d S r3  )r  r   r  s    r    test_jump_from_except_to_finallyz-JumpTestCase.test_jump_from_except_to_finally  s    	aCCC  	 	 	MM!MM!	 MM!FMM!as!    A 4?A ?A A/)rW   rf   rY   c                     	 ddz   nF#  |                      d           |                      d           |                      d           Y nxY w|                      d           d S )Nr?   r   rW   rP   rf   rY   r  r  s    r   test_jump_within_except_blockz*JumpTestCase.test_jump_within_except_block  so    	aCCC	MM!MM!MM!as
    AA)r?   rP   r?   rP   c                     |                      d           	 ddz   n,# t          $ r}|                      d           Y d }~nd }~ww xY wd}d S )Nr?   r   rP   rQ  r   r  )r   r   r-   s      r   test_jump_over_try_exceptz&JumpTestCase.test_jump_over_try_except  sm    a	EEE  	 	 	MM!	s    
AAA)r?   rW   rP   r   c                 &   |                      d           t          | d          5  |                      d           d d d            n# 1 swxY w Y   t          | d          5  |                      d           d d d            d S # 1 swxY w Y   d S Nr?   rL   rN   rW   rP   r  r  s    r   test_jump_across_withz"JumpTestCase.test_jump_across_with     a&!$$ 	 	MM!	 	 	 	 	 	 	 	 	 	 	 	 	 	 	&!$$ 	 	MM!	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	#   AAA#BB
B
c                 r  K   |                      d           t          | d          4 d {V  |                      d           d d d           d {V  n# 1 d {V swxY w Y   t          | d          4 d {V  |                      d           d d d           d {V  d S # 1 d {V swxY w Y   d S r?  r  r  s    r   test_jump_across_async_withz(JumpTestCase.test_jump_across_async_with       a$VQ// 	 	 	 	 	 	 	 	MM!	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	$VQ// 	 	 	 	 	 	 	 	MM!	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	#   A
A #A =B&&
B03B0)r?   rN   rP   rf   c                    |                      d           dD ]T}t          | d          5  |                      d           d d d            n# 1 swxY w Y   |                      d           U|                      d           d S Nr?   r   rN   rW   rP   rf   r  r  s     r   ,test_jump_out_of_with_block_within_for_blockz9JumpTestCase.test_jump_out_of_with_block_within_for_block  s    a 	 	Afa(( ! !a   ! ! ! ! ! ! ! ! ! ! ! ! ! ! !MM!as   AA	A	c                 0  K   |                      d           dD ]f}t          | d          4 d {V  |                      d           d d d           d {V  n# 1 d {V swxY w Y   |                      d           g|                      d           d S rH  r  r  s     r   2test_jump_out_of_async_with_block_within_for_blockz?JumpTestCase.test_jump_out_of_async_with_block_within_for_block  s%     a 	 	A(33 ! ! ! ! ! ! ! !a   ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! !MM!as   A
A$	'A$	)r?   rL   rN   rP   rt   rf   c                 N   |                      d           t          | d          5  t          | d          5  |                      d           d d d            n# 1 swxY w Y   |                      d           d d d            n# 1 swxY w Y   |                      d           d S Nr?   rL   rN   rW   rP   rf   r  r  s    r   -test_jump_out_of_with_block_within_with_blockz:JumpTestCase.test_jump_out_of_with_block_within_with_block  s   a&!$$ 	 	fa(( ! !a   ! ! ! ! ! ! ! ! ! ! ! ! ! ! !MM!	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	as4   BABA	B A	!BB	B	c                 v  K   |                      d           t          | d          5  t          | d          4 d {V  |                      d           d d d           d {V  n# 1 d {V swxY w Y   |                      d           d d d            n# 1 swxY w Y   |                      d           d S rM  )r   r
   r%   r  s    r   3test_jump_out_of_async_with_block_within_with_blockz@JumpTestCase.test_jump_out_of_async_with_block_within_with_block  sz     a&!$$ 	 	(33 ! ! ! ! ! ! ! !a   ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! !MM!	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	as4   BA'B'
A1	1B4A1	5BB B)rL   rW   rf   rY   c                    	 |                      d           t          | d          5  |                      d           d d d            n# 1 swxY w Y   |                      d           nW# t          | d          5  |                      d           d d d            n# 1 swxY w Y   |                      d           w xY w|                      d           d S NrL   rW   rP   rf   rY   r  r  s    r   0test_jump_out_of_with_block_within_finally_blockz=JumpTestCase.test_jump_out_of_with_block_within_finally_block  sO   	MM!fa(( ! !a   ! ! ! ! ! ! ! ! ! ! ! ! ! ! !MM! fa(( ! !a   ! ! ! ! ! ! ! ! ! ! ! ! ! ! !MM!as@   A* A		AA*B>;BB>B!!B>$B!%B>c                   K   	 |                      d           t          | d          4 d {V  |                      d           d d d           d {V  n# 1 d {V swxY w Y   |                      d           ni# t          | d          4 d {V  |                      d           d d d           d {V  n# 1 d {V swxY w Y   |                      d           w xY w|                      d           d S rR  r  r  s    r   6test_jump_out_of_async_with_block_within_finally_blockzCJumpTestCase.test_jump_out_of_async_with_block_within_finally_block  s     	MM!(33 ! ! ! ! ! ! ! !a   ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! !MM! )33 ! ! ! ! ! ! ! !a   ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! !MM!as@   A> A
A!$A!>C$B=+C$=
CC$
CC$r7  )r?   rN   rP   rx  r  c                    |                      d           dD ]}|                      d           dD ]b}|                      d           	 dD ]}|                      d           	 |                      d           I# |                      d           w xY w|                      d           |                      d	           d S )
Nr?   r   rN   r  rP   r7  r   rx  r  r  )r   r   r  ks       r   &test_jump_out_of_complex_nested_blocksz3JumpTestCase.test_jump_out_of_complex_nested_blocks  s    a 		 		AMM! & &a   &# ) )a(((() MM"%%%%FMM"%%%%MM"bs   	A::B)r?   rL   rP   c                     |                      d           t          | d          5 }|                      d           d d d            n# 1 swxY w Y   |                      d           d S Nr?   rL   rW   rP   r  r  s     r    test_jump_out_of_with_assignmentz-JumpTestCase.test_jump_out_of_with_assignment  s    a&!$$ 	MM!	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	as   AAAc                    K   |                      d           t          | d          4 d {V 	 }|                      d           d d d           d {V  n# 1 d {V swxY w Y   |                      d           d S rZ  r  r  s     r   &test_jump_out_of_async_with_assignmentz3JumpTestCase.test_jump_out_of_async_with_assignment	  s     a$VQ// 	 	 	 	 	 	 	 	MM!	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	as   A
A!$A!)r?   rf   r7  r8  c                 D   |                      d           	 |                      d           | s	 |                      d           d S |                      d           |                      d           n# |                      d           w xY w|                      d           d S )Nr?   rN   r7  rf   r8  r  r  s    r   *test_jump_over_return_in_try_finally_blockz7JumpTestCase.test_jump_over_return_in_try_finally_block	  s    a	MM!  MM! MM!MM!FMM!as   A1 A1 1B)r?   rN   r7  r   rx  r  c                    |                      d           	 |                      d           	 |                      d           | s	 |                      d           n[|                      d           |                      d           n# |                      d           w xY w|                      d           	 |                      d           d S )	Nr?   TrN   rP   r   r7  rx  r  r  r  s    r   )test_jump_over_break_in_try_finally_blockz6JumpTestCase.test_jump_over_break_in_try_finally_block	  s    a
	MM!"a     b!!!! a   b!!!!b!!!!MM"bs   B B Bc                     |                      d           | sdD ]}|                      d           n*|                      d           |                      d           |                      d           d S Nr?   r  rW   rf   rY   r7  r  r  s     r   $test_jump_over_for_block_before_elsez1JumpTestCase.test_jump_over_for_block_before_else)	      a 	 ! !a    ! MM!MM!ar   c                   K   |                      d           | s/t          dg          2 3 d {V }|                      d           6 n*|                      d           |                      d           |                      d           d S Nr?   rN   rW   rf   rY   r7  r   r.   r  s     r   *test_jump_over_async_for_block_before_elsez7JumpTestCase.test_jump_over_async_for_block_before_else4	        a 	$aS>> ! ! ! ! ! ! !aa     *> MM!MM!a   Ac                 Z    |                      d           |                      d           d S r`   r  r  s    r   test_no_jump_too_far_forwardsz*JumpTestCase.test_no_jump_too_far_forwardsA	  r  r   rt   beforec                 Z    |                      d           |                      d           d S r`   r  r  s    r   test_no_jump_too_far_backwardsz+JumpTestCase.test_no_jump_too_far_backwardsF	  r  r   exceptc                 h    	 |                      d           d S #  |                      d            xY wNrL   rW   r  r  s    r   test_no_jump_to_except_1z%JumpTestCase.test_no_jump_to_except_1L	  s=    	MM!	MM!s    1c                 z    	 |                      d           d S # t          $ r |                      d            w xY wrs  r   r  r  s    r   test_no_jump_to_except_2z%JumpTestCase.test_no_jump_to_except_2T	  sO    	MM! 	 	 	MM!	s    !:c                     	 |                      d           d S # t          $ r}|                      d           |d }~ww xY wrs  rv  r  s     r   test_no_jump_to_except_3z%JumpTestCase.test_no_jump_to_except_3\	  sU    	MM! 	 	 	MM!G	s    
?:?c                     	 |                      d           d S # t          t          f$ r}|                      d           |d }~ww xY wrs  )r   r  r   r  s     r   test_no_jump_to_except_4z%JumpTestCase.test_no_jump_to_except_4d	  sZ    	MM!L) 	 	 	MM!G	s    AAAintoc                 d    |                      d           dD ]}|                      d           d S )Nr?   r  rN   r  r  s     r   $test_no_jump_forwards_into_for_blockz1JumpTestCase.test_no_jump_forwards_into_for_blockl	  sB    a 	 	AMM!	 	r   c                    K   |                      d           t          ddg          2 3 d {V }|                      d           6 d S r  rh  r  s     r   *test_no_jump_forwards_into_async_for_blockz7JumpTestCase.test_no_jump_forwards_into_async_for_blockr	  sk      a !Q(( 	 	 	 	 	 	 	!MM! )s   Ac                 d    dD ]}|                      d           |                      d           d S )Nr  rL   rN   r  r  s     r   %test_no_jump_backwards_into_for_blockz2JumpTestCase.test_no_jump_backwards_into_for_blocky	  s>     	 	AMM!ar   z&can't jump into the body of a for loopc                    K   t          ddg          2 3 d {V }|                     d           6 |                     d           d S r  )r.   r   r  s     r   +test_no_jump_backwards_into_async_for_blockz8JumpTestCase.test_no_jump_backwards_into_async_for_block	  sl       !Q(( 	 	 	 	 	 	 	!MM! )as   1stackc                     |                      d           t          | d          5  |                      d           d d d            d S # 1 swxY w Y   d S r  r  r  s    r   %test_no_jump_forwards_into_with_blockz2JumpTestCase.test_no_jump_forwards_into_with_block	  r  r  c                    K   |                      d           t          | d          4 d {V  |                      d           d d d           d {V  d S # 1 d {V swxY w Y   d S r  r  r  s    r   +test_no_jump_forwards_into_async_with_blockz8JumpTestCase.test_no_jump_forwards_into_async_with_block	  r  r  )r?   rL   r   c                     t          | d          5  |                     d           d d d            n# 1 swxY w Y   |                     d           d S r  r  r  s    r   &test_no_jump_backwards_into_with_blockz3JumpTestCase.test_no_jump_backwards_into_with_block	  r  r  c                    K   t          | d          4 d {V  |                     d           d d d           d {V  n# 1 d {V swxY w Y   |                     d           d S r  r  r  s    r   ,test_no_jump_backwards_into_async_with_blockz9JumpTestCase.test_no_jump_backwards_into_async_with_block	  r  r  c                     |                      d           	 |                      d           |                      d           d S # |                      d           w xY wr%  r  r  s    r   )test_jump_forwards_into_try_finally_blockz6JumpTestCase.test_jump_forwards_into_try_finally_block	  r'  r(  )rL   rW   rL   rW   rP   c                     	 |                      d           |                      d           n# |                      d           w xY w|                      d           d S r  r  r  s    r   *test_jump_backwards_into_try_finally_blockz7JumpTestCase.test_jump_backwards_into_try_finally_block	  r"  r#  c                     |                      d           	 |                      d           d S #  |                      d            xY wr%  r  r  s    r   (test_jump_forwards_into_try_except_blockz5JumpTestCase.test_jump_forwards_into_try_except_block	  r0  r1  )rL   rL   rf   c                     	 |                      d           n#  |                      d            xY w|                      d           d S r*  r  r  s    r   )test_jump_backwards_into_try_except_blockz6JumpTestCase.test_jump_backwards_into_try_except_block	  r,  r-  c                     	 ddz   na# t           $ r- |                     d           |                     d           Y n+t          $ r}|                     d           Y d }~nd }~ww xY w|                     d           d S r3  r4  r  s     r   !test_jump_between_except_blocks_2z.JumpTestCase.test_jump_between_except_blocks_2	  s    	aCCC  	 	 	MM!MM!! 	 	 	MM!	as    4A&	A&A!!A&c                     |                      d           	 |                      d           |                      d           d S # |                      d           w xY wr%  r  r  s    r   test_jump_into_finally_blockz)JumpTestCase.test_jump_into_finally_block	  r'  r(  )rL   rf   rY   c                 :   	 |                      d           |                      d           |                      d           |                      d           n/# |                      d           |                      d           w xY w|                      d           d S )NrL   rN   rP   rf   rY   r  r  s    r   +test_jump_into_finally_block_from_try_blockz8JumpTestCase.test_jump_into_finally_block_from_try_block	  s    	MM!MM!MM!MM! MM!MM!as   *A ,B)r?   rN   r?   rN   rP   c                     |                      d           	 |                      d           |                      d           d S # |                      d           w xY wr%  r  r  s    r   test_jump_out_of_finally_blockz+JumpTestCase.test_jump_out_of_finally_block	  r'  r(  z9can't jump into an 'except' block as there's no exceptionc                     |                      d           	 |                      d           d S #  |                      d           Y d S xY wr%  r  r  s    r   #test_no_jump_into_bare_except_blockz0JumpTestCase.test_no_jump_into_bare_except_block	  sU    a	MM!	MM!s	   . Ac                     |                      d           	 |                      d           d S # t          $ r |                      d           Y d S w xY wr%  r   rx   r  s    r   (test_no_jump_into_qualified_except_blockz5JumpTestCase.test_no_jump_into_qualified_except_block	  sg    a	MM! 	 	 	MM!	s   . AA)rL   rP   rf   c                     	 |                      d           |                      d           n0#  |                      d           |                      d            xY w|                      d           d S NrL   rN   rP   rf   r7  r  r  s    r   2test_no_jump_into_bare_except_block_from_try_blockz?JumpTestCase.test_no_jump_into_bare_except_block_from_try_block	  sv    	MM!MM!	MM!MM!as	   *- -Ac                     	 |                      d           |                      d           n9# t          $ r, |                      d           |                      d            w xY w|                      d           d S r  r<  r  s    r   7test_no_jump_into_qualified_except_block_from_try_blockzDJumpTestCase.test_no_jump_into_qualified_except_block_from_try_block 
  s    	MM!MM!  	 	 	MM!MM!	 	as	   *- 6A#)r?   rN   rf   r?   rN   rf   rY   c                     |                      d           	 |                      d           ddz   d S #  |                      d           |                      d           Y d S xY wNr?   rN   r   rf   rY   r  r  s    r   "test_jump_out_of_bare_except_blockz/JumpTestCase.test_jump_out_of_bare_except_block
  sn    a	MM!aCCCC	MM!MM!s	   3 ,A"c                     |                      d           	 |                      d           ddz   d S # t          $ r. |                      d           |                      d           Y d S w xY wr  r  r  s    r   'test_jump_out_of_qualified_except_blockz4JumpTestCase.test_jump_out_of_qualified_except_block
  s    a	MM!aCCCC 	 	 	MM!MM!	s   3 4A+*A+)r?   rL   rP   rt   c                 &   |                      d           t          | d          5  |                      d           d d d            n# 1 swxY w Y   t          | d          5  |                      d           d d d            d S # 1 swxY w Y   d S r?  r  r  s    r   test_jump_between_with_blocksz*JumpTestCase.test_jump_between_with_blocks
  rA  rB  c                 r  K   |                      d           t          | d          4 d {V  |                      d           d d d           d {V  n# 1 d {V swxY w Y   t          | d          4 d {V  |                      d           d d d           d {V  d S # 1 d {V swxY w Y   d S r?  r  r  s    r   #test_jump_between_async_with_blocksz0JumpTestCase.test_jump_between_async_with_blocks'
  rE  rF  c                     	 |                      d           |                      d           |                      d           d S # |                      d           |                      d            Y d S xY wr  r  r  s    r   -test_no_jump_over_return_out_of_finally_blockz:JumpTestCase.test_no_jump_over_return_out_of_finally_block/
  sx    	MM!MM!MM!F MM!MM!FFFFFFr  c                     |                      d           | sdD ]}|                      d           n*|                      d           |                      d           |                      d           d S rc  r  r  s     r   'test_no_jump_into_for_block_before_elsez4JumpTestCase.test_no_jump_into_for_block_before_else9
  re  r   c                   K   |                      d           | s/t          dg          2 3 d {V }|                      d           6 n*|                      d           |                      d           |                      d           d S rg  rh  r  s     r   -test_no_jump_into_async_for_block_before_elsez:JumpTestCase.test_no_jump_into_async_for_block_before_elseD
  rj  rk  c                 B    |                      t          dddg           d S )NrL   SpamT)r   r  r   s    r   test_no_jump_to_non_integersz)JumpTestCase.test_no_jump_to_non_integersO
  s#    -q&4&AAAAAr   c                 "    t                       d S r   )r  r   s    r   #test_no_jump_without_trace_functionz0JumpTestCase.test_no_jump_without_trace_functionR
  s     	'(((((r   c                 r    i }t          ddz  |           |d         }|                     |dddg           d S )Na  def f(output):        # line 0
            x = 0                     # line 1
            y = 1                     # line 2
            '''                       # line 3
            %s                        # lines 4-1004
            '''                       # line 1005
            x += 1                    # line 1006
            output.append(x)          # line 1007
            return)a  







































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































r)  rL   i  r   )r,  r   )r   r  r)  s      r   test_large_functionz JumpTestCase.test_large_functionW
  sX      '' )*	+ 	+ 	+ cFaD1#&&&&&r   c                 (   t          ddd           G fdd          }t          |dd          }t          j        |j                   dg i}t          |           t          j        d            |                     g d	|d                    d S )
Nzd
# Comments don't count.
output.append(2)  # firstlineno is here.
output.append(3)
output.append(4)
z<fake module>r,  c                       e Zd Z ZdS )<JumpTestCase.test_jump_to_firstlineno.<locals>.fake_functionN)r   r    r!   r   )r  s   r   fake_functionr  o
  s        HHHr   r  rW   r?   r   )rL   rN   rL   rN   rW   )compiler  r   r   r   r,  r  )r   r  r   r-  r  s       @r   test_jump_to_firstlinenoz%JumpTestCase.test_jump_to_firstlinenoe
  s      
 f 	 	 	 	 	 	 	 	 	 	M1a00V\"""rN	T9T  )H2EFFFFFr   rB   z5can't jump from the 'call' trace event of a new frame)r   r  c                 z                           d            fd} |                                   d           d S )Nr?   c                  2                          d           d S r  r  r  s   r   nestedz3JumpTestCase.test_no_jump_from_call.<locals>.nested|
  s    MM!r   rP   r  )r   r  s   ` r   test_no_jump_from_callz#JumpTestCase.test_no_jump_from_callx
  sS     	a	 	 	 	 	ar   rF   z'can only jump from a 'line' trace eventc                 0    |                      d           d S r>   r  r  s    r   test_no_jump_from_return_eventz+JumpTestCase.test_no_jump_from_return_event
  s     	ar   c                 :    |                      d           ddz   d S r  r  r  s    r   !test_no_jump_from_exception_eventz.JumpTestCase.test_no_jump_from_exception_event
  s#     	a	Ar   )r   c                 j      fd}t           |                                            d           d S )Nc               3   >   K                         d           dV  d S )NrL   rN   r  r  s   r   r9  z.JumpTestCase.test_jump_from_yield.<locals>.gen
  s&      MM!GGGGGr   rP   )rJ  r   )r   r9  s   ` r   test_jump_from_yieldz!JumpTestCase.test_jump_from_yield
  sG    	 	 	 	 	 	SSUUar   c                     |                      d           d t          d          D             }|                      d           d S )Nr?   c                     g | ]}|S r#   r#   r   r   s     r   r   z@JumpTestCase.test_jump_forward_over_listcomp.<locals>.<listcomp>
      """1Q"""r   r   rN   r   rb   r  s     r   test_jump_forward_over_listcompz,JumpTestCase.test_jump_forward_over_listcomp
  sE    a""b		"""ar   c                 @    d}d t          d          D             }d}d S )Nr?   c                     g | ]}|S r#   r#   r  s     r   r   zAJumpTestCase.test_jump_backward_over_listcomp.<locals>.<listcomp>
  r  r   r   rN   ra   r   rc   r-   r  s       r    test_jump_backward_over_listcompz-JumpTestCase.test_jump_backward_over_listcomp
  s)    ""b		"""r   )rL   rY   rL   c                     d}|                      d           |rd S d t          d          D             }d}|                      d           |                      d           d S )NFrL   c                     g | ]}|S r#   r#   r  s     r   r   zDJumpTestCase.test_jump_backward_over_listcomp_v2.<locals>.<listcomp>
  s    !!!1Q!!!r   rP   rf   rY   r7  r  r   flagr-   s      r   #test_jump_backward_over_listcomp_v2z0JumpTestCase.test_jump_backward_over_listcomp_v2
  sn    a 	F!!a!!!aar   c                    K   |                      d           d t          t          d                    2              d {V }|                      d           d S )Nr?   c                 "   K   g | 3 d {V }|
6 S r   r#   r  s     r   r   zFJumpTestCase.test_jump_forward_over_async_listcomp.<locals>.<listcomp>
  .      33333333Q3333   r   rN   r   r.   rb   r  s     r   %test_jump_forward_over_async_listcompz2JumpTestCase.test_jump_forward_over_async_listcomp
  sc      a33ib		22333333333ar   c                 j   K   d}d t          t          d                    2              d {V }d}d S )Nr?   c                 "   K   g | 3 d {V }|
6 S r   r#   r  s     r   r   zGJumpTestCase.test_jump_backward_over_async_listcomp.<locals>.<listcomp>
  r  r  r   rN   )r.   rb   r  s       r   &test_jump_backward_over_async_listcompz3JumpTestCase.test_jump_backward_over_async_listcomp
  sG      33ib		22333333333r   c                    K   d}|                      d           |rd S d t          t          d                    2              d {V }d}|                      d           |                      d           d S )NFrL   c                 "   K   g | 3 d {V }|
6 S r   r#   r  s     r   r   zJJumpTestCase.test_jump_backward_over_async_listcomp_v2.<locals>.<listcomp>
  s.      22222222Q2222r  rP   rf   rY   r7  r  r  s      r   )test_jump_backward_over_async_listcomp_v2z6JumpTestCase.test_jump_backward_over_async_listcomp_v2
  s      a 	F22ia11222222222aar   )r  c                     d}t          |                     d                     |                     d           |dz   dz    |                     d           d S Nr?   rN   rP   r   r  r%  r  r   r   rc   s     r   (test_jump_with_null_on_stack_load_globalz5JumpTestCase.test_jump_with_null_on_stack_load_global
  sr    MM!	
 	
 	
 	a 
   	br   c                     d}t           } ||                     d                     |                     d           |dz   dz    |                     d           d S )Nr?   rW   rf   rx  rz     r  )r   rc   r)  s      r   &test_jump_with_null_on_stack_push_nullz3JumpTestCase.test_jump_with_null_on_stack_push_null
  sy    	MM!	
 	
 	
 	a 
   	br   c                     d}t                               | d           |                     d           |dz   dz    |                     d           d S r  )listr   r  s     r   &test_jump_with_null_on_stack_load_attrz3JumpTestCase.test_jump_with_null_on_stack_load_attr
  sl    A	
 	
 	
 	a 
   	br   c                     |                      d           |                      d          pd^}}}|                      d           d S Nr?   rL   r  rN   r  r   r;  s     r   (test_jump_extended_args_unpack_ex_simplez5JumpTestCase.test_jump_extended_args_unpack_ex_simple
  sH    a==##-vAqar   )r?   rW   rW   rP   c                     |                      d           |                      d          pd^}}}|                      d           d S )Nr?   rW   r  rP   r  r  s     r   (test_jump_extended_args_unpack_ex_trickyz5JumpTestCase.test_jump_extended_args_unpack_ex_tricky  sN    a MM!&	
1ar   cpuc                     dddgd t          dd          D             d}i }t          d                    |          |           |d	         }|                     |d
dddg           d S )Nzdef f(output):z    output.append(1)z    for _ in spam:c              3   "   K   | ]
}d | dV  dS )z        output.append()Nr#   r  s     r   r   z@JumpTestCase.test_jump_extended_args_for_iter.<locals>.<genexpr>  s.      GG+q+++GGGGGGr   rN   i z    output.append(100_000)r   r)  rL   r?   )rb   r,  r   r   )r   sourcer-  r)  s       r    test_jump_extended_args_for_iterz-JumpTestCase.test_jump_extended_args_for_iter  s    
 " 
 HGU1g5F5FGGG	

 *
 	TYYv	***cNa!Wq'l33333r   c                     |                      d           |                      d          od}|                      d           d S r  r  r  s     r   test_jump_or_popzJumpTestCase.test_jump_or_pop  sB    aMM!'ar   )NrD   Fr  )rr   r    r!   r   r  r   r  r  r  r  r  r  r  r  r  r  r  r<   r  r  r  r  r  r  r  r  r  r  r  r	  r  r  r  r  r  r!  r&  r+  r/  r6  r8  r:  r=  r@  rD  rI  rK  rN  rP  rS  rU  rX  r[  r]  r_  ra  rd  ri  rm  rp  rt  rw  ry  r{  r~  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r   requires_resourcer   r  r#   r   r   r  r  P  s         6 6 6 @D).3 3 3 3" FJ).3 3 3 3$
 
 
 

 
 
 
 Yq!aS  
 Yq!YYY    Yq!aS   Yq!YYY    Yq!aS   Yq!YYY    Yq!aV   Yq!---..  /. _QAq6""  _ #" _Q---..  _ /. Yq!aS  
 Yq!YYY    Yq!aV	 	 	 Yq!aV/455  65 Yq"q"g 12677  87 Yq"q!fz;788  98 Yq!aS:w/00  10 Yq!aV   Yq!\\\""  #" Yq!aV  
 _QAq6""  #"
 Yq!((())  *)
 _Q...//  0/
 Yq!aS   Yq!\\\""  #" Yq!aS   Yq!YYY    Yq!YYY    Yq!YYY    Yq!YYY    Yq!\\\""  #" Yq!]]]##  $# _Q===))  *) Yq!\\\""  #" _Q<<<((  )( Yq!((())  *) _Q...//  0/ Yq!\\\""  #" _Q<<<((  )( Yq"'''((  )( Yq!YYY    _Q999%%  &% Yq!\\\""	 	 #"	 Yq!***++  ,+ Yq!aV   _QAq6""  #" Yq!aS:w/00  10 Yq"qcJ122  32
 Yq!aS:x011  21 Yq!aS:x011  21 Yq!aS:x011  21 Yq!aS:x011  21 Yq!R*f-..  /.
 _Q2
F344  54 Yq!aVj&122  32
 _QAq6J0X#YZZ  [Z
 Yq!R*g.//  0/
 _Q2
G455  65
 Yq!ZZZ*g!677  87
 _Q:::
G'<==  >=
 Yq!aV   Yq!___%%  &% Yq!aS   Yq!YYY    Yq!YYY    Yq!aS   Yq!YYY    Yq!___%%  &% Yq!R*&abcc  dc Yq!R*&abcc  dc Yq!YYY-h ijj  kj Yq!aS:'bcdd  ed Yq!***++  ,+ Yq!***++  ,+ Yq!]]]##  $# _Q===))  *) Yq!aVj'233  43 Yq!aVj&122  32 _QAq6J#788  98B B B) ) )
' ' 'G G G& Yq!aSz <8 /9 : : : : : Yq!aS81: ; ; ; ; ; Yq!aSJ84: ; ; ; ; ; Yq!aV8,,,  -, Yq!aV   Yq!R  
 Yq!YYY    _QAq6""  #"
 _Q2  
 _Q999%%  &% Yq!R
G4555  65$ Yq!R
G4555  65& Yq!R
G4555  65" Yq!aV  
 Yq!\\\""  #" Wu%%4 4 &%4 Yq!aV    r   r  c                   &    e Zd Zd Zd Zd Zd ZdS )TestExtendedArgsc                     |                      t          j        t          j                               t          j        d            d S r   ru  r   s    r   r   zTestExtendedArgs.setUp&  r  r   c                     t          d          D ]} |             ddddfdt          j                    |             t          j        d            S )N   r   rB   rD   rF   c                 (    |xx         dz  cc<   S r>   r#   )r   r   r   countsr   s      r   r   z,TestExtendedArgs.count_traces.<locals>.trace0  s    5MMMQMMMLr   )rb   r   r   )r   r   r;  r  r   s      @@r   count_traceszTestExtendedArgs.count_traces*  s    r 	 	ADFFFFQ!44	 	 	 	 	 	 	UTr   c                     i }d}t          ||           |                     |d                   }|                     |dddd           d S )Na"  def f():
  (y,
   y,
   y,
   y,
   y,
   y,
   y,
   y,
   y,
   y,
   y,
   y,
   y,
   y,
   y,
   y,
   y,
   y,
   y,
   y,
   y,
   y,
   y,
   y,
   y,
   y,
   y,
   y,
   y,
   y,
   y,
   y,
   y,
   y,
   y,
   y,
   y,
   y,
   y,
   y,
   y,
   y,
   y,
   y,
   y,
   y,
   y,
   y,
   y,
   y,
   y,
   y,
   y,
   y,
   y,
   y,
   y,
   y,
   y,
   y,
   y,
   y,
   y,
   y,
   y,
   y,
   y,
   y,
   y,
   y,
   y,
   y,
   y,
   y,
   y,
   y,
   y,
   y,
   y,
   y,
   y,
   y,
   y,
   y,
   y,
   y,
   y,
   y,
   y,
   y,
   y,
   y,
   y,
   y,
   y,
   y,
   y,
   y,
   y,
   y,
   y,
   y,
   y,
   y,
   y,
   y,
   y,
   y,
   y,
   y,
   y,
   y,
   y,
   y,
   y,
   y,
   y,
   y,
   y,
   y,
   y,
   y,
   y,
   y,
   y,
   y,
   y,
   y,
   y,
   y,
   y,
   y,
   y,
   y,
   y,
   y,
   y,
   y,
   y,
   y,
   y,
   y,
   y,
   y,
   y,
   y,
   y,
   y,
   y,
   y,
   y,
   y,
   y,
   y,
   y,
   y,
   y,
   y,
   y,
   y,
   y,
   y,
   y,
   y,
   y,
   y,
   y,
   y,
   y,
   y,
   y,
   y,
   y,
   y,
   y,
   y,
   y,
   y,
   y,
   y,
   y,
   y,
   y,
   y,
   y,
   y,
   y,
   y,
   y,
   y,
   y,
   y,
   y,
   y,
   y,
   y,
   y,
   y,
   y,
   y,
   y,
   y,
   y,
   y,
   y,
   y,
   y,
   y,
   y,
   y,
   y,
   y,
   y,
   y,
   y,
   y,
   y,
   y,
   y,
   y,
   y,
   y,
   y,
   y,
   y,
   y,
   y,
   y,
   y,
   y,
   y,
   y,
   y,
   y,
   y,
   y,
   y,
   y,
   y,
   y,
   y,
   y,
   y,
   y,
   y,
   y,
   y,
   y,
   y,
   y,
   y,
   y,
   y,
   y,
   y,
   y,
   y,
   y,
   y,
   y,
   y,
   y,
   y,
   y,
   y,
   y,
   y,
   y,
   y,
   y,
   y,
   y,
   y,
   y,
   y,
   y,
   y,
   y,
   y,
   y,
   y,
   y,
   y,
   y,
   y,
   y,
   y,
   y,
   y,
   y,
   y,
   y,
   y,
   y,
   y,
   y,
   y,
   y,
   y,
   y,
   ) = range(300)r)  r?   i-  r	  )r,  r  rB  )r   nsr  r  s       r   test_trace_unpack_long_sequencez0TestExtendedArgs.test_trace_unpack_long_sequence:  sV    AT2""2c7++!SA!F!FGGGGGr   c                 @   d                     d                    d t          d          D                                 }d t          d          D             }t          ||           |                     |d                   }|                     |dddd	           d S )
Nzeif 1:
            def f():
                return (
                    {}
                )
        z
+
c              3   "   K   | ]
}d | dV  dS )varr   Nr#   r  s     r   r   z>TestExtendedArgs.test_trace_lots_of_globals.<locals>.<genexpr>G  s*      AAaAAAAAAr   i  c                     i | ]}d | |	S )r  r#   r  s     r   
<dictcomp>z?TestExtendedArgs.test_trace_lots_of_globals.<locals>.<dictcomp>H  s     000qiAii000r   r)  r?   i  r	  )formatr   rb   r,  r  rB  )r   r  r  r  s       r   test_trace_lots_of_globalsz+TestExtendedArgs.test_trace_lots_of_globalsA  s    
 F7<<AAU4[[AAAAABB 	 10E$KK000T2""2c7++!TQ!G!GHHHHHr   N)r   r    r!   r   r  r  r  r#   r   r   r  r  $  sX             H H H
I 
I 
I 
I 
Ir   r  c                        e Zd Zd Zd Zd ZdS )TestEdgeCasesc                     |                      t          j        t          j                               t          j        d            d S r   ru  r   s    r   r   zTestEdgeCases.setUpP  r  r   c                    d }d  G fdd          }t          j         |                       t          j                    5 }t          j        |           |                     |j        j        |j                   |                     |j        j	        t                     d d d            n# 1 swxY w Y   |                     t          j                    |           d S )Nc                      d S r   r#   r   s    r   r  z*TestEdgeCases.test_reentrancy.<locals>.fooU      Cr   c                      d S r   r#   r   s    r   barz*TestEdgeCases.test_reentrancy.<locals>.barX  r  r   c                        e Zd Zd Z fdZdS )(TestEdgeCases.test_reentrancy.<locals>.Ac                     d S r   r#   )r   r8   s     r   __call__z1TestEdgeCases.test_reentrancy.<locals>.A.__call__\  r  r   c                 0    t          j                   d S r   )r   r   )r   r  s    r   __del__z0TestEdgeCases.test_reentrancy.<locals>.A.__del___  s    S!!!!!r   N)r   r    r!   r"  r$  )r  s   r   r  r   [  s=          " " " " " " "r   r  )r   r   r   catch_unraisable_exceptionrB  
unraisableobjectr$  r  	exc_valuer   r   )r   r  r  cmr  s       @r   test_reentrancyzTestEdgeCases.test_reentrancyT  sH   	 	 		 	 		" 	" 	" 	" 	" 	" 	" 	" 	" 	" 	QQSS/11 	IRLR]119===!!"-"9<HHH	I 	I 	I 	I 	I 	I 	I 	I 	I 	I 	I 	I 	I 	I 	I
 	-----s   AB11B58B5c                     d }t          j        |           ~t          j        t          j                               d S )Nc                      d S r   r#   r   s    r   r  z+TestEdgeCases.test_same_object.<locals>.fool  r  r   r   )r   r  s     r   test_same_objectzTestEdgeCases.test_same_objectk  sB    	 	 	 	SS\^^$$$$$r   N)r   r    r!   r   r*  r-  r#   r   r   r  r  N  sA          . . ..% % % % %r   r  __main__)7r:   r   unittestunittest.mockr   r   r   r   	functoolsr   r  test.supportr   requires_working_socketr
   r%   r.   r<   r@   r   rI   rS   rU   r\   rd   rk   ro   rB   ry   r{   r   r   r   r   r   r   r   r   r   r   TestCaser   r=  r^  r\  rj  rs  r  r  r  r  r  r  r   mainr#   r   r   <module>r6     s          # # # # # # 



  				        & & & & & &  t , , , ,
( 
( 
( 
( 
( 
( 
( 
(
( 
( 
( 
( 
( 
( 
( 
(  
       
 
 
' ' ' 
 
 
' ' '   ' ' ' 
 
 

( ( (   	% 	% 	% 
 
 
' ' ' 
 
 
        
$ 
$ 
$
 / / /$ $ $ ,_      , , ,    ) ) )   + + +  "  + + +      	- 	- 	- )+6;
< )-89         0g1 g1 g1 g1 g1H% g1 g1 g1T)  	/ 	/ 	/ 	/ 	/- 	/ 	/ 	/ 	0 0 0 0 0= 0 0 0g3 g3 g3 g3 g3x0 g3 g3 g3\# # # # # # # #L+ + +H H HQ Q Q Q Q8$ Q Q Qh'I 'I 'I 'I 'Ix( 'I 'I 'IT#% #% #% #% #%H% #% #% #%L zHMOOOOO r   