
    ;e']                        d Z ddlZddlZddlZddlZddlZddlZddlZddlZ	 ddl	Z	n# e
$ r dZ	Y nw xY wddlmZmZmZmZ ddlmZ ddlmZ ddlmZ ed         Zd Zd	 Zd
 Z G d dej                  Zd Z G d dej                  Z G d dej                  Zd Zd Zd Z d Z!d Z" e#            fdZ$d Z%d Z&d Z' G d dej                  Z( ed          re	e	j)        Z* e	j+        de	j,                  Z-e*j.        Z/e-fe/_0        e	j1        e/_2        e*j3        Z4e	j5        e	j1        e	j,        fe4_0        e	j6        e4_2        e*j7        Z8e	j5        e	j1         e	j9        e	j,                  fe8_0        e	j6        e8_2        da:d Z; e-e;          Z< e/e<          Z= G d  d!ej                  Z>d" Z?e@d#k    r ejA                     dS dS )$a  This module includes tests of the code object representation.

>>> def f(x):
...     def g(y):
...         return x + y
...     return g
...

>>> dump(f.__code__)
name: f
argcount: 1
posonlyargcount: 0
kwonlyargcount: 0
names: ()
varnames: ('x', 'g')
cellvars: ('x',)
freevars: ()
nlocals: 2
flags: 3
consts: ('None', '<code object g>')

>>> dump(f(4).__code__)
name: g
argcount: 1
posonlyargcount: 0
kwonlyargcount: 0
names: ()
varnames: ('y',)
cellvars: ()
freevars: ('x',)
nlocals: 1
flags: 19
consts: ('None',)

>>> def h(x, y):
...     a = x + y
...     b = x - y
...     c = a * b
...     return c
...

>>> dump(h.__code__)
name: h
argcount: 2
posonlyargcount: 0
kwonlyargcount: 0
names: ()
varnames: ('x', 'y', 'a', 'b', 'c')
cellvars: ()
freevars: ()
nlocals: 5
flags: 3
consts: ('None',)

>>> def attrs(obj):
...     print(obj.attr1)
...     print(obj.attr2)
...     print(obj.attr3)

>>> dump(attrs.__code__)
name: attrs
argcount: 1
posonlyargcount: 0
kwonlyargcount: 0
names: ('print', 'attr1', 'attr2', 'attr3')
varnames: ('obj',)
cellvars: ()
freevars: ()
nlocals: 1
flags: 3
consts: ('None',)

>>> def optimize_away():
...     'doc string'
...     'not a docstring'
...     53
...     0x53

>>> dump(optimize_away.__code__)
name: optimize_away
argcount: 0
posonlyargcount: 0
kwonlyargcount: 0
names: ()
varnames: ()
cellvars: ()
freevars: ()
nlocals: 0
flags: 3
consts: ("'doc string'", 'None')

>>> def keywordonly_args(a,b,*,k1):
...     return a,b,k1
...

>>> dump(keywordonly_args.__code__)
name: keywordonly_args
argcount: 2
posonlyargcount: 0
kwonlyargcount: 1
names: ()
varnames: ('a', 'b', 'k1')
cellvars: ()
freevars: ()
nlocals: 3
flags: 3
consts: ('None',)

>>> def posonly_args(a,b,/,c):
...     return a,b,c
...

>>> dump(posonly_args.__code__)
name: posonly_args
argcount: 3
posonlyargcount: 2
kwonlyargcount: 0
names: ()
varnames: ('a', 'b', 'c')
cellvars: ()
freevars: ()
nlocals: 3
flags: 3
consts: ('None',)

    N)cpython_onlycheck_impl_detailrequires_debug_ranges
gc_collect)assert_python_ok)threading_helper)opmapCOPY_FREE_VARSc              #   ~   K   | D ]7}t          |          }|                    d          rd|j        z  V  3|V  8dS )z.Yield a doctest-safe sequence of object reprs.z<code objectz<code object %s>N)repr
startswithco_name)teltrs      %/usr/lib/python3.11/test/test_code.pyconstsr      s_        II<<'' 	$s{22222GGGG     c           
          dD ]'}t          |dt          | d|z                        (t          dt          t          | j                                       dS )z1Print out a text representation of a code object.)
