
    z%i                         d dl Z d dlZd dlZd dlZd dlZd dlmZ d Zde	e
   fdZd ZddZd Zdad	 Zd
 Zdad Zd Zd Zd Zy)    N)supportc                    t        j                  | dz        }t        |d      \  } }t        | d      \  }} t        |d      \  }}g }|r|j                  d|z         |r|j                  d|z         | r1|r|j                  d| z         n|j                  d| |dz  z   z         |sd|z  S |d d	 }d
j	                  |      S )Ng     @@i  <   z%s hourz%s minz%s secz%.1f secz%s ms    )mathceildivmodappendjoin)secondsmsminuteshourspartss        J/home/uftp/.pyenv/versions/3.12.0/lib/python3.12/test/libregrtest/utils.pyformat_durationr   	   s    	7S=	!BT"KGRgr*GWGR(NE7EY&'X'(LLG+, LLwd':;<|"1IE88E?    namesc                     | sy t        |       D ]2  \  }}t        j                  j                  |      \  }}|dk(  s.|| |<   4 y )Nz.py)	enumerateospathsplitext)r   idxnamebasenameexts        r   strip_py_suffixr   "   sH    u% "	T((.#%<!E#J"r   c                 (    | dk(  rd| |fz  S d| |fz  S )N   z%d %sz%d %ss )nwords     r   countr%   +   s'    Av!T""1d)##r   c           
          d|z  }t        t        j                  dj                  d t	        |       D              |||      |       y)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   2   K   | ]  }t        |        y wN)str).0elts     r   	<genexpr>zprintlist.<locals>.<genexpr><   s      ?cS ?s   )initial_indentsubsequent_indent)fileN)printtextwrapfillr   sorted)xwidthindentr/   blankss        r   	printlistr8   2   s@     6\F	(-- ?VAY ??'-Ir   c                 .    t        j                  |        y r(   )r   print_warning)msgs    r   r:   r:   A   s    #r   c                 \   dt         _        t        j                  d       t        j                  }	 t        j
                          t         j                  j                  t        _        t        |        t        j                  j                          |t        _        y # |t        _        w xY w)NTzUnraisable exception)	r   environment_alteredr:   sysstderrflush_std_streamsorig_stderrorig_unraisablehookflush)
unraisable
old_stderrs     r   regrtest_unraisable_hookrF   H   sm    "&G01J !!#**66
J'


Z
s   A B B+c                  B    t         j                  at        t         _        y r(   )r>   unraisablehookrB   rF   r"   r   r   setup_unraisable_hookrI   V   s    ,,1Cr   c                    dt         _        t        j                  d| j                  j                          t
        j                  }	 t        j                          t         j                  j                  t
        _        t        |        t
        j                  j                          |t
        _        y # |t
        _        w xY w)NTzUncaught thread exception: )r   r=   r:   exc_type__name__r>   r?   r@   rA   orig_threading_excepthookrC   )argsrE   s     r   regrtest_threading_excepthookrO   _   s    "&G78N8N7OPQJ !!#**66
!$'


