+
    Bi                         ^ RI t ^ RIt^ RIt^ RIt^ RIHt ^ RIHt ^ RIH	t	H
t
 ^ RIHt  ^ RIt^ RIHt ]P                   ! 4        ! R R]4      4       t]R	8X  d   ]P&                  ! 4        R# R#   ] d    Rt LLi ; i)
    N)Or)partial)BarrierThread)TestCase)threading_helperc                   \   a  ] tR t^t o R tR tR tR t]3R lt	R t
R tR tR	 tR
tV tR# )TestDictc                F     ! R R\         4      pV P                  V4       R# )zUVerify that creating dictionaries is thread safe when we
have a type with shared keysc                       ] tR t^tRtR# )4TestDict.test_racing_creation_shared_keys.<locals>.C N__name__
__module____qualname____firstlineno____static_attributes__r       9/usr/lib/python3.14/test/test_free_threading/test_dict.pyCr          r   r   N)intracing_creation)selfr   s   & r    test_racing_creation_shared_keys)TestDict.test_racing_creation_shared_keys   s    	 	 	Qr   c                0    V P                  \        4       R# )zZVerify that creating dictionaries is thread safe when we
have a type with an ordinary dictN)r   r   )r   s   &r   #test_racing_creation_no_shared_keys,TestDict.test_racing_creation_no_shared_keys   s     	R r   c                J   a  ! R R4      oV3R lpV P                  V4       R# )zQVerify that re-creating a dict after we have invalid inline values
is thread safec                       ] tR t^%tRtR# )>TestDict.test_racing_creation_inline_values_invalid.<locals>.Cr   Nr   r   r   r   r   r#   %   r   r   r   c                  (   < S! 4       p / V n         V = V # N__dict__)ar   s    r   make_objETestDict.test_racing_creation_inline_values_invalid.<locals>.make_obj(   s    AAJ
Hr   Nr   )r   r)   r   s   & @r   *test_racing_creation_inline_values_invalid3TestDict.test_racing_creation_inline_values_invalid"   s"    	 		 	X&r   c                4    R pR pV P                  W4       R# )zsVerify that explicit creation of an unmanaged dict is thread safe
outside of the normal attribute setting code pathc                      R  p V # )c                      R # r%   r   r   r   r   fJTestDict.test_racing_creation_nonmanaged_dict.<locals>.make_obj.<locals>.f5   s    Tr   r   )r1   s    r   r)   ?TestDict.test_racing_creation_nonmanaged_dict.<locals>.make_obj4   s
    Hr   c                 "    W P                   V&   R # r%   r&   )funcnamevals   &&&r   set:TestDict.test_racing_creation_nonmanaged_dict.<locals>.set8   s    "%MM$r   Nr+   )r   r)   r8   s   &  r   $test_racing_creation_nonmanaged_dict-TestDict.test_racing_creation_nonmanaged_dict1   s    		& 	X+r   c           	     @  aaaaa . o. o^do^