nameargcountposonlyargcountkwonlyargcountnamesvarnamescellvarsfreevarsnlocalsflagsz: co_zconsts:N)printgetattrtupler   	co_consts)coattrs     r   dumpr'      sh    = < < 	$$$EDL 9 9 9:;;;;	)U6",//0011111r   c                 J    dt                                          |           S )NzForeign getitem: )super__getitem__)selfis     r   external_getitemr-      s"    7uww22155777r   c                       e Zd Zed             Zed             Zd Zd Zd Zd Z	d Z
d Z e            d	             Zd
 Zd Z e            d             Zd ZdS )CodeTestc                 b   dd l }|                    ddd          }|                     |j        d           |                     |j        d           |                     |j        d           |                     t                    5  t          |           d d d            d S # 1 swxY w Y   d S )Nr   filenamefuncname   )		_testcapicode_newemptyassertEqualco_filenamer   co_firstlinenoassertRaises	Exceptionexec)r+   r4   r%   s      r   test_newemptyzCodeTest.test_newempty   s    $$ZR@@444Z000*B///y)) 	 	HHH	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	s   B$$B(+B(c                 ,   ddl m d d fd} G d dt                    } ||dt                     |j        }|j        d         j        }|                     ||            |g d	          }|                     |d         d
           d S )Nr   )FunctionTypec                       fdj         S )Nc                       S N 	__class__s   r   <lambda>zICodeTest.test_closure_injection.<locals>.create_closure.<locals>.<lambda>   s    I r   )__closure__rC   s   `r   create_closurez7CodeTest.test_closure_injection.<locals>.create_closure   s    %%%%22r   c                 x    |                      | j        dz   t          t          dg          | j        z             S )z9A new code object with a __class__ cell added to freevarsrC      )co_freevarsco_code)replacerJ   bytesr
   rK   )cs    r   new_codez1CodeTest.test_closure_injection.<locals>.new_code   s8    99)GQVXfhiWjQkQklmluQu9vvvr   c                      |j                   }|j        rJ  |           }|j        }t          | | |t	                      |||                     d S rA   )__code__rF   __defaults__setattrglobals)	clsr   fcodeclosuredefaultsr>   rG   rO   s	         r   add_foreign_methodz;CodeTest.test_closure_injection.<locals>.add_foreign_method   sf    8AJ''D}$$$$nS))G~HC||D'))T8WUUVVVVVr   c                       e Zd ZdS )-CodeTest.test_closure_injection.<locals>.ListN)__name__
__module____qualname__rB   r   r   Listr\      s        Dr   r`   r*   )rI         zForeign getitem: 1)	typesr>   listr-   r*   rF   cell_contentsassertIsr6   )	r+   rZ   r`   function	class_refobjr>   rG   rO   s	         @@@r   test_closure_injectionzCodeTest.test_closure_injection   s    	'&&&&&	3 	3 	3	w 	w 	w	W 	W 	W 	W 	W 	W 	W	 	 	 	 	4 	 	 	 	40@AAA #(+9	i&&& d999ooQ!566666r   c                 $   d }|j         }t          |          } ||j        |j        |j        |j        |j        |j        |j        |j	        |j
        |j        |j        |j        |j        |j        |j        |j        |j        |j                   d S )Nc                      d S rA   rB   rB   r   r   funcz'CodeTest.test_constructor.<locals>.func   s      r   )rQ   typeco_argcountco_posonlyargcountco_kwonlyargcount
co_nlocalsco_stacksizeco_flagsrK   r$   co_namesco_varnamesr7   r   co_qualnamer8   co_linetableco_exceptiontablerJ   co_cellvars)r+   rm   r%   CodeTypes       r   test_constructorzCodeTest.test_constructor   s    ]88 	-,

),#	( 	( 	( 	( 	(r   c                 x    |                      t          j        j        j        t          j        j                   d S rA   )r6   r/   test_qualnamerQ   rw   r_   r+   s    r   r~   zCodeTest.test_qualname   s9    "+7"/	
 	
 	
 	
 	
r   c                 6   d }|j         }d }|j         }dddddd|j        t          j        z  fd	d
|j        fd|j        fddddddd|j        ffD ]g\  }}|                     ||          5   |j        di ||i}| 	                    t          ||          |           d d d            n# 1 swxY w Y   h|                    |j        |j                  }| 	                    |j        |j                   | 	                    |j        |j                   d S )Nc                  
    d} | S NrI   rB   xs    r   rm   z#CodeTest.test_replace.<locals>.func       AHr   c                      d} d}| S )Nra   rb   rB   )yzs     r   func2z$CodeTest.test_replace.<locals>.func2   s    AAHr   )ro   r   )rp   r   )rq   r   )rr   rI   )rs   r   rt   )r8   d   rK   r$   )ru   )myname)rv   )spam)rJ   )freevar)rz   )cellvar)r7   newfilename)r   newnamerx   )r&   value)rv   rr   rB   )rQ   rt   inspectCO_COROUTINErK   r$   rx   subTestrL   r6   r"   rv   rr   )r+   rm   rW   r   code2r&   r   rO   s           r   test_replacezCodeTest.test_replace   s   	 	 	 }	 	 	  %$)==>#&%/*%&))*"U/0!
 	A 	AKD%$ 4u55 A A'4<884-88  4!8!8%@@@A A A A A A A A A A A A A A A <<E,=+0+;   = =-u/@AAA,e.>?????s   ,4B,,B0	3B0	c                    d }|j         }|j        dk    sJ t          |          }dD ]}|                     t                    5   ||j        |j        |j        |j        |z   |j        |j	        |j
        |j        |j        |j        |j        |j        |j        |j        |j        |j        |j        |j                   d d d            n# 1 swxY w Y   |                     t                    5  |                    |j        dz
             d d d            n# 1 swxY w Y   |                     t                    5  |                    |j        dz              d d d            d S # 1 swxY w Y   d S )Nc                  
    d} | S r   rB   r   s    r   rm   z,CodeTest.test_nlocals_mismatch.<locals>.func"  r   r   r   )rI   rI   )rr   )rQ   rr   rn   r9   
ValueErrorro   rp   rq   rs   rt   rK   r$   ru   rv   r7   r   rw   r8   rx   ry   rJ   rz   rL   )r+   rm   r%   r{   diffs        r   test_nlocals_mismatchzCodeTest.test_nlocals_mismatch!  sB   	 	 	 ]}q     88 	 	D"":..  .--*-%                , z** 	5 	5JJ"-!"3J444	5 	5 	5 	5 	5 	5 	5 	5 	5 	5 	5 	5 	5 	5 	5z** 	5 	5JJ"-!"3J444	5 	5 	5 	5 	5 	5 	5 	5 	5 	5 	5 	5 	5 	5 	5 	5 	5 	5s7   A:CC	C	1DD #D E--E14E1c                 r    d }|j         }|                    d          }|                     ||           d S )Nc                       fdS )Nc                       S rA   rB   args   r   rE   zBCodeTest.test_shrinking_localsplus.<locals>.func.<locals>.<lambda>J  s    3 r   rB   r   s   `r   rm   z0CodeTest.test_shrinking_localsplus.<locals>.funcI  s    ;;;r   rm   )r   )rQ   rL   r6   )r+   rm   rW   newcodes       r   test_shrinking_localsplusz"CodeTest.test_shrinking_localsplusF  sG    	 	 	},,v,..w'''''r   c                     d }|j                             d          x}}|                     t          |                                          g            d S )Nc                      d S rA   rB   rB   r   r   rm   z+CodeTest.test_empty_linetable.<locals>.funcP      Dr   r   rx   )rQ   rL   r6   rd   co_lines)r+   rm   rO   rW   s       r   test_empty_linetablezCodeTest.test_empty_linetableO  s^    	 	 	-//S/AAA4h//1122B77777r   c                    dd l }i }t          t          j        d          |           |d         }|j        }|j        j        }g }t           |j        |d          |	                                d          D ]T\  }}| 
                    |                    d           g d           t          |          s|                    |           U|                     d |D             g d	           d S )