Z
s   	A B5 5Cc                  :    dd l } | j                  at        | _        y )Nr   )	threading
excepthookrM   rO   )rQ   s    r   setup_threading_excepthookrS   m   s     ) 4 48Ir   c                     t         j                  j                         D ]  } t        | d      s| ` t         j
                  t         j                  t         j                  t         j                  fD ]  }||j                           	 t         j                  d   }|j                          	 t         j                  d   }|j                  j                          	 t         j                  d   }|j                          	 t         j                  d   }|j                          	 t         j                  d   }|j!                          	 t         j                  d   }|j#                          	 t         j                  d   }|j$                  j                          	 t         j                  d	   }	|	j'                          	 t         j                  d
   }
d |
_        	 t         j                  d   }|j+                          	 t         j                  d   }|j,                  D ]	  } |         	 	 t         j                  d   }|j.                  j1                          	 t         j                  d   }|j2                  j1                          y # t        $ r Y w xY w# t        $ r Y w xY w# t        $ r Y w xY w# t        $ r Y w xY w# t        $ r Y w xY w# t        $ r Y ww xY w# t        $ r Y Yw xY w# t        $ r Y Ew xY w# t        $ r Y :w xY w# t        $ r Y &w xY w# t        $ r Y 	w xY w# t        $ r Y w xY w# t        $ r Y y w xY w)N__warningregistry__re	_strptimezurllib.parsezurllib.request	linecache	mimetypesfilecmpstructdoctestctypestyping	fractionsinspect)r>   modulesvalueshasattrrU   stdoutr?   
__stdout__
__stderr__rC   purgeKeyError_regex_cacheclearclear_cache
urlcleanup
clearcache_default_mime_types_cache_clearcachemaster_reset_cache	_cleanups_hash_algorithmcache_clear_shadowed_dict_from_mro_tuple)modstreamrV   rW   urllib_parseurllib_requestrX   rY   rZ   r[   r\   r]   r^   fr_   r`   s                   r   clear_cachesr|   t   s+   {{!!# (3-.'( ::szz3>>3>>J LLN[[ 	
'KK,	 	$$&#{{>2 	  "$%56 	!!#KK,	 	(KK,	 	%%'++i( 	X& 	++i( X& 	X& !! 	AC	0KK,	 	!!--/<++i( 	--99;q                          s   
J .J J&  J6 $K K ,K& K6 >L L =L& *L6 M 	JJ	J#"J#&	J32J36	KK	KK	K#"K#&	K32K36	LL	LL	L#"L#&	L32L36	MM	MMc                    	 t        j                  d      xs d} t        j                  d      xs d}t        j                  d      xs d	t        j                  d      xs d}g }t        t        d      r*|j	                  d       d|	z   v rQ|j	                  d	       n?|j	                  d
       d| v r|j	                  d       nd|	z   vr|j	                  d       t        j                  d      }|r|j	                  d|        t        t        j                  d      xs d      }|r|j	                  d       g }d|v r|j	                  d       nd|v r|j	                  d       d}t        	fd|D              r|j	                  d       |r |j	                  dj                  |             g }t        j                  d      r|j	                  d       t        j                  d      r|j	                  d       t        j                  d      r|j	                  d        |r |j	                  dj                  |             t        t        d!      r|j	                  d"       t        t        d#      r|j	                  d$       t        j                  d%      r|j	                  d&       t        j                  d'      r|j	                  d(       |S ))NCONFIG_ARGS 	PY_CFLAGSPY_CFLAGS_NODISTPY_LDFLAGS_NODISTgettotalrefcountdebugz-DNDEBUGwithout_assertreleasez--with-assertionswith_assertPYTHONFRAMEWORKz
framework=PY_ENABLE_SHARED0sharedz
-flto=thinThinLTOz-fltoLTO)z-fprofile-usez-fprofile-instr-usez	-prof-usec              3   &   K   | ]  }|v  
 y wr(   r"   )r*   optioncflags_nodists     r   r,   z!get_build_info.<locals>.<genexpr>  s     
=v6]"
=s   PGO+T)addressASAN)memoryMSAN)ubUBSAN
getobjects	TraceRefs	_stats_onpystatsWITH_VALGRINDvalgrindWITH_DTRACEdtrace)
	sysconfigget_config_varrc   r>   r   intanyr   r   check_sanitizer)
config_argscflagsldflags_nodistbuild	frameworkr   optimizationspgo_options
sanitizersr   s
            @r   get_build_infor      si    **=9?RK%%k28bF,,-?@FBM--.ABHbNEs&'W&=01LL)*Y+-LL' 67LL' (():;Iz)-. ))*<=DEFX M~%Y'	N	"U#K 
=
==U#SXXm,- Jt,&!d+&!$''"SXXj)* sL![!sK Y0Z .XLr   )F      N)r   os.pathr   r>   r   r1   testr   r   listr)   r   r%   r8   r:   rB   rF   rI   rM   rO   rS   r|   r   r"   r   r   <module>r      sl      
   2"49 "$   2 !  9f<RQr   