p^ o\        S4       F  pSP                  V! 4       4       K  	  VVVVV3R lp. p\        V4       F>  p\        \        VRVR 24      R7      pVP                  V4       VP	                  4        K@  	  \        S4       F=  pVo\        S4      V8w  d   \        P                  ! R4       K(  SP                  4        K?  	  SoV F  pVP                  4        K  	  \        S4       F  w  r\        V4       F  pK  	  K  	  R# )d   c                    < Rp SV8X  d   \         P                  ! R4       K   SS8X  d   R# SS,          pS! W V 4       SpSP                  V 4       KP  )   MbP?N)timesleepappend)r6   lastobjCUROBJECT_COUNTobjects	processedr8   s   &  r   writer_func-TestDict.racing_creation.<locals>.writer_funcI   sR    D$;JJu%L(clCt$  &r   r(   02targetr@   N)rangerD   r   r   startlenrB   rC   clearjoin	enumerate)r   clsr8   THREAD_COUNTirK   writersxwriterobj_idxrF   rG   rH   rI   rJ   s   &&f        @@@@r   r   TestDict.racing_creation>   s    	|$ANN35! %	' 	' |$A7;!Ab6
#CDFNN6"LLN %
 |$ACi.L0

5!OO	 % FKKM  &g.LG <((	 /r   c                  a
a R o. p^
p ! R R\         4      o
V
V3R lp. p. p\        V4       F<  p. pVP                  V4       \        \	        W74      R7      pVP                  V4       K>  	  V F  pVP                  4        K  	  V F  pVP                  4        K  	  / Sn        \        P                  ! 4        V F"  pV F  p	V P                  V	! 4       4       K  	  K$  	  R# )1Races assigning to __dict__ should be thread safec                      R # r%   r   r   r   r   r1   (TestDict.test_racing_set_dict.<locals>.fr   s    r   c                       ] tR t^utRtR# )-TestDict.test_racing_set_dict.<locals>.MyDictr   Nr   r   r   r   MyDictrc   u       Dr   rd   c                    < \        R 4       F6  pS! 4       pV P                  \        P                  ! V4      4       VSn        K8  	  R#   NrP   rD   weakrefrefr'   )lrX   drd   r1   s   &  r   rK   2TestDict.test_racing_set_dict.<locals>.writer_funcw   s3    4[HQ(
 !r   rN   N)dictrP   rD   r   r   rQ   rT   r'   gccollectassertIsNone)r   rl   rW   rK   listsrY   rZ   thread_listr[   rk   rd   r1   s   &         @@r   test_racing_set_dictTestDict.test_racing_set_dicto   s     	 T 	 |$AKLL%7;#DEFNN6"	 % FLLN  FKKM  



 K"!!#%( # !r   c                   a ^
p\        V4      oV3R lp/ p. p\        V4       F  pVP                  \        W#.R7      4       K!  	  V F  pVP	                  4        K  	  V F  pVP                  4        K  	  R# )z6Races getting and setting a dict should be thread safec                    < SP                  4        \        R 4       F#  p^ V ^
&   V P                  ^
R4       V ^
,          pK%  	  R# rg   )waitrP   get)rm   _barriers   & r   work/TestDict.test_racing_get_set_dict.<locals>.work   s9    LLN4["b$bE !r   )rO   argsN)r   rP   rD   r   rQ   rT   )r   rW   r}   rm   worker_threadsiitr|   s   &      @r   test_racing_get_set_dict!TestDict.test_racing_get_set_dict   sm    ,'	 %B!!&3"?@ &AGGI  AFFH  r   c           	       aaa  ! R R4      p ! R R\         4      oR
 EF  oV! 4       oR^*/Sn        ^
pVVV3R lpV3R lp. p. p. p\        V4       F<  p. p	VP                  V	4       \	        \        W94      R7      p
VP                  V
4       K>  	  \        V4       F)  p\	        \        V4      R7      pVP                  V4       K+  	  V F  p
V
P                  4        K  	  V F  pVP                  4        K  	  V F  p
V
P                  4        K  	  V F  pVP                  4        K  	  / Sn        \        P                  ! 4        \        P                  ! 4        ^ p\        4       pV FS  p	\        V	4       FA  w  rV! 4       f   K  V^,          pVP                  \        V! 4       4      4       V^,          pKC  	  KU  	  V P                  V^ 4       EK  	  R	# )r_   c                       ] tR t^tRtR# )/TestDict.test_racing_set_object_dict.<locals>.Cr   Nr   r   r   r   r   r      s    r   r   c                       ] tR t^tRtR# )4TestDict.test_racing_set_object_dict.<locals>.MyDictr   Nr   r   r   r   rd   r      re   r   rd   fooc                    < \        R 4       FT  pS'       d   / pS! R^d/4      pS'       d
   XVR&   W2R&   V P                  \        P                  ! V4      4       VSn        KV  	  R# )rh   r   rZ   barNri   )rl   rX   other_drm   rd   cyclicr1   s   &   r   rK   9TestDict.test_racing_set_object_dict.<locals>.writer_func   sU    tA"$s|,A!(#)*HHW[[^,!"AJ %r   c                  D   < \        R 4       F  p SP                   K  	  R# rg   )rP   r   )rX   r1   s    r   reader_func9TestDict.test_racing_set_object_dict.<locals>.reader_func   s    tAEE %r   rN   N)FT)ro   r'   rP   rD   r   r   rQ   rT   rp   rq   r8   rU   addidassertEqual)r   r   rW   rK   r   rs   readersrY   rZ   rt   r[   readercountidsrX   rk   rd   r   r1   s   &               @@@r   test_racing_set_object_dict$TestDict.test_racing_set_object_dict   s    T #FAAJL	# EGG<( [)w{'HIv&	 ) <(w{';<v& ) " "! " " " " " AJJJLJJLE%C$'4FAu} QJEGGBsuI&QJE 5  % UA&u $r   c                   a \        4       oV3R  lpV3R lp\        VR7      p\        VR7      p\        P                  ! W4.4      ;_uu_ 4         RRR4       R#   + '       g   i     R# ; i)c                  >   < \        R 4       F  p ^^/Sn        K  	  R# i'  NrP   r'   rX   es    r   r[   8TestDict.test_racing_object_get_set_dict.<locals>.writer   s    5\U
 "r   c                  D   < \        R 4       F  p SP                   K  	  R# r   r   r   s    r   r   8TestDict.test_racing_object_get_set_dict.<locals>.reader   s    5\

 "r   rN   N)	Exceptionr   r   start_threads)r   r[   r   t1t2r   s   &    @r   test_racing_object_get_set_dict(TestDict.test_racing_object_get_set_dict   sO    K	#	 6"6"++RH55 6555s   AA,	r   N)r   r   r   r   r   r   r,   r:   setattrr   ru   r   r   r   r   __classdictcell__)__classdict__s   @r   r
   r
      s@      !
', (/ /Sb!)F*>'@ r   r
   __main__)rp   rB   unittestrj   astr   	functoolsr   	threadingr   r   r   	_testcapiImportErrortest.supportr   requires_working_threadingr
   r   mainr   r   r   <module>r      s    	      %  * ,,.bx b /bH zMMO W  Is   A1 1	A=<A=