Nr   zX        try:
            1/0
        except Exception as e:
            exc = e
        excT)show_caches)strict)r   rb      c                 *    g | ]}|j         |j        fS rB   )opnameargval).0instructions     r   
<listcomp>zFCodeTest.test_co_positions_artificial_instructions.<locals>.<listcomp>w  s3        #[%78  r   ))PUSH_EXC_INFON)
LOAD_CONSTN)
STORE_NAMEe)DELETE_NAMEr   RERAISErI   )COPYrb   )
POP_EXCEPTNr   )disr;   textwrapdedent__traceback__tb_framef_codezipget_instructionsco_positionsassertIncountanyappendr6   )	r+   r   	namespacer   	tracebackrW   artificial_instructionsinstr	positionss	            r   )test_co_positions_artificial_instructionsz2CodeTest.test_co_positions_artificial_instructionsU  s?   


	X_   
 	 	 	 %	!("$ # C 4888!
 !
 !
 	6 	6E9 MM)//$//;;;y>> 6'..u555 #:  	 	 		
 	
 	
 	
 	
r   c                 R    t          j        d          }t          ddd|           d S )N#  
            def f():
                pass

            positions = f.__code__.co_positions()
            for line, end_line, column, end_column in positions:
                assert line == end_line
                assert column is None
                assert end_column is None
            z-Xno_debug_ranges-cr   r   r   r+   rW   s     r   6test_endline_and_columntable_none_when_no_debug_rangesz?CodeTest.test_endline_and_columntable_none_when_no_debug_ranges  s7      	  	 	 	0$=====r   c                 R    t          j        d          }t          d|d           d S )Nr   r   1)PYTHONNODEBUGRANGESr   r   s     r   :test_endline_and_columntable_none_when_no_debug_ranges_envzCCodeTest.test_endline_and_columntable_none_when_no_debug_ranges_env  s5     	  	 	 	t======r   c                     d }|j                             d          }|                                }|D ]:\  }}}}|                     |           |                     ||j        dz              ;d S )Nc                  
    d} d S r   rB   r   s    r   rm   z8CodeTest.test_co_positions_empty_linetable.<locals>.func  s    AAAr   r   r   rI   )rQ   rL   r   assertIsNoner6   r8   )r+   rm   rO   r   lineend_linecolumn
