
    F\h`              	          % S SK r S SKrS SKrS SKrS SKrS SKrS SKrS SKrS SK	r	S SK
r
S SKrS SKrS SKrS SKrS SKrS SKJrJr  S SKJr  S SKJr  S SKJr  Sr\r\S-   rSrS	r\S
-   r\r\r \r!\"\ S4   r#\$\    r%\$\"\ \&4      r'\"\ S4   r(\)\ \(4   r*S\+S\4S jr,S\$\   S-  SS4S jr-SFS\.S\S\S-  S\4S jjr/S\.S\S\4S jr0SGS jr1S\SS4S jr2Sq3\S   S-  \4S'   SHS jr5SHS jr6Sq7\S   S-  \4S'   SHS jr8SHS  jr9S! r:S" r;SFS#\S-  S\4S$ jjr<SHS% jr=SIS'\S(\&S\4S) jjr>\ R~                  S* 5       r@S+\ S,\.SS4S- jrAS+\ S.\S-  S\ 4S/ jrB\C" S05      rDS&S1.S2\S3\&S\S-  4S4 jjrESHS5 jrFS\4S6 jrGS\&4S7 jrHS8\\   S\4S9 jrIS8\"\S4   S:\"\S4   S-  SS4S; jrJS#\SS4S< jrKS=S>S?S@.rLSA rM\R                  " SB5      rOSC rPSD\S\4SE jrQg)J    N)CallableIterable)support)	os_helper)threading_helpertest_python_worker_g      ^@)audioconsolecurses	largefilenetworkdecimalcpu
subprocessurlfetchguiwalltime)extralargefiletzdata.secondsreturnc                    [         R                  " U S-  5      n[        US5      u  p[        U S5      u  p [        US5      u  p2/ nU(       a  UR                  SU-  5        U(       a  UR                  SU-  5        U (       a5  U(       a  UR                  SU -  5        OUR                  SXS-  -   -  5        U(       d  SU-  $ US S	 nS
R	                  U5      $ )Ng     @@i  <   z%s hourz%s minz%s secz%.1f secz%s ms    )mathceildivmodappendjoin)r   msminuteshourspartss        -/usr/lib/python3.13/test/libregrtest/utils.pyformat_durationr'   =   s    	7S=	!BT"KGgr*GGR(NEEY&'X'(LLG+, LLwd':;<|"1IE88E?    namesc                     U (       d  g [        U 5       H2  u  p[        R                  R                  U5      u  p4US:X  d  M.  X0U'   M4     g )Nz.py)	enumerateospathsplitext)r)   idxnamebasenameexts        r&   strip_py_suffixr3   V   s=    u%	((.%<!#J &r(   nsingularpluralc                 &    U S:X  a  U$ Ub  U$ US-   $ )N   s )r4   r5   r6   s      r&   r6   r6   _   s#    Av		#~r(   wordc                 ,    U S:X  a  U  SU 3$ U  SU S3$ )Nr8   r   r9   r:   )r4   r;   s     r&   countr=   h   s+    AvAdV}AdV1~r(   c           
          SU-  n[        [        R                  " SR                  S [	        U 5       5       5      UXDS9US9  g)zPrint the elements of iterable x to stdout.

Optional arg width (default 70) is the maximum line length.
Optional arg indent (default 4) is the number of blanks with which to
begin each line.
r   c              3   8   #    U  H  n[        U5      v   M     g 7fN)str).0elts     r&   	<genexpr>printlist.<locals>.<genexpr>y   s      ?YcSYs   )initial_indentsubsequent_indent)fileN)printtextwrapfillr!   sorted)xwidthindentrH   blankss        r&   	printlistrQ   o   s>     6\F	(-- ?VAY ??'-Ir(   msgc                 0    [         R                  " U 5        g r@   )r   print_warning)rR   s    r&   rT   rT   ~   s    #r(   ).Norig_unraisablehookc                 |   S[         l        [         R                  " S5        [        R                  n [         R
                  " 5         [         R                  R                  [        l        [        c   S5       e[        U 5        [        R                  R                  5         U[        l        g ! U[        l        f = f)NTzUnraisable exceptionzorig_unraisablehook not set)	r   environment_alteredrT   sysstderrflush_std_streamsorig_stderrrU   flush)
unraisable
old_stderrs     r&   regrtest_unraisable_hookr_      s    "&G01J !!#**66
".M0MM.J'


Z
s   A/B. .B;c                  B    [         R                  q[        [         l        g r@   )rX   unraisablehookrU   r_   r:   r(   r&   setup_unraisable_hookrb      s    ,,1Cr(   orig_threading_excepthookc                    S[         l        [         R                  " SU R                  R                   35        [
        R                  n [         R                  " 5         [         R                  R                  [
        l        [        c   S5       e[        U 5        [
        R                  R                  5         U[
        l        g ! U[
        l        f = f)NTzUncaught thread exception: z!orig_threading_excepthook not set)r   rW   rT   exc_type__name__rX   rY   rZ   r[   rc   r\   )argsr^   s     r&   regrtest_threading_excepthookrh      s    "&G78N8N7OPQJ !!#**66
(4Y6YY4!$'


Z
s   
A/C Cc                  :    SS K n U R                  q[        U l        g )Nr   )	threading
excepthookrc   rh   )rj   s    r&   setup_threading_excepthookrl      s     ) 4 48Ir(   c                     [         R                  R                  5        H  n [        U S5      (       d  M  U ?M     [         R
                  [         R                  [         R                  [         R                  4 H  nUc  M  UR                  5         M      [         R                  S   nUR                  " 5          [         R                  S   nUR                  R                  5          [         R                  S   nUR                  5          [         R                  S   nUR                  5          [         R                  S   nUR!                  5          [         R                  S   nUR#                  5          [         R                  S   nUR$                  R                  5          [         R                  S	   n	U	R'                  5          [         R                  S
   n
S U
l         [         R                  S   nUR+                  5          [         R                  S   nUR,                   H
  nU" 5         M     SS Kn[1        UR2                  UR4                  R                  5       5      nU H.  nUR7                  5       U/-    H  nUR9                  5         M     M0      [         R                  S   nUR:                  R=                  5          [         R                  S   nUR>                  R=                  5         UR@                  R                  5         URB                  R                  5          [         R                  S   nURD                  RF                  R=                  5         g ! [         a     GNf = f! [         a     GNf = f! [         a     GNf = f! [         a     GNvf = f! [         a     GNcf = f! [         a     GNPf = f! [         a     GN3f = f! [         a     GN f = f! [         a     GNf = f! [         a     GNf = f! [         a     GNf = f! [         a     GNcf = f! [         a     GNf = f! [         a     g f = f)N__warningregistry__re	_strptimezurllib.parsezurllib.request	linecache	mimetypesfilecmpstructdoctestctypestypingr   	fractionsinspectzimportlib.metadata)$rX   modulesvalueshasattrrn   stdoutrY   
__stdout__
__stderr__r\   purgeKeyError_regex_cacheclearclear_cache
urlcleanup
clearcache_default_mime_types_cache_clearcachemaster_reset_cache	_cleanupsry   filter
isabstract__dict____subclasses___abc_caches_clear_hash_algorithmcache_clear%_shadowed_dict_from_weakref_mro_tuple_filesbymodnamemodulesbyfileFastPath__new__)modstreamro   rp   urllib_parseurllib_requestrq   rr   rs   rt   ru   rv   rw   fry   abs_classesabcobjrx   importlib_metadatas                       r&   clear_cachesr      s   {{!!#3-..' $ ::szz3>>3>>JLLN K[[ 	
'KK,	 	$$&#{{>2 	  "$%56 	!!#KK,	 	(KK,	 	%%'++i( 	X& 	++i( X& 	(X& !!AC " 	W//1G1G1IJC))+se3%%' 4 0KK,	 	!!--/&++i( 	55AAC%%'##%: [[)=> 	##++779O                            s   M& ;M7 )N N 1N* N; 9O 'O O. &O? 
P P! P2 .Q &
M43M47
NN
NN
N'&N'*
N87N8;
O	O	
OO
O+*O+.
O<;O<?
PP
PP!
P/.P/2
Q ?Q 
QQc                  6
   [         R                  " S5      =(       d    Sn [         R                  " S5      =(       d    SnUS[         R                  " S5      =(       d    S-   -  n[         R                  " S5      =(       d    Sn/ n[         R                  " S5      (       at  [        R                  R                  (       d-  [
        R                  R                  SS 5      nU(       a  US	:H  nOS nS
nUb  U S[        U5       3nUR                  U5        [        [        S5      (       a)  UR                  S5        SU;   a  UR                  S5        O@UR                  S5        SU ;   a  UR                  S5        OSU;  a  UR                  S5        [        R                  " SU5      nU(       a  [        UR                  S5      5      n[        R                  R                  (       d-  [
        R                  R                  SS 5      nU(       a  US:g  nOS nUS:X  a  US:X  a  SnOFSnOCUS:X  a  U(       a  SnO3SnO0US:X  a  US:X  a  SnO!SnOUS:X  a  U(       a  SnOSnOSU;   a  SnOS nU(       a  UR                  U5        [         R                  " S 5      n	U	(       a  UR                  S!U	 35        [        [         R                  " S"5      =(       d    S5      n
U
(       a  UR                  S#5        / nS$U;   a  UR                  S%5        OS&U;   a  UR                  S'5        [        R                  " 5       (       a  UR                  S(5        [        R                   " 5       (       a  UR                  S)5        U(       a   UR                  S*R#                  U5      5        / n[        R$                  " S+S,9(       a  UR                  S-5        [        R$                  " S+S.9(       a  UR                  S/5        [        R$                  " S+S09(       a  UR                  S15        [        R$                  " S+S29(       a  UR                  S35        U(       a   UR                  S*R#                  U5      5        [        [        S45      (       a  UR                  S55        [        [        S65      (       a  UR                  S75        [         R                  " S85      (       a  UR                  S95        [         R                  " S:5      (       a  UR                  S;5        U$ )<NCONFIG_ARGS 	PY_CFLAGSr   PY_CFLAGS_NODISTPY_LDFLAGS_NODISTPy_GIL_DISABLED
PYTHON_GIL1free_threadingz GIL=gettotalrefcountdebugz-DNDEBUGwithout_assertreleasez--with-assertionswith_assertz-D_Py_TIER2=([0-9]+)r8   
PYTHON_JIT0FzJIT=offJIT      zJIT-interpreter=offzJIT-interpreter   z	-D_Py_JITPYTHONFRAMEWORKz
framework=PY_ENABLE_SHAREDsharedz
-flto=thinThinLTOz-fltoLTOPGOBOLT+TaddressASANmemoryMSANubUBSANthreadTSAN
getobjects	TraceRefs	_stats_onpystatsWITH_VALGRINDvalgrindWITH_DTRACEdtrace)	sysconfigget_config_varrX   flagsignore_environmentr,   environgetintr    r|   ro   searchgroupr   check_cflags_pgocheck_bolt_optimizedr!   check_sanitizer)config_argscflagsldflags_nodistbuildr   r   tier2r   jit	frameworkr   optimizations
sanitizerss                r&   get_build_infor   +  s    **=9?RK%%k28bF
cY--.@AGRHHF--.ABHbNE  122yy++d;J(C/
J)! ./uS_4EFN^$s&''WLL)*Y+-LL'v%LL' II,f5EEKKN#99''ZZ^^L$7
$+J
zCC	!CC	!'C#C	!#C'C		
S (():;Iz)-. ))*<=DEFX M~%Y'	N	"U#!!U###%%V$SXXm,- Jt,&!d+&!$''"d+&!SXXj)* sL!![!sK  Y00Z ..XLr(   tmp_dirc                    U (       a!  [         R                  R                  U 5      n GO&[        R                  " 5       (       a  [
        R                  (       d  [        R                  " S5      n U cE  [        R                  " S5      n U (       d(  [        R                  " S5      n U (       d  [        S5      e[         R                  R                  U S5      n Ox[        R                  " S5      n U (       d  [        SU < S35      e[         R                  R                  U S5      n [         R                  " U S	S
9  O[        R                  " 5       n [         R                  R                  U 5      $ )Nabs_builddir
abs_srcdirsrcdirz1Could not determine the correct value for tmp_dirr   projectbasez>sysconfig.get_config_var('projectbase') unexpectedly returned z on WASIT)exist_ok)r,   r-   
expanduserr   is_python_buildr   is_wasir   RuntimeErrorr!   makedirstempfile
gettempdirabspath)r   s    r&   get_temp_dirr     s   ''$$W-
 $$&&??#22>B?'66|DG"
 #,":":8"D&". S#  '',,w8 $22=A&1188E  '',,w8 Gd3))+G77??7##r(   c                      [         R                  (       aJ  [        R                  " S5      n U S:X  a  [        R                  " S5        g [        R                  " U 5        g g )Nr   i     )r   is_emscriptenr,   umask)old_masks    r&   	fix_umaskr     s>     88A;uHHUOHHX r(   F
parent_dirworkerc                 p   [         R                  (       d  [         R                  (       a  [        R                  " SS5      nO[
        R                  " 5       nU(       a  [        [        U5      -   nO[        [        U5      -   nU[        R                  -  n[
        R                  R                  X5      nU$ )Nr   i@B )r   r   r   randomrandintr,   getpidWORK_DIR_PREFIXrA   WORKER_WORK_DIR_PREFIXr   FS_NONASCIIr-   r!   )r   r  nouncework_dirs       r&   get_work_dirr    st     9-"S[0)CK7	%%%Hww||J1HOr(   c               #      #     S v   g ! [          aX  n [        R                  (       a  [        R                  " [
        SS9  [        R                  " U R                  5         S n A g S n A ff = f7f)NT)exit)	
SystemExitr   can_start_threadfaulthandlerdump_traceback_laterEXIT_TIMEOUTrX   r  code)excs    r&   exit_timeoutr     sJ       ,,--lFs+   A.	 A.
A+AA&!A.&A++A.	test_nameverbosec           
         [         R                  n[        R                  R	                  U5      (       d  g [        R                  R                  U5      (       a  SS KnSUR                  pTOF[        R                  R                  U5      (       a  S[        R                  pTO[        SU< S35      eU(       a  [        U  SU SU< 35        S[        l         SS Kn[        R                  " X&R                   UR"                  -  UR$                  -  5        U" U5        g ! [&         a!  n[        U  SU SU< S	U 35         S nAg S nAff = f)
Nr   	directoryrH   zos.path says z) exists but is neither directory nor filez left behind r   Tz and it couldn't be removed: )r   TESTFNr,   r-   existsisdirshutilrmtreeisfileunlinkr   rT   r   rW   statchmodS_IRWXUS_IRWXGS_IRWXO	Exception)r  r  r0   r  kindnukerr!  r  s           r&   remove_testfnr)    s    D77>>$ 
ww}}T!6==e			biie]4( 30 1 2 	2 =ax@A&*#<
||dll2T\\ABd <=ax @558E; 	< 	<<s   AD   
E*EEtest_dirc                 J    U R                  S5      (       d  U(       a  U $ SU -   $ )Nztest.)
startswith)r  r*  s     r&   abs_module_namer-  1  s(    G$$ ""r(   )
setUpClasstearDownClasssetUpModuletearDownModule)is_errortest_full_namer2  c                    U R                  S5      S   nU(       a\  U[        ;   aR  U R                  S5      (       a  g U R                  S5      nU R                  S5      nXS-   U R                  S5      S   $ U$ )	Nr   r   )zsetUpModule (ztearDownModule (()r8   .)split_TEST_LIFECYCLE_HOOKSr,  index)r3  r2  
short_namelparrpars        r&   normalize_test_namer?  A  s    %%c*1-JJ"77$$%JKK  ##C(##C(Qh-33C8<<r(   c            
      \    SSK n U R                  U R                  5      u  pSnX:  aA  X:  a;  [	        X25      n U R                  U R                  XB45        [        SU SU 35        ggg! [         a     gf = f! [        [        4 a  n[        SU SU SU S	35         SnAgSnAff = f)
z
On macOS the default fd limit (RLIMIT_NOFILE) is sometimes too low (256)
for our test suite to succeed. Raise it to something more reasonable. 1024
is a common Linux default.
r   Ni   zRaised RLIMIT_NOFILE: z -> z#Unable to raise RLIMIT_NOFILE from z to z: r7  )
resourceImportError	getrlimitRLIMIT_NOFILEmin	setrlimitrI   
ValueErrorOSErrorrT   )rA  fd_limitmax_fdsdesired_fdsnew_fd_limiterrs         r&   adjust_rlimit_nofilerN  W  s     !**8+A+ABHK("4;0	5x55 ,68*8*DGH #5   G$ 	5?z)N"SE4 5 5	5s(   A, .A< ,
A98A9<B+B&&B+c                  v    [         R                  R                  S5      =n c  [        R                  " S5      n U $ )N_PYTHON_HOSTRUNNER
HOSTRUNNER)r,   r   r   r   r   )
hostrunners    r&   get_host_runnerrS  q  s1    jjnn%9::
C--l;
r(   c                  (    S[         R                  ;   $ )N_PYTHON_HOST_PLATFORM)r,   r   r:   r(   r&   is_cross_compiledrV  w  s    #rzz12r(   use_resourcesc                    [        U 5      n [        [        5      nS/n[        X-
  5       H  nUR                  SU 35        M     [        X-
  5       H  nUR                  U 5        M     SR	                  U5      nSU 3nSR	                  [        U 5      5      nS[        U 5       SU 3n[        U5      [        U5      ::  a  U$ U$ )Nall-,zresources: zresources (z): )setALL_RESOURCESrL   r    r!   len)rW  all_resourcesrelative_allr0   all_texttexts         r&   format_resourcesrc  {  s    &M&M 7L}45avJ' 6}45tf& 6xx%HXJ'H 88F=)*D]+,Cv6D 8}D	!r(   
python_cmdc                 P   [        S[        R                  " 5       /[        R                  R                  5       Q76   [        S[        R                  " SS9S[        R                  -  5        [        SSR                  [        5       5      5        [        S[        R                  " 5       5        [        R                  " 5       nU(       a5  [        R                  " 5       nU(       a  X2:w  a  U SU S	3n[        S
U5        [        S[        R                  " 5       < S[        R                  " 5       < 35        U (       a  [!        U 5      n[        SU 35        O[        S5        [#        5       nU(       a  [        S5        U(       a  [$        R                  " U5      n[        SU 35        / UQSPSPn[&        R(                  " U[&        R*                  S[,        R.                  S9nUR0                  R3                  SS5      R5                  5       n	U	(       a  [        SU	 35        OJUR6                  (       a  [        SUR6                   S35        O[9        5       n
U
(       a  [        SU
 35        [:        R<                  " SS9n[:        R<                  " SS9n[:        R<                  " SS9n[:        R<                  " SS9n/ nU(       a  UR?                  S5        U(       a  UR?                  S5        U(       a  UR?                  S5        U(       a  UR?                  S 5        U(       at  [        S!S"R                  U5       35        US#4US$4US%4US&44 HE  u  nn[        R@                  RC                  U5      nU(       d  M.  Uc  M3  [        SU S'U< 35        MG     [        SS(9  g ))Nz==T)aliasedz	%s-endianz== Python build:r   z== cwd:z (process) / z	 (system)z== CPU count:z== encodings: locale=z FS=z== zL== resources: all test resources are disabled, use -u option to unskip testsz== cross compiled: Yesz== host python: z-mplatform)r}   rb  cwd
z== host platform: z1== host platform: <command failed with exit code >z== host runner: r   r   r   r   r   r   zundefined behaviorr   z== sanitizers: z, ASAN_OPTIONSMSAN_OPTIONSUBSAN_OPTIONSTSAN_OPTIONS=)r\   )"rI   rg  python_implementationrX   versionr9  	byteorderr!   r   r,   getcwd	cpu_countprocess_cpu_countlocalegetencodinggetfilesystemencodingrc  rV  shlexr   runPIPEr   SAVEDCWDr}   replacestrip
returncoderS  r   r   r    r   r   )rW  rd  rt  ru  rb  cross_compilecmdget_cmdprocr}   rR  asanmsanubsantsanr   	sanitizerenv_varoptionss                      r&   display_headerr    s    
$..0G3;;3D3D3FG	$!!$/-/	
chh~'789	)RYY[!I002!2!?,-]9+YOIoy)	!3#<#<#>@ A .D6l . 	/ &'M&'jj$ &'1J11j1~~??""	$
 $$T3/557&vh/0__EdooEVVWXY$&
$ZL12 ""40D""$/D##t,E""$/DJ)$(#./(#		* 5678>">"O$>"	#
Iw ZZ^^G,GyW0G9Ag[12#
 
r(   c                    SS K n[        R                  R                  UR	                  U 5      [
        S-   5      n[        SU -  5        UR                  U5       Hq  n[        R                  R                  U5      (       a&  [        SU-  5        [        R                  " U5        MM  [        SU-  5        [        R                  " U5        Ms     g )Nr   *zCleanup %s directoryzRemove directory: %szRemove file: %s)globr,   r-   r!   escape
TMP_PREFIXrI   r  r   r  r   )r   r  r-   r0   s       r&   cleanup_temp_dirr    s    77<<G,j3.>?D	
 7
*+		$77==(4/0T"#d*+T"  r(   STATUS_ACCESS_VIOLATIONSTATUS_STACK_OVERFLOWSTATUS_CONTROL_C_EXIT)l       l       l   :   c                 6   U S:  a$  U * n [         R                  " U5      R                  $ SU s=:  a  S:  a)  O  O&U S-
  n [         R                  " U5      R                  $  [        U    $ ! [         a     NLf = f! [         a     N&f = f! [
         a     g f = f)Nr         )signalSignalsr0   rG  WINDOWS_STATUSr   )exitcodesignums     r&   get_signal_namer    s    !|	>>&)...
 XC	>>&)...h''  		  		
  s5   A+ A; "B +
A87A8;
BB
BBu   [ ---￾￿]+c                 <    U S   nSR                  S U 5       5      $ )Nr   r   c              3   h   #    U  H(  nUS ::  a  S[        U5      S 3O[        U5      SS v   M*     g7f)   ÿz\x02xr8   r8  N)ordascii)rB   chs     r&   rD   (_sanitize_xml_replace.<locals>.<genexpr>  s9      #!r +-,SR&E"IaOK!s   02)r!   )regsrb  s     r&   _sanitize_xml_replacer    s)    7D77 #!# # #r(   rb  c                 6    [         R                  [        U 5      $ r@   )ILLEGAL_XML_CHARS_REsubr  )rb  s    r&   sanitize_xmlr    s    ##$94@@r(   r@   )F   r   N)r   N)F)R
contextlibr  rv  r   os.pathr,   rg  r  ro   ry  r  r   rX   r   r   rJ   collections.abcr   r   testr   test.supportr   r   r  r  r  r  r]  RESOURCE_NAMESrA   StrPathTestNameStrJSONtuple	TestTuplelistTestListbool
TestFilterFilterTupledict
FilterDictfloatr'   r3   r   r6   r=   rQ   rT   rU   __annotations__r_   rb   rc   rh   rl   r   r   r   r   r  contextmanagerr  r)  r-  	frozensetr:  r?  rN  rS  rV  rc  r  r  r  r  compiler  r  r  r:   r(   r&   <module>r     s'          	    
    .  " )
 
(94 
 P !== 
(C- 	> %$'(
HcM"(K'(
U s 2"49t+ " "c S #*  S   s t  37 Xi(4/ 6 2 9= 8I.5 < 9u:pGT)$'D. )$G )$XW d w (  "<X "< "< "<J#x #7T> #h # " #   */ "&36:,54 34 3HSM c 0L%S/ L$S#X5L:>L^#g #$ # *''0 zz		

 #
As As Ar(   