end_columns           r   !test_co_positions_empty_linetablez*CodeTest.test_co_positions_empty_linetable  s    	 	 	=((c(::))++	2; 	D 	D.D(FJd###Xx'>'BCCCC	D 	Dr   c                    d }|j         }|                    d          }|                    d          }|                    d          }|                     ||           |                     ||           |                     ||           |                     ||           |                     ||           |                     ||           d S )Nc                      	 t                       t                       n#  t                       Y nxY wt                       d S # t                       w xY wrA   )arN   bdrB   r   r   rV   z&CodeTest.test_code_equality.<locals>.f  sP      s    A 1A Ar   r   )ry   )rQ   rL   assertNotEqual)r+   rV   code_acode_bcode_ccode_ds         r   test_code_equalityzCodeTest.test_code_equality  s    	 	 	 S11#66#66FF+++FF+++FF+++FF+++FF+++FF+++++r   N)r]   r^   r_   r   r<   rj   r|   r~   r   r   r   r   r   r   r   r   r   r   rB   r   r   r/   r/      s#         \ 7 7 \7@( ( (2
 
 
&@ &@ &@P#5 #5 #5J( ( (8 8 8 /
 /
 /
b> > >> > >  D D D, , , , ,r   r/   c                 J    | t          j        d| z   dz   dd                   u S )N_rI   r   )sysintern)ss    r   
isinternedr     s(    
C!GcM1R401111r   c                       e Zd Zd Zd Zd Zed             Zed             Zed             Z	ed             Z
ed             Zd	S )
CodeConstsTestc                 z    |D ]}||k    r|c S |                      ||           |                     d           d S )NzShould never be reached)r   fail)r+   r   r   vs       r   
find_constzCodeConstsTest.find_const  sU     	 	AEzz eV$$$		+,,,,,r   c                 Z    t          |          s|                     d|d           d S d S )NString z is not internedr   r   r+   r   s     r   assertIsInternedzCodeConstsTest.assertIsInterned  s;    !}} 	:IIIQQQ899999	: 	:r   c                 Z    t          |          r|                     d|d           d S d S )Nr   z is internedr   r   s     r   assertIsNotInternedz"CodeConstsTest.assertIsNotInterned  s;    a== 	6III455555	6 	6r   c                     t          ddd          }|                     |j        d          }|                     |           d S )Nzres = "str_value"?r;   	str_valuecompiler   r$   r   r+   r%   r   s      r   test_interned_stringz#CodeConstsTest.test_interned_string  sC    (#v66OOBL+66a     r   c                     t          ddd          }|                     |j        d          }|                     |d                    d S )Nzres = ("str_value",)r  r;   r  r   r  r  s      r   test_interned_string_in_tuplez,CodeConstsTest.test_interned_string_in_tuple  sG    +S&99OOBL.99ad#####r   c                     t          ddd          }|                     |j        t          d                    }|                     t          |          d                    d S )Nzres = a in {"str_value"}r  r;   r
  r   )r  r   r$   	frozensetr   r#   r  s      r   !test_interned_string_in_frozensetz0CodeConstsTest.test_interned_string_in_frozenset  sU    /f==OOBL)N*C*CDDeAhhqk*****r   c                 H    dd}|                       |                       d S )Nr  c                     | S rA   rB   )r   s    r   rV   z6CodeConstsTest.test_interned_string_default.<locals>.f  s    Hr   r
  )r   r+   rV   s     r   test_interned_string_defaultz+CodeConstsTest.test_interned_string_default  s6    	 	 	 	aacc"""""r   c                     t          ddd          }|                     |j        d          }|                     |           d S )Nzres = "str\0value!"r  r;   z
str value!)r  r   r$   r  r  s      r   test_interned_string_with_nullz-CodeConstsTest.test_interned_string_with_null  sC    +S&99OOBL-88  #####r   N)r]   r^   r_   r   r   r  r   r  r  r  r  r  rB   r   r   r   r     s        - - -: : :6 6 6 ! ! \!
 $ $ \$
 + + \+
 # # \#
 $ $ \$ $ $r   r   c                       e Zd Zd ZdS )CodeWeakRefTestc                     i }t          dt                      |           |d         }~d _         fd}t          j        |j        |          }                     t           |                                 ~t                        	                    t           |                                                       j                   d S )Nzdef f(): passrV   Fc                     d_         d S )NT)called)rW   r+   s    r   callbackz,CodeWeakRefTest.test_basic.<locals>.callback  s    DKKKr   )
r;   rT   r  weakrefrefrQ   
assertTrueboolr   assertFalse)r+   r   rV   r  coderefs   `    r   
test_basiczCodeWeakRefTest.test_basic  s     	_gii333cN	 	 	 	 	 +aj(33WWYY(((ggii)))$$$$$r   N)r]   r^   r_   r!  rB   r   r   r  r    s#        % % % % %r   r  c                      t          |           S rA   )next)its    r   readr%    s    88Or   c                     t          |           }|dz  }d}|dz  r$t          |           }|dz  }||dz  |z  z  }|dz  $|S )N?   r   @      )r%  )r$  r   valshifts       r   read_varintr,    sb    RA
b&CE
b& HH
" b&  Jr   c                 @    t          |           }|dz  r|dz	   S |dz	  S r   )r,  )r$  uvals     r   read_signed_varintr/     s/    r??Dax |qyr   c              #     K   | j         }t          | j                  }	 	 t          |          }n# t          $ r Y d S w xY w|dz	  dz  } |dz  dz   }| dk    r| |d d d d fV  n| dk    rkt          |          }||z  }|t          |          z   }t          |          }|dk    rd }n|dz  }t          |          }|dk    rd }n|dz  }| |||||fV  n| dk    rt          |          }||z  }| |||d d fV  nr| d	v r3| d
z
  }||z  }t          |          }	t          |          }
| ||||	|
fV  n;d| cxk    rd
k     sn J t          |          }| dz  |dz	  z  }	| ||||	|	|dz  z   fV  N)NTrb   r3      rI      r      )
         r4  r   )r8   iterrx   r%  StopIterationr/  r,  )rW   r   r$  
first_bytelength
line_deltar   colend_colr   r   second_bytes               r   parse_location_tabler?  '  s     D	d	 	 B&R	bJJ 	 	 	FF	a2%q.A%2::tT488888RZZ+B//JJDk"oo-Hb//Caxxq!"ooG!||1xg>>>>>RZZ+B//JJDtT488888\!!JJD"XXFbJtVZ@@@@@NNNNNNNNNNr((KQY+"23FtVV{R?O5PQQQQM&Rs   0 
>>c              #   p   K   t          |           D ]#\  }}}}}}t          |          D ]
}||||fV  $d S rA   )r?  range)rW   r   r:  r   r   r<  r=  s          r   positions_from_location_tablerB  R  sf      3G3M3M 1 1/643v 	1 	1A300000	11 1r   c              #   ,   K   | D ]}||k    r|V  |}d S rA   rB   )lstprevitems      r   deduprG  W  s7        4<<JJJD r   c                 4    t          d | D                       S )Nc              3   $   K   | ]\  }}}}|V  d S rA   rB   )r   lr   s      r   	<genexpr>z&lines_from_postions.<locals>.<genexpr>^  s*      11|1a111111r   )rG  )r   s    r   lines_from_postionsrL  ]  s    11y111111r   c                  Z    d| z   }t           t          z   t          z   } |rt          nt          S )z






    r   )r   r   r   qp)r   r   s     r   
misshappenrP  `  sJ     	
 	
		
  	
	
 	  	
11 	r   c                  F    d                                 } t                      )Nz
            )stripr   )!example_report_generation_messages    r   bug93662rT    s!    egg & ,,r   c                   <    e Zd Zd Zd Zd Zd Zed             ZdS )CodeLocationTestc                 L   t          |j                                                  }t          t          |j                            }t	          ||          D ]\  }}|                     ||           |                     t          |          t          |                     d S rA   )rd   rQ   r   rB  r   r6   len)r+   rm   pos1pos2l1l2s         r   check_positionsz CodeLocationTest.check_positions  s    DM..00111$-@@AA$oo 	% 	%FBR$$$$TCII.....r   c                     |                      t                     |                      t                     |                      t                     d S rA   )r]  r?  rP  rT  r   s    r   test_positionszCodeLocationTest.test_positions  sE    1222Z(((X&&&&&r   c                    |j         }t          t          d |                                D                                 }t          t	          t          |                              }t          ||          D ]\  }}|                     ||           |                     t          |          t          |                     d S )Nc              3   "   K   | ]
\  }}}|V  d S rA   rB   )r   r   rJ  s      r   rK  z/CodeLocationTest.check_lines.<locals>.<genexpr>  s(      ==)1aA======r   )	rQ   rd   rG  r   rL  rB  r   r6   rX  )r+   rm   r%   lines1lines2r[  r\  s          r   check_lineszCodeLocationTest.check_lines  s    ]e==r{{}}=====>>)*G*K*KLLMM&&)) 	% 	%FBR$$$$Vc&kk22222r   c                     |                      t                     |                      t                     |                      t                     d S rA   )rd  r?  rP  rT  r   s    r   
test_lineszCodeLocationTest.test_lines  sE    -...$$$"""""r   c                    d }d}|j                             dt          t          j        d         dt          j        d         dt          j        d         dg          t          d	|d
z  z  dz  dg                    |_         |                     t          |           |                     t          |j         	                                          d
dgz             d S )Nc                      d S rA   rB   rB   r   r   rV   z/CodeLocationTest.test_code_new_empty.<locals>.f  r   r   r3  *   RESUMEr   LOAD_ASSERTION_ERRORRAISE_VARARGSrI      rb   ra   )r8   rK   rx   )ri  ri  NN)
rQ   rL   rM   r   r	   r9   AssertionErrorr6   rd   r   )r+   rV    PY_CODE_LOCATION_INFO_NO_COLUMNSs      r   test_code_new_emptyz$CodeLocationTest.test_code_new_empty  s    
	 	 	+-(Z''Ih'I45qIo.  71<> 	  ( 
 

$ 	.!,,,((**++%&&	
 	
 	
 	
 	
r   N)	r]   r^   r_   r]  r_  rd  rf  r   rp  rB   r   r   rV  rV    sk        / / /' ' '
3 3 3# # #
 
 
 \
 
 
r   rV  T)cpythonc                 
    | a d S rA   )
LAST_FREED)ptrs    r   myfreeru    s    


r   c                   \    e Zd Zd Zd Zd Zd Zd Z ej	                    d             Z
dS )CoExtrac                      t          d          S )Nz	lambda:42)evalr   s    r   get_funczCoExtra.get_func  s     $$$r   c           	         |                                  }|                     t          t          dt          t          j        d                     |                     t          t          dt          t          j        d                     d S )Nri  r   )rz  r9   SystemErrorSetExtra
FREE_INDEXctypesc_voidpGetExtrar  s     r   test_get_non_codezCoExtra.test_get_non_code  ss    Ak8R$nS113 3 3k8R$nS113 3 3 3 3r   c           	      :   |                                  }|                     t          t          |j        t
          dz   t          j        d                     |                     t          |j        t
          dz   t          j        d                    d           d S )Nr   r   )
rz  r9   r|  r}  rQ   r~  r  r  r6   r  r  s     r   test_bad_indexzCoExtra.test_bad_index  s    Ak8QZ(nfnS.A.AC C CXaj*S.$nS113 3457 7 7 7 7r   c                     |                                  }t          |j        t          t	          j        d                     ~|                     t          d           d S )Nr   )rz  r}  rQ   r~  r  r  r6   rs  r  s     r   test_free_calledzCoExtra.test_free_called  sN     AQZV^C-@-@AAAZ-----r   c                    |                                  }t          j                    }t          |j        t
          t          j        d                     t          |j        t
          t          j        d                     |                     t          d           t          j                    }t          |j        t
          |           |                     |j	        d           ~d S )N   i,  )
rz  r  r  r}  rQ   r~  r6   rs  r  r   )r+   rV   extras      r   test_get_setzCoExtra.test_get_set  s    AN$$EQZV^C-@-@AAAQZV^C-@-@AAAZ---N$$EQZU333U[#...r   c                 X   |                                  } G d dt          j                  }t          |j        t
          t          j        d                      |||           }~|                                 |	                                 | 
                    t          d           d S )Nc                   $     e Zd Z fdZd Z xZS )6CoExtra.test_free_different_thread.<locals>.ThreadTestc                 d    t                                                       || _        || _        d S rA   )r)   __init__rV   test)r+   rV   r  rD   s      r   r  z?CoExtra.test_free_different_thread.<locals>.ThreadTest.__init__  s+    GG$$&&&DF $DIIIr   c                 J    | ` | j                            t          d           d S )N  )rV   r  r6   rs  r   s    r   runz:CoExtra.test_free_different_thread.<locals>.ThreadTest.run  s%    I))*c:::::r   )r]   r^   r_   r  r  __classcell__rC   s   @r   
ThreadTestr    sG        % % % % %; ; ; ; ; ; ;r   r  r  )rz  	threadingThreadr}  rQ   r~  r  r  startjoinr6   rs  )r+   rV   r  tts       r   test_free_different_threadz"CoExtra.test_free_different_thread  s     A; ; ; ; ;Y- ; ; ; QZV^C-@-@AAAAt$$BHHJJJGGIIIZ-----r   N)r]   r^   r_   rz  r  r  r  r  r   requires_working_threadingr  rB   r   r   rw  rw    s        	% 	% 	%	3 	3 	3	7 	7 	7	. 	. 	.	 	 	  
5		4	6	6	. 	. 
7	6	. 	. 	.r   rw  c                 R    |                     t          j                               |S rA   )addTestdoctestDocTestSuite)loadertestspatterns      r   
load_testsr  "  s"    	MM'&(()))Lr   __main__)B__doc__r   r   r  r  unittestr   r  r   r  ImportErrortest.supportr   r   r   r   test.support.script_helperr   r   opcoder	   r
   r   r'   r-   TestCaser/   r   r   r  r%  r,  r/  r?  rB  objectrG  rL  rP  rT  rV  	pythonapipy	CFUNCTYPEr  freefunc_PyEval_RequestCodeExtraIndexRequestCodeExtraIndexargtypes	c_ssize_trestype_PyCode_SetExtrar}  	py_objectc_int_PyCode_GetExtrar  POINTERrs  ru  	FREE_FUNCr~  rw  r  r]   mainrB   r   r   <module>r     s  } }~  



         



MMMM   FFF& & & & & & & & & & & & 8 7 7 7 7 7 ) ) ) ) ) )      '(  2 2 28 8 8W, W, W, W, W,x  W, W, W,t2 2 2-$ -$ -$ -$ -$X& -$ -$ -$`% % % % %h' % % %4      )R )R )RV1 1 1
 FHH    2 2 2  @  9
 9
 9
 9
 9
x( 9
 9
 9
x T""" [.v'9		BvV^44H<&.["$*$4!"H)6+;V^LH|H"H)6+;'779H|HJ     I&&y11JB. B. B. B. B.(# B. B. B.J  
 zHMOOOOO s   ) 33