
    /hh%                    P   S SK Jr  S SKJrJrJrJr  S SKrS SKJ	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\R,                  (       d  \R.                  " S5      e S SKr\R4                  S:H  rS rSrSrS	r\R@                  (       a  \r!O\r!\"" \S
5      r#Sr$Sr%Sr&Sr'Sr(\RR                  " S5      (       a  SOSr*\RV                  RY                  \RZ                  \R\                  S\R^                  R`                   S\R^                  Rb                   35      r2\RV                  Rg                  \RV                  RY                  \2S5      5      (       d  Sr2S r4S r5 " S S5      r6 " S S\6\Rn                  5      r8\Rr                  " \SL S5       " S S\6\Rn                  5      5       r: " S S\Rn                  5      r; " S S \6\Rn                  5      r< " S! S"\6\Rn                  5      r=\>S#:X  a  \R~                  " 5         gg! \ a    Sr GNf = f)$    )support)import_helper	os_helperthreading_helper
MS_WINDOWSN)
namedtupleztest module requires subprocessdarwin         	_stats_on      l    Py_GIL_DISABLEDt python.os.pyc                     [         R                  R                  U 5      n [         R                  R                  U 5      S   nUR	                  5       R                  SR	                  5       5      $ )Nr   _d)ospathbasenamesplitextcasefoldendswith)programnames     8/opt/python-3.13.8/usr/lib/python3.13/test/test_embed.pydebug_buildr!   >   sL    ggw'G77G$Q'D==?##DMMO44    c                      [        [        R                  5      n [        U 5       H  nUR	                  S5      (       d  M  X	 M     U $ )NPYTHON)dictr   environlist
startswith)envkeys     r    remove_python_envvarsr+   D   s9    
rzz
CCy>>(##  Jr"   c                   <    \ rS rSrS rS rSSSSSS.S jrS rS	rg)
EmbeddingTestsMixinM   c                 ,   Sn[         R                  R                  [        R                  5      n[
        (       a,  [        [        R                  5      (       a  SOSS-   nX-  nUnO [         R                  R                  US5      n[         R                  R                  XA5      =U l        n[         R                  R                  U5      (       d  U R                  SU-  5        [         R                  " 5       U l        [         R                  " U5        g )N
_testembedr   r   .exeProgramsz%r doesn't exist)r   r   dirnamesys
executabler   r!   jointest_exeexistsskipTestgetcwdoldcwdchdir)selfexenamebuilddirextexepathexes         r    setUpEmbeddingTestsMixin.setUpN   s    77??3>>2:&s~~664B&HCNGGggll8Z8G ggll7<<ww~~c""MM,s23 iik
r"   c                 D    [         R                  " U R                  5        g N)r   r<   r;   r=   s    r    tearDownEmbeddingTestsMixin.tearDown`   s    
r"   Nr   )r)   timeout
returncodeinputcwdc          	         U R                   /nUR                  U5        Ub1  [        (       a&  UR                  5       n[        R
                  S   US'   [        R                  " U[        R                  [        R                  SUUS9n UR                  XBS9u  pUR                  U:w  aK  [        R                  (       a6  [        SU S35        [        SU	 35        [        SU
 35        [        S	5        U R!                  UR                  US
UR                  U
4-  5        X4$ !   UR                  5         UR                  5         e = f)z'Runs a test in the embedded interpreter
SYSTEMROOTT)stdoutstderruniversal_newlinesr)   rM   )rL   rJ   z--- z failed ---zstdout:
zstderr:
z------zbad returncode %d, stderr is %r)r7   extendr   copyr   r&   
subprocessPopenPIPEcommunicate	terminatewaitrK   r   verboseprintassertEqual)r=   r)   rJ   rK   rL   rM   argscmdpouterrs              r    run_embedded_interpreter,EmbeddingTestsMixin.run_embedded_interpreterc   s    }}o

4?zz ((*C "

< 8CS$.OO$.OO04!$!$&	UDJS
 <<:%'//D[)*IcU#$IcU#$(Oz:,,,-	. x	KKMFFHs   	D$ $#Ec              #   f  #    U R                  S5      u  pU R                  US5        Sn[        SS5      nSn/ nUR                  5        GHa  nUSR	                  U5      :X  aA  U R                  [        U5      S5        [        R                  S:  a  [        U5        US-  nMZ  U R                  [        U5      S	5        [        R                  " X75      nUc  U R                  Xs5        U" UR                  5       6 n	[        R                  S
:  a  [        U	5        U R                  U	R                  5        U R                  U	R                   5        U R                  U	R"                  5        UR%                  U	5        [        U5      S	:X  d  GME  US   n
U R                  X5        Uv   / nGMd     g 7f)N&test_repeated_init_and_subinterpretersr   zS^interp (\d+) <(0x[\dA-F]+)>, thread state <(0x[\dA-F]+)>: id\(modules\) = ([\d]+)$Interpzid interp tstate modulesr   z--- Pass {} ---r      r
   )rc   r]   r   
splitlinesformatlenr   r[   r\   
assertLessrematchassertRegexgroups
assertTrueinterptstatemodulesappend)r=   ra   rb   
interp_patrg   numloopscurrent_runlinern   rr   mains              r    %run_repeated_init_and_subinterpreters9EmbeddingTestsMixin.run_repeated_init_and_subinterpreters   si    001YZb!2
 H&@ANN$D(//99  [!115??Q&$KAOOC,a0HHZ.E}  2 U\\^,F"fOOFMM*OOFMM*OOFNN+v& ;1$"1~  .!! ; %s   FF1"F1)r;   r7   )	__name__
__module____qualname____firstlineno__rC   rH   rc   r{   __static_attributes__ r"   r    r-   r-   M   s&    $ 37)-!4%)!F2!r"   r-   c                       \ rS rSrSrS rS rS rS rS r	S r
S	 rS
 rS rS rS rS rS rS r\R(                  \R,                  " \R.                  S5      S 5       5       rS rS rS rS rSrg)EmbeddingTests   i  c                 t    U R                  5        H$  nUS   nU R                  UR                  S5        M&     g )Nr   0)r{   r]   id)r=   runrz   s      r    test_subinterps_main#EmbeddingTests.test_subinterps_main   s3    ==?Cq6DTWWc* @r"   c           	          U R                  5        H[  nUGtp#n[        UR                  5      n[        U5       H/  u  pgU R	                  UR                  [        XV-   S-   5      5        M1     M]     g )Nr   )r{   intr   	enumerater]   str)r=   r   rz   subs_mainidisubs           r    test_subinterps_different_ids,EmbeddingTests.test_subinterps_different_ids   s[    ==?C ND\F#D/  VZ!^)<= *	 @r"   c                 j   U R                  5        H  nUGtp#nSU;   a  [        R                  " S5      eU Hu  nU R                  UR                  UR                  5        U R                  UR
                  UR
                  5        U R                  UR                  UR                  5        Mw     M     g )N0x0zplatform prints pointers as 0x0)r{   unittestSkipTestassertNotEqualrr   rs   rt   )r=   r   rz   r   r   r   s         r    test_subinterps_distinct_state-EmbeddingTests.test_subinterps_distinct_state   s    ==?C ND}
 ''(IJJ ##CJJ<##CJJ<##CKK>  @r"   c                     U R                  S5      u  pU R                  US5        [        S[        S-   5       Vs/ s H	  nSU S3PM     nnSR	                  U5      S-   nU R                  X5        g s  snf )Ntest_repeated_init_and_inittabr   r   z	--- Pass z ---
)rc   r]   range
INIT_LOOPSr6   )r=   ra   rb   r   liness        r    r   -EmbeddingTests.test_repeated_init_and_inittab   sv    001QRb!.3Az!|.DE.D9QCt$.DE		% 4'$ Fs   A3c                 ^   [        [        R                  SS9nU R                  SUS9u  p#[        R
                  S:  a   [        5         [        U5        [        U5        SnSnSR                  / S	Q5      nUR                  UUUS
9nS U l	        U R                  UR                  5       U5        g )Nzutf-8:surrogateescape)PYTHONIOENCODINGtest_forced_io_encodingr)   r   utf-8surrogateescaper   )z--- Use defaults ---Expected encoding: defaultExpected errors: defaultzstdin: {in_encoding}:{errors}zstdout: {out_encoding}:{errors}'stderr: {out_encoding}:backslashreplacez--- Set errors only ---r   zExpected errors: ignorezstdin: {in_encoding}:ignorezstdout: {out_encoding}:ignorer   z--- Set encoding only ---Expected encoding: iso8859-1r   zstdin: iso8859-1:{errors}zstdout: iso8859-1:{errors}"stderr: iso8859-1:backslashreplacez--- Set encoding and errors ---r   zExpected errors: replacezstdin: iso8859-1:replacezstdout: iso8859-1:replacer   )in_encodingout_encodingerrors)r%   r   r&   rc   r   r[   r\   r6   rj   maxDiffr]   strip)r=   r)   ra   rb   expected_stream_encodingexpected_errorsexpected_outputs          r    r   &EmbeddingTests.test_forced_io_encoding   s    2::0GH001JPS0T??QG#J#J#* +)) %. /2 *00,D-E'6 1 8
 o6r"   c                    [        [        R                  [        R                  R	                  [
        R                  5      S9nU R                  SUS9u  p#[        R                  S:  a   [        5         [        U5        [        U5        [        (       a  U R                  nO3[        R                  R	                  [        R                  " 5       S5      nSU S3nU R                  XR5        U R                  US5        g	)
zo
Checks some key parts of the C-API that need to work before the runtime
is initialized (via Py_Initialize()).
)
PYTHONPATHtest_pre_initialization_apir   r   spamzsys.executable: r   r   N)r%   r   r&   pathsepr6   r4   r   rc   r   r[   r\   r   r7   r:   assertInr]   )r=   r)   ra   rb   expected_pathr   s         r    r   *EmbeddingTests.test_pre_initialization_api  s    
 2::"**//#((*CD001NTW0X??QG#J#J: MMMGGLLf=M,]O2>o+b!r"   c                 N   [        5       n[        R                  R                  [        R
                  5      US'   U R                  SUS9u  p#[        R                  S:  a   [        5         [        U5        [        U5        SnU R                  XB5        U R                  US5        g)z
Checks that sys.warnoptions and sys._xoptions can be set before the
runtime is initialized (otherwise they won't be effective).
r   #test_pre_initialization_sys_optionsr   r   zsys.warnoptions: ['once', 'module', 'default']
sys._xoptions: {'not_an_option': '1', 'also_not_an_option': '2'}
warnings.filters[:3]: ['default', 'module', 'once']
r   N)r+   r   r   r6   r4   r   rc   r   r[   r\   r   r]   )r=   r)   ra   rb   r   s        r    r   2EmbeddingTests.test_pre_initialization_sys_options'  s    
 $%JJOOCHH5L00=3 1 H??QG#J#JD 	
 	o+b!r"   c                 r    U R                  S5      u  pU R                  US5        U R                  US5        g)zM
bpo-20891: Calling PyGILState_Ensure in a non-Python thread must not
crash.
test_bpo20891r   Nrc   r]   r=   ra   rb   s      r    r   EmbeddingTests.test_bpo20891<  s6    
 00Ab!b!r"   c                 r    U R                  S5      u  pU R                  US5        U R                  US5        g)zN
bpo-33932: Calling Py_Initialize() twice should do nothing (and not
crash!).
test_initialize_twicer   Nr   r   s      r    r   $EmbeddingTests.test_initialize_twiceE  s7    
 001HIb!b!r"   c                     U R                  S5      u  pU R                  UR                  5       S5        U R                  US5        g)zC
bpo-34008: Calling Py_Main() after Py_Initialize() must not fail.
test_initialize_pymainz6Py_Main() after Py_Initialize: sys.argv=['-c', 'arg2']r   Nrc   r]   rstripr   s      r    r   %EmbeddingTests.test_initialize_pymainN  s>     001IJ'_`b!r"   c                     U R                  S5      u  pU R                  UR                  5       S5        U R                  US5        g )Ntest_run_mainz%Py_RunMain(): sys.argv=['-c', 'arg2']r   r   r   s      r    r   EmbeddingTests.test_run_mainV  s;    00A'NOb!r"   c                 |    SnU R                  S5      u  p#U R                  USU-  5        U R                  US5        g )Nrh   test_run_main_loopz&Py_RunMain(): sys.argv=['-c', 'arg2']
r   r   )r=   nloopra   rb   s       r    r   !EmbeddingTests.test_run_main_loop[  sB     001EFG%OPb!r"   c                     [         R                  " S5      n[        USS9 nUR                  5       nS S S 5        U R	                  SW5      u  pEU R                  US[        -  5        g ! , (       d  f       N<= f)Nz_test_embed_structseq.pyr   encodingtest_repeated_init_execTests passed
)r   findfileopenreadrc   r]   r   )r=   scriptfpcodera   rb   s         r    test_finalize_structseq&EmbeddingTests.test_finalize_structseqc  se     !!"<=&7+r779D ,001JDQ.;< ,+s   A((
A6c                 \    U R                  S5      u  pU R                  US[        -  5        g )Ntest_repeated_simple_initz
Finalized
rc   r]   r   r   s      r    test_simple_initialization_api-EmbeddingTests.test_simple_initialization_apio  s,     001LMmj89r"   zrequires test modulesc                     [         R                  " S5      nU R                  nU" SU5      u  p4U R                  US[        -  5        g )Na              import dis
            import importlib._bootstrap
            import opcode
            import test.test_dis

            def is_specialized(f):
                for instruction in dis.get_instructions(f, adaptive=True):
                    opname = instruction.opname
                    if (
                        opname in opcode._specialized_opmap
                        # Exclude superinstructions:
                        and "__" not in opname
                    ):
                        return True
                return False

            func = importlib._bootstrap._handle_fromlist

            # "copy" the code to un-specialize it:
            func.__code__ = func.__code__.replace()

            assert not is_specialized(func), "specialized instructions found"

            for i in range(test.test_dis.ADAPTIVE_WARMUP_DELAY):
                func(importlib._bootstrap, ["x"], lambda *args: None)

            assert is_specialized(func), "no specialized instructions found"

            print("Tests passed")
        r   r   textwrapdedentrc   r]   r   )r=   r   r   ra   rb   s        r    >test_specialized_static_code_gets_unspecialized_at_Py_FINALIZEMEmbeddingTests.test_specialized_static_code_gets_unspecialized_at_Py_FINALIZEu  sI    
    > ++0$7.;<r"   c                 b    SnU R                  SU5      u  p#U R                  US[        -  5        g )Nzprint('\N{digit nine}')r   z9
r   r=   r   ra   rb   s       r    test_ucnhash_capi_reset&EmbeddingTests.test_ucnhash_capi_reset  s1    )001JDQej01r"   c                 b    SnU R                  SU5      u  p#U R                  US[        -  5        g )Nzdimport datetime;d = datetime.datetime.strptime('2000-01-01', '%Y-%m-%d');print(d.strftime('%Y%m%d'))r   z	20000101
r   r   s       r    test_datetime_reset_strptime+EmbeddingTests.test_datetime_reset_strptime  s8    * 	
 001JDQlZ78r"   c                    [         R                  " S5      n0 n[        XU5        US   nAU[         R                  " S5      -  nU R                  SX5      u  pEUR	                  S5      SS  nU Vs/ s H  owR                  S5      S   PM     nnS U l        [        USS	9 H  u  p[        R                  " U	5      n
UR                  5        H?  u  pU R                  XS
9   U
R                  U5      nU R                  X5        S S S 5        MA     U R                  U
0 5        M     U R                  US5        g s  snf ! , (       d  f       M  = f)Na   
            import test.support

            results = {}
            def add(cls, slot, own):
                value = getattr(cls, slot)
                try:
                    subresults = results[cls.__name__]
                except KeyError:
                    subresults = results[cls.__name__] = {}
                subresults[slot] = [repr(value), own]

            for cls in test.support.iter_builtin_types():
                for slot, own in test.support.iter_slot_wrappers(cls):
                    add(cls, slot, own)
            resultsz
            import json
            import sys
            text = json.dumps(results)
            print(text, file=sys.stderr)
            r   z
--- Loop #r   z ---
)start)loopclsr   )r   r   execrc   split
rpartitionr   r   jsonloadsitemssubTestpopr]   )r=   r   nsall_expectedra   rb   r   resr   textresult	classnameexpectedslotss                 r    !test_static_types_inherited_slots0EmbeddingTests.test_static_types_inherited_slots  s=    " " V)}(// #  	 00)6;))L)!"-;BC7C>>(+B/7C 2GAZZ%F'3'9'9';#	\\q\8"JJy1E$$U5 98 (< VR( 3 	b! D 98s   0D7#D<<
Ec                     [         R                  " S5      nU R                  SU5      u  p#U R                  US[        -  5        g )Na  
            try:
                import _ssl
            except ModuleNotFoundError:
                _ssl = None
            if _ssl is not None:
                _ssl.txt2obj(txt='1.3')
            print('1')

            import _queue
            _queue.SimpleQueue().put_nowait(item=None)
            print('2')

            import _zoneinfo
            _zoneinfo.ZoneInfo.clear_cache(only_keys=['Foo/Bar'])
            print('3')
        r   z1
2
3
r   r   s       r     test_getargs_reset_static_parser/EmbeddingTests.test_getargs_reset_static_parser  sC        " 001JDQkJ67r"   )r   N)r}   r~   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   requires_specializationr   
skipUnlessTEST_MODULES_ENABLEDr   r   r   r  r  r   r   r"   r    r   r      s    G+>?*%)7V"&"*""""
"
=: $$557NO$= P %$=L29*"X8r"   r   requires _testinternalcapic                   R   \ rS rSrSr\(       a  SOSr\" 5       r\" 5       r	\
\SSSSSS.r\(       a  \R                  SS05        \" \\S\\S	9r\" \\SSSSSSS
9r/ SQr0 S\
_SS_SS_SS_SS_SS_SS_S\R*                  R,                  _SS_SS_SS_SS_SS_SS_SS_SS_SS _0 S!S_S"\_S#\_S$S _S%\_S&S_S'S(/_S)/ _S*/ _S+/ _S,S _S-S _S.\_S/\_S0\_S1\_S2\_E0 S3\_S4\_S5S_S6\R.                  _S7\_S8S_S9S_S:S_S;S_S<S_S=S_S>S_S?S_S@S_SAS_SBS_SCS_ES\\SS S S S SSDSS\R2                  (       + S\	SE.Er\(       a  S\SF'   \R2                  (       a  S \SG'   \R8                  (       a  S\SH'   \(       a  \R                  SIS05        \" \\SSSJ9r\" \\SSSSSSSSSSSSK9r\(       a  S\SI'   SSSSL.rSM/r / SNQr!\(       a"  \ RE                  SO5        \!RE                  SP5        S r#\$SQ 5       r%SR r&SS r'ST r( SSU jr)SV r*SW r+SX r,    SS S SS SY.SZ jjr-S[ r.S\ r/S] r0S^ r1S_ r2S` r3Sa r4Sb r5Sc r6Sd r7Se r8Sf r9Sg r:Sh r;Si r<Sj r=Sk r>Sl r?Sm r@Sn rA\BR                  " So5      Sp 5       rDSq rESr rFSs rGSt rHSu rISv rJSw rKSx rLSSy jrM\NR                  SSz j5       rPS{ rQS| rRS} rS\BR                  " \S~5      S 5       rU\BR                  " \S5      S 5       rWS rX\BR                  " \S5      S 5       rYS rZS r[S r\S r]S r^S r_\`R                  " 5       S 5       rbSrcg )InitConfigTestsi  i   surrogatepassr   r   r   )_config_init	allocator
parse_argvconfigure_localecoerce_c_localecoerce_c_locale_warn	utf8_modelegacy_windows_fs_encoding)r  r  r  r  )r  r  isolateduse_environmentr  dev_moder  )r#  r!  r"  r  r!  Fr"  Tr#  install_signal_handlersuse_hash_seed	hash_seedint_max_str_digits	cpu_countr   faulthandlertracemallocperf_profilingimport_timecode_debug_rangesshow_ref_count	dump_refsdump_refs_fileNmalloc_statsfilesystem_encodingfilesystem_errorspycache_prefixprogram_namer  argvr   	orig_argvxoptionswarnoptionspythonpath_envhomer5   base_executableprefixbase_prefixexec_prefixbase_exec_prefixmodule_search_pathsmodule_search_paths_set
platlibdir
stdlib_dirsite_importbytes_warningwarn_default_encodinginspectinteractiveoptimization_levelparser_debugwrite_bytecoder[   quietuser_site_directoryconfigure_c_stdiodefault)buffered_stdiostdio_encodingstdio_errorsskip_source_first_linerun_command
run_modulerun_filename
sys_path_0_install_importlibcheck_hash_pycs_modepathconfig_warnings
_init_mainuse_frozen_modules	safe_path_is_python_build_pystatsrun_presite
enable_gillegacy_windows_stdio)r  rO  r  )r  r!  r"  rN  r^  r#  r$  r%  r)  r*  r+  r[  )Py_HasFileSystemDefaultEncodingPy_HashRandomizationFlag$_Py_HasFileSystemDefaultEncodeErrors)Py_UTF8Moder  ))Py_BytesWarningFlagrF  )Py_DebugFlagrK  )Py_DontWriteBytecodeFlagrL  T) Py_FileSystemDefaultEncodeErrorsr3  )Py_FileSystemDefaultEncodingr2  )Py_FrozenFlagr[  T)Py_IgnoreEnvironmentFlagr"  T)Py_InspectFlagrH  )Py_InteractiveFlagrI  )Py_IsolatedFlagr!  )Py_NoSiteFlagrE  T)Py_NoUserSiteDirectoryrN  T)Py_OptimizeFlagrJ  )Py_QuietFlagrM  )Py_UnbufferedStdioFlagrQ  T)Py_VerboseFlagr[   ))Py_LegacyWindowsFSEncodingFlagr   ))Py_LegacyWindowsStdioFlagrc  c                     S U l         g rF   )EXPECTED_CONFIG)r   s    r    tearDownClassInitConfigTests.tearDownClass  s     #r"   c                 d    0 nU H'  nSU;   a  UR                  SS5      u  pEXRU'   M#  SX#'   M)     U$ )N=r   T)r   )r=   xoptions_listr8  optr*   values         r    main_xoptionsInitConfigTests.main_xoptions  s?     Ccz YYsA.
 % $ ! r"   c                     [        5       n[        R                  " S5      n[        R                  SSU/n[
        R                  " X1[
        R                  [
        R                  S9nUR                  (       a'  [        SUR                  < SUR                  < 35      eUR                  R                  S5      n [        R                  " U5      $ ! [        R                   a    U R!                  SU< 35         g f = f)	Na4  
            import json
            import sys
            import _testinternalcapi

            configs = _testinternalcapi.get_configs()

            data = json.dumps(configs)
            data = data.encode('utf-8')
            sys.stdout.buffer.write(data)
            sys.stdout.buffer.flush()
        z-S-c)r)   rP   rQ   z)failed to get the default config: stdout=z stderr=r   fail to decode stdout: )r+   r   r   r4   r5   rU   r   rW   rK   	ExceptionrP   rQ   decoder   r  JSONDecodeErrorfail)r=   r)   r   r^   procrP   s         r    _get_expected_config_impl)InitConfigTests._get_expected_config_impl  s    #%    dD1~~d%/__%/__6 ?? &&*kk_HT[[OM N N##G,	<::f%%## 	<II/z:;	<s   ;C )C=<C=c                 0   [         nUR                  c  U R                  5       Ul        0 nUR                  R                  5        HM  u  p40 nUR                  5        H.  u  pg[	        U[
        5      (       a  UR                  5       nXuU'   M0     XRU'   MO     U$ rF   )r  r{  r  r  
isinstancer'   rT   )r=   r   configs
config_keyconfig_valueconfigr*   r  s           r    _get_expected_config$InitConfigTests._get_expected_config  s    &"&"@"@"BC (+(;(;(A(A(C$JF*002
eT**!JJLE#s 3 #)J )D r"   c                    U R                  5       nUS   nUR                  5        H  u  pXR                  L d  M  Xx   X'   M     US   (       a
  U[        :X  a  S H  nU R                  X('   M     US   (       d  U R                  US'   US   S:X  af  US   U R                  L a  SUS'   US   U R                  L a  U R
                  US'   US	   U R                  L a  SUS	'   US
   U R                  L a  SUS
'   [        (       a  U R                  n
OhUS   U R                  La#  [        R                  R                  US   5      n
O3[        R                  R                  [        R                  " 5       S5      n
US   U R                  L a  XS'   US   U R                  L a  XS'   US   U R                  L a  SUS'   US   nUR                  5        H  u  pXR                  L d  M  X   X('   M     US   U R                  Laa  US   nUb5  UR                  [        R                  R                  5      n/ UQUS   QUS'   Ub!  US   R                  5       US'   U" US   5        U R                    H  nX;  d  M
  X(   X'   M     g )N
pre_configr  )r2  r3  rR  rS  r  r   r2  r   r3  rR  rS  r   r5  r0   r5   r<  z./_testembedr  rA  r:  )r  r  GET_DEFAULT_CONFIG
API_COMPATIGNORE_CONFIGUTF8_MODE_ERRORSr   r7   r   r   abspathr6   r:   r   r   rT   COPY_PRE_CONFIG)r=   expected_preconfigr  r)   apimodify_path_cbr  r  r*   r  default_executabler  r:  pathss                 r    get_expected_config#InitConfigTests.get_expected_config  s   ++-\*
,224JC///*4/"' 5 ""45
9J: $ 2 2: ""45 /3.@.@{+k*a/-.$2I2II29./+,0G0GG040E0E,-()T-D-DD-4)*'4+B+BB+<(:!%n%T-D-DD!#.1I!J!#biik<!HL!T%<%<<%7\"%&$*A*AA*<&'N#t'>'>>'5H^$""..*JC/// & + )*$2D2DD%&67N)&,,RWW__=2\E2\HEZ<[2\./)2:;P2Q2V2V2X./x(=>?''C,*2-"' (r"   c                     [        US   5      n[        UR                  5       5       H)  u  pEXPR                  L d  M  UR	                  US 5        X$	 M+     U R                  X25        g )Nr  )r%   r'   r  r  r  r]   )r=   r  r  r  r*   r  s         r    check_pre_config InitConfigTests.check_pre_config1  sX    ',/0
x~~/0JC***sD)M 1 	.r"   c                    [        US   5      n[        (       a  UR                  S=n5      nU(       a  [        U[        5      (       ax  US [        UR                  5       R                  S5      5       n[        [        R                  5      (       a+  US [        UR                  5       R                  S5      5       nXSU'   [        UR                  5       5       H  u  pEXPR                  L a  UR                  US 5        X$	 [        U[        [         45      (       d  MD  [        UR                  U5      [        [         45      (       d  Mp  [#        X4   5      " X$   5      X$'   M     U R%                  X25        g )Nr  r5  r1   r   )r%   r   getr  r   rk   lowerremovesuffixr!   r4   r5   r'   r  r  r  boolr   typer]   )r=   r  r  r  r*   r  s         r    check_configInitConfigTests.check_config9  s   gh'(:JJn4s5EE3//Fs5;;=#=#=f#EFGs~~..!"H3u{{}'A'A$'G#HIE#sx~~/0JC***

3%M%$--*VZZ_tUXk2Z2Z $V[ 1(- @ 1 	*r"   c                 t   US   nUS   n[        U R                  5      nU R                   H2  n[        U5      S:X  a  Uu  pgnX7   (       a  SOSXF'   M(  Uu  pgX7   XF'   M4     U R                   H2  n[        U5      S:X  a  Uu  pgnX'   (       a  SOSXF'   M(  Uu  pgX'   XF'   M4     U R                  US   U5        g )Nr  r  r   r   r   global_config)r%   DEFAULT_GLOBAL_CONFIGCOPY_GLOBAL_CONFIGrk   COPY_GLOBAL_PRE_CONFIGr]   )	r=   r  r  r  r  item
global_keycore_keyopposites	            r    check_global_config#InitConfigTests.check_global_configK  s    \*
"223++D4yA~15.
h,2,<q!$'+$
'-'7$ , //D4yA~15.
h,6,@qa$'+$
'1';$ 0 	18<r"   )preconfig_apir)   ignore_stderrrM   c                0   [        5       nUb  UR                  U5        UnUc  UnU[        :X  a  U R                  nO#U[        :X  a  U R
                  nOU R                  nUc  0 n[        U40 UD6nUc  0 nU[        :X  a  U R                  nO#U[        :X  a  U R                  nOU R                  n[        U40 UD6nU R                  UUUXd5        U R                  UXS9u  pUc  US   (       d  SnUb'  U	(       d   U R                  UR                  5       U5         [        R                   " U5      nU R'                  WU5        U R)                  UU5        U R+                  U5        U$ ! [        R"                   a    U R%                  SU< 35         Nbf = f)N)r)   rM   r[   r   r  )r+   updateAPI_ISOLATEDPRE_CONFIG_ISOLATED
API_PYTHONPRE_CONFIG_PYTHONPRE_CONFIG_COMPATr%   CONFIG_PYTHONCONFIG_ISOLATEDCONFIG_COMPATr  rc   r]   r   r   r  r  r  r  r  r  )r=   testnameexpected_configr  r  rQ   r  r  r)   r  rM   new_envdefault_preconfigdefault_configra   rb   r  s                    r    check_all_configs!InitConfigTests.check_all_configsa  s   
 ()?NN3 ML( $ 8 8j( $ 6 6 $ 6 6%!#!"3J7IJ" O*!//NL !11N!//N~AA  !3!0!$!$	6
 0058 1 C>/)"<FmSZZ\62	9jjoG 	g'9:'?3  ) ## 	9II/w78	9s   E) ))FFc                 ,    U R                  S[        S9  g )Ntest_init_initialize_configr  r  r  rG   s    r    test_init_default_config(InitConfigTests.test_init_default_config  s    <*Mr"   c                 ,    U R                  S[        S9  g )Ntest_preinit_compat_configr  r  rG   s    r    r  *InitConfigTests.test_preinit_compat_config      ;Lr"   c                 ,    U R                  S[        S9  g )Ntest_init_compat_configr  r  rG   s    r    r  'InitConfigTests.test_init_compat_config      8jIr"   c                 X    SS0nSSSS/SSSSSSSSSS.nU R                  SX![        S	9  g )
Nr  r   z./globalvarr   default::BytesWarningr
   )r5  rE  rF  r9  rH  rI  rJ  rL  r[   rM  rQ  rN  r[  test_init_global_configr  r  r=   	preconfigr  s      r    r  'InitConfigTests.test_init_global_config  s^    
	 *34"##$#$
  	8&#- 	 	/r"   c                 f   [         SS.n0 SS_SS_SS_S	S
_SS_SS_SS_SS_SS_SS_SS_SS_SS_SSS/_S/ SQ_SS_S/ SQ_0 S / S!Q_S"S#_S$S_S%S_S&S_S'S_S(S
_S)S_S*S_S+S_S,S_S-S_S.S_S/S_S0S1_S2U R                  _S3S_ES4S5S6SS7.En[        (       a  SUS8'   U R                  S9X![        S:9  g );Nr   r  r  r$  Fr%  Tr&  {   r*  r
   r+  r,  r-  r.  r1  rR  	iso8859-1rS  replacer4  conf_pycache_prefixr5  z./conf_program_namer6  r  arg2r7  )python3-Wcmdline_warnoption-Xcmdline_xoptionr  passr  r  r8  )zconfig_xoption1=3zconfig_xoption2=config_xoption3r  r9  )r  r  config_warnoptionrU  pass
rE  rF  rH  rI  rJ  rL  r[   rM  rO  rQ  rN  r)  rC  my_platlibdirrA  r^  iiz  i  always)r'  r(  rZ  r[  r`  test_init_from_configr  ALLOCATOR_FOR_CONFIGr  Py_STATSr  r  r  s      r    r  %InitConfigTests.test_init_from_config  s!   -
	8
%u8
T8
 8
 1	8

 e8
 48
  8
 d8
 D8
 k8
 I8
 38
 18
  T6N!8
"  "#8
, $-8
.  /8
:  ;8
D 8E8
H 5I8
J QK8
L tM8
N 4O8
P !!Q8
R eS8
T qU8
V TW8
X  Y8
Z e[8
\ "5]8
^ D_8
` /a8
b "4#5#5c8
d e8
f #($,#(o8
r 8!"F:6#- 	 	/r"   c                     S[         0n0 SS_SS_SS_SS	_S
S_SS	_SS_SS_SS_SS_SS_SS	_SS_SS	_SS_SS_SS	_SS/SU R                  SSS.En[        (       a  SUS '   U R                  S!X![        S"9  g )#Nr  r%  Tr&  *   r*  r
   r+  Fr,  r-  r1  rH  rJ  r:  /my/pathr4  env_pycache_prefixrL  r[   r   rQ  rR  r  rS  r  rN  EnvVarenv_platlibdir  r)  r9  rC  rA  r^  r'  r`  test_init_compat_envr  r  r  s      r    r  $InitConfigTests.test_init_compat_env  s,   -
	
T

 1
 e	

 4
  
 D
 t
 !!
 j
 2
 e
 q
 e
 k
  I!
" "5#
$ !$:*#'#5#5"&/
2 8!"F:5v#- 	 	/r"   c                     [         SS.n0 SS_SS_SS_S	S
_SS_SS
_SS_SS_SS_SS_SS_SS
_SS_SS
_SS_SS_SS
_SS/SU R                  SSS.En[        (       a  SUS '   U R                  S!X![        S"9  g )#Nr   r  r%  Tr&  r  r*  r
   r+  Fr,  r-  r1  rH  rJ  r:  r  r4  r  rL  r[   rQ  rR  r  rS  r  rN  r  r  r   r  r`  test_init_python_envr  )r  r  r  r  r  r  s      r    r  $InitConfigTests.test_init_python_env  s,   -
	
T

 1
 e	

 4
  
 D
 t
 !!
 j
 2
 e
 q
 e
 k
  I!
" "5#
$ !$:*#'#5#5"&/
2 8!%F:5v#- 	 	/r"   c                 `    [        [        S9n[        SSS/S9nU R                  SX![        S9  g )Nr  r   rP  r#  r)  r9  test_init_env_dev_moder  )r%   PYMEM_ALLOCATOR_DEBUGr  r  r  s      r    r
  &InitConfigTests.test_init_env_dev_mode?  s>    #89	q#$#,+/ 	7#- 	 	/r"   c                 `    [        [        S9n[        SSS/S9nU R                  SX![        S9  g )Nr  r   rP  r	  test_init_env_dev_mode_allocr  )r%   r  r  r  r  s      r    r  ,InitConfigTests.test_init_env_dev_mode_allocG  s>    #78	q#$#,+/ 	=v#- 	 	/r"   c                 L    S[         0nSSS/S.nU R                  SX![        S9  g )Nr  TrP  )r)  r#  r9  test_init_dev_moder  )r  r  r  r  s      r    r  "InitConfigTests.test_init_dev_modeO  s@    .
	 !%;

 	3V#- 	 	/r"   c           	          S[         0nS// SQ[        R                  R                  S5      SSS/S/SS.nU R	                  SX![
        S	9  g )
Nr  	script.py)r  r  dev-Pr  TrP  r  )r6  r7  rW  r#  r)  r9  r8  r^  test_preinit_parse_argvr  )r  r   r   r  r  r  r  s      r    r  'InitConfigTests.test_preinit_parse_argv[  sb     .
	 !MDGGOOK8 %;	
 	8&#- 	 	/r"   c                 J    SS0n/ SQnUUSS.nU R                  SX1[        S9  g )Nr!  r   )	r  -E-Ir  r  r  r  utf8r  )r6  r7  r!  test_preinit_dont_parse_argvr  r  r  )r=   r  r6  r  s       r    r  ,InitConfigTests.test_preinit_dont_parse_argvn  sF     
	 

 	=v#/ 	 	1r"   c                 <    SSSSS.nU R                  SU[        S9  g )NTFr!  r^  r"  rN  test_init_isolated_flagr  r  r  r=   r  s     r    r"  'InitConfigTests.test_init_isolated_flag  s-    $#(	
 	8&jQr"   c                 <    SSSSS.nU R                  SU[        S9  g )NTFr!  test_preinit_isolated1r  r  r$  s     r    r'  &InitConfigTests.test_preinit_isolated1  /     $#(	
 	7ZPr"   c                 <    SSSSS.nU R                  SU[        S9  g )NTFr!  test_preinit_isolated2r  r  r$  s     r    r+  &InitConfigTests.test_preinit_isolated2  r)  r"   c                 ,    U R                  S[        S9  g )Ntest_preinit_isolated_configr  r  rG   s    r    r.  ,InitConfigTests.test_preinit_isolated_config  s    =<Pr"   c                 ,    U R                  S[        S9  g )Ntest_init_isolated_configr  r  rG   s    r    r1  )InitConfigTests.test_init_isolated_config  s    :Mr"   c                 ,    U R                  S[        S9  g )Ntest_preinit_python_configr  r#  rG   s    r    r4  *InitConfigTests.test_preinit_python_config  r  r"   c                 ,    U R                  S[        S9  g )Ntest_init_python_configr  r#  rG   s    r    r7  'InitConfigTests.test_init_python_config  r  r"   c                 :    SSS.nU R                  S0 U[        S9  g )Nr   )r  r  test_init_dont_configure_localer  r#  )r=   r  s     r    r:  /InitConfigTests.test_init_dont_configure_locale  s0     !" 
	 	@"i#- 	 	/r"   zSas of 3.11 this test no longer works because path calculations do not occur on readc                 B    SSSS.nS nU R                  SU[        US9  g )Nz./init_read_setmy_executable)r5  r5   r<  c                 J    U R                  SS5        U R                  S5        g )Nr   test_path_insert1test_path_append)insertru   )r   s    r    modify_path7InitConfigTests.test_init_read_set.<locals>.modify_path  s    KK./KK*+r"   test_init_read_set)r  r  r#  )r=   r  rB  s      r    rD  "InitConfigTests.test_init_read_set  s9     .).

	, 	3V#-.9 	 	;r"   c                 H    S/ SQ/ SQ/ SQS.nU R                  SU[        S9  g )Nr   )config_xoptionr  sysadd_xoptionr)  )ignore:::cmdline_warnoptionzignore:::sysadd_warnoptionzignore:::config_warnoption)r  r  rI  r  r  )r)  r8  r9  r7  test_init_sys_addr  r#  r$  s     r    rJ  !InitConfigTests.test_init_sys_add  s3    
3
" 	2F
Kr"   c                 V    SnSS/SSUS/SUS-   SSS	.nU R                  S
U[        S9  g )NRimport _testinternalcapi, json; print(json.dumps(_testinternalcapi.get_configs()))r  r  r  	./python3r   Tr   )r6  r7  r5  rU  r  rX  test_init_run_mainr  r#  r=   r   r  s      r    rO  "InitConfigTests.test_init_run_main  sN    E 6N#T48'$;
 	3VLr"   c                 Z    SnSS/SSUS/SUS-   SSS	S
.nU R                  SU[        SS9  g )NrM  r  r  r  rN  r   Tr   r   )r6  r7  r5  rU  r  r\  rX  test_init_mainz)Run Python code before _Py_InitializeMain)r  rQ   r#  rP  s      r    rS  InitConfigTests.test_init_main  s`    E 6N# " ($;

 	/#-&Q 	 	Sr"   c                 H    S/ SQ/ SQSSSS.nU R                  SU[        S	9  g )
NT)r  arg1-varg3./argv0r  r  r  rV  rW  rX  rZ  r  F)r  r6  r7  r5  rU  r"  test_init_parse_argvr  r#  r$  s     r    r[  $InitConfigTests.test_init_parse_argv  s3    0N%#$
 	5v:Nr"   c                 L    SS0nS/ SQ/ SQSS.nU R                  SX![        S9  g )	Nr  r   FrY  rZ  )r  r6  r7  r5  test_init_dont_parse_argvr  r#  )r=   r  r  s      r    r^  )InitConfigTests.test_init_dont_parse_argv  s@    !

  IN%	
 	:F#- 	 	/r"   c                     [         (       a  SnU R                  nO9Sn[        (       a  U R                  nO[        R                  " U5      =(       d    SnUR                  UUUS.5        g )Nr   r  r   )r5  r<  r5   )r   r7   MACOSshutilwhichr  )r=   r  r5  r5   s       r    default_program_name$InitConfigTests.default_program_name  sU    :#LJ$Lu!]]
#\\,7=2
()$
 	r"   c                     U R                  5       nUS   S   nUSSSSSS.nU R                  U5        S[        R                  R                  R                  U5      0nU R                  SU[        USS9  g )	Nr  rA  r   )rA  r=  r>  r?  r@  rD  TESTPATHtest_init_setpathTr  r)   r  )r  rd  r   r   r   r6   r  r  r=   r  r  r)   s       r    rh  !InitConfigTests.test_init_setpath  s    **,x !67 $) " 	
 	!!&)277??//672F#-3-1 	 	3r"   c                     U R                  5       nUS   S   nUSSSSS[        R                  (       + SSSS.
nS[        R                  R
                  R                  U5      0nU R                  SU[        US	S
9  g )Nr  rA  r   conf_program_nameconf_executable)
rA  r=  r>  r?  r@  rD  r]  r5  r<  r5   rg  test_init_setpath_configTri  )	r  r   Py_DEBUGr   r   r   r6   r  r  rj  s       r    ro  (InitConfigTests.test_init_setpath_config2  s    **,x !67 $) " &-&6&6"6/0+
  277??//6796#-3d 	 	Lr"   c                 n   U R                  5       nUc  US   S   nUc  US   S   n[        (       a  US   S   $ [        R                  n[        R
                  R                  U[        R                  SUR                   UR                   [         S35      [        R
                  R                  U[        R                  SUR                   SUR                   [         35      [        R
                  R                  U[        R                  SUR                   SUR                   [         3S5      /$ )Nr  r=  rA  r   z.zipr   lib-dynload)r  r   r4   version_infor   r   r6   rC  majorminor
ABI_THREAD)r=   r=  r?  r  vers        r    rA  #InitConfigTests.module_search_pathsK  s   **,>H%h/F *84K:(#$9::""CVS^^%cii[J<tLNVS^^%cii[#))ZLIK[#..%cii[#))ZLI=Z r"   c           	   #     #    [         R                  " 5        n[        R                  R	                  U5      nU(       aR  [        R                  R                  [        R                  R                  X!5      5      n[        R                  " U5        [        (       a  SS K	n[        R                  R                  U R                  5      n[        R                  " U5       Hm  nUR                  US5      (       d  M  [        R                  " [        R                  R                  XE5      [        R                  R                  X%5      5        Mo     [        R                  R                  U[        R                  R                  U R                  5      5      n[        R                  " U R                  U5        [        R                   " U R                  U5        X`l        Uv   S S S 5        g ! , (       d  f       g = f7f)Nr   z*.dll)tempfileTemporaryDirectoryr   r   realpathnormpathr6   makedirsr   fnmatchr3   r7   listdirrb  copyfiler   copystat)r=   subdirtmpdirr  exedirf	exec_copys          r    tmpdir_with_python"InitConfigTests.tmpdir_with_python^  s'     ((*f WW%%f-F))"'',,v*FGF#z7F+Aq'22V(?fAXY ,
 VRWW-=-=dmm-LMIOODMM95OODMM95%ML/ +**s$   G=CG,;C(G,#	G=,
G:6G=c           	         U R                  5       nUS   S   n[        R                  R                  R	                  U5      nU H  n[        R                  R                  U5      (       d  M)  [        R                  R                  [        R                  R	                  US5      5      (       d  Mm  [        R                  R                  U5      n  O   U R                  SU< 35        W=pg[        (       aG  [        R                  R	                  US5      nUS   [        R                  R	                  US5      U/n	O~[        R                  R                   S[        R                  R                   3n
[        R                  R	                  U[        R                  S	U
 [         35      nU R!                  XUS
9n	UU	UUUUUUS.nU R#                  U5        XSS.nU R%                  SU[&        US9  g )Nr  rA  r   Unable to find home in Libr   DLLsr   r   r=  r?  r;  rA  r=  r>  r?  r@  r:  rD  TESTHOMEr   test_init_setpythonhomer  r)   )r  r   r   r   r6   isdirr8   r3   r  r   r4   rt  ru  rv  rC  rw  rA  rd  r  r  )r=   r  r  	paths_strr   r;  r=  r?  stdlibexpected_pathsversionr)   s               r    r  'InitConfigTests.test_init_setpythonhomez  s   **,x !67GGOO((/	D77==&&ww~~bggll49::wwt,  II/y9:##:WW\\$.F $AhT6(BFKN))//0#2B2B2H2H1IJGWW\\$&	*8VWF!55T5TN #1!& +' 	
 	!!&)98&#-3 	 	8r"   c           	      T   U R                  5       nUS   S   n[        R                  R                  R	                  U5      nU H  n[        R                  R                  U5      (       d  M)  [        R                  R                  [        R                  R	                  US5      5      (       d  Mm  [        R                  R                  U5      n  O   U R                  SU< 35        W=pg[        (       aG  [        R                  R	                  US5      nUS   [        R                  R	                  US5      U/n	O~[        R                  R                   S[        R                  R                   3n
[        R                  R	                  U[        R                  S	U
 [         35      nU R!                  XUS
9n	UU	UUUUUUS.nXSS.nSUS'   SUS'   U R#                  SU[$        US9  SUS'   SUS'   [        R                  R                  [        R&                  5      n[)        [        R                  R	                  US5      SS9 n[        R                  R+                  [        R                  R	                  XR-                  5        S3R/                  5       S   5      5      U	[        (       a  SOS'   S S S 5        [        (       d6  [        R0                  =pgU R!                  US9S   U	S'   UR3                  XfXwS9  U R#                  SU[$        US9  g ! , (       d  f       Nf= f)Nr  rA  r   r  r  r   r  r   r   r  r  r  1NEGATIVE_ISPYTHONBUILDr_  test_init_is_python_buildr  r   r   pybuilddir.txtr  r   z
$r
   )r=  )r=  r>  r?  r@  )r  r   r   r   r6   r  r8   r3   r  r   r4   rt  ru  rv  rC  rw  rA  r  r  r5   r   r~  r   ri   r=  r  )r=   r  r  r  r   r;  r=  r?  r  r  r  r)   r  r  s                 r    #test_init_is_python_build_with_home3InitConfigTests.test_init_is_python_build_with_home  s   **,x !67GGOO((/	D77==&&ww~~bggll49::wwt,  II/y9:##:WW\\$.F $AhT6(BFKN))//0#2B2B2H2H1IJGWW\\$&	*8VWF!55T5TN #1!& +' 	
  9(+$%%&!":F#-3 	 	8 ),$%%&!"0"'',,v'786Ja57WW5E5EVz%5%@%@%B1%EF6HN

12 K z#&::-F $ 8 8 8 G JN1MM&1  Q:F#-3 	 	8 KJs   
A/L
L'c                     U R                  5       nUS   S   n[        R                  R                  R	                  U5      nXAS'   SU0nU$ )Nr  rA  r:  r   )r  r   r   r   r6   )r=   r  all_configsr  r  r)   s         r    copy_paths_by_env!InitConfigTests.copy_paths_by_env  sP    //1H%&;<GGOO((/	#, Y'
r"   zSee test_init_pybuilddir_win32c           
      &   U R                  5        n[        R                  " S5      =(       d    SnSn[        R                  R                  X5      n[        R                  R                  [        R                  R                  XS5      5      n[        R                  " U5        [        R                  R                  US5      n[        USSS9 nUR                  U5        S S S 5        U R                  5       nXXS	'   XHS
'   U R                  n	[        R                  " S5      [        R                  " S5      U	U	UUS.n
U R                  U
5      nU R                  SU
[        USUS9  S S S 5        g ! , (       d  f       N= f! , (       d  f       g = f)NVPATHr   libdirr  r  wr  r   r   r?  r=  )r@  r>  r<  r5   rA  rD  r  Tr  r)   r  rM   )r  	sysconfigget_config_varr   r   r6   r~  mkdirr   writerA  r7   r  r  r  )r=   r  vpathr  r  	stdlibdirfilenamer   rA  r5   r  r)   s               r    test_init_pybuilddir$InitConfigTests.test_init_pybuilddir  sK    $$&& ,,W5;EFWW\\&1F((fU)KLIHHVww||F,<=Hhf5  6 #'":":"<&/#&,#J$-$<$<]$K(77A#-(':'F ((0C""#<f'1s156 # C9 '& 65 '&s%   B?FE1"BF1
E?	;F
FzSee test_init_pybuilddirc           
         [         R                  " S5      nSn[        R                  R	                  U5      R                  [        R                  5      S:X  a   [        R                  R                  US5      nU R                  U5       n[        R                  R	                  [        R                  R                  X15      5      n[        R                  R	                  [        R                  R                  X1S5      5      n[        R                  R                  US5      n[        USSS	9 nUR                  U5        S S S 5        U R                  5       n[        R                  R                  U[        R                  R                  US
   5      5      US
'   X8S'   XXS'   U R                  n	UUU	U	UUUUS.n
U R                  U
5      nU R                  SU
[         USUS9  S S S 5        g ! , (       d  f       N= f! , (       d  f       g = f)Nr  zPCbuild\archr
   instrumentedr  r  r  r  r   r  r   )r@  r>  r<  r5   r=  r?  rA  rD  r  Fr  )r  r  r   r   r~  countsepr6   r  r   r  rA  r   r7   r  r  r  )r=   r  r  r  r=  r  r  r   rA  r5   r  r)   s               r    test_init_pybuilddir_win32*InitConfigTests.test_init_pybuilddir_win32  s    ((1 77E"((0A5WW\\&.9F$$V,WW%%bggll6&ABF((fU)KLIww||F,<=Hhf5  6 #'":":"<&(ggll6277;K;KL_`bLc;d&e#&,#&/#J$*%#-( %':'	F ((0C""#<f'1s16F # D7 -, 65 -,s&   
B%G>/G-B#G>-
G;	7G>>
Hc                    U R                  5        n[        R                  " 5        n[        R                  n[
        (       dg  [        R                  R                  U[        R                  SUR                   SUR                   [         3S5      n[        R                  " U5        O[        R                  R                  US5      n[        R                  " U5        [        R                  " [        R                  R                  [         R"                  S5      [        R                  R                  US5      5        [        R                  R                  US5      n[%        USSS	9 n['        S
U-  US9  ['        SUS9  S S S 5        U R)                  5       n[
        (       d  WUS'   Oa[        R                  R                  U[        R                  R+                  US   5      5      U[        R                  R                  US5      /nU R,                  n	[        R                  R                  U[        R                  R+                  U	5      5      n
Un[.        R0                  " S5      UUU
U	US.n[
        (       aM  X,S'   X,S'   [        R                  R                  US5      US'   [3        [         R4                  (       + 5      US'   O0U R6                  US'   [3        [         R4                  (       + 5      US'   U R9                  U5      nU R;                  SU[<        USUS9  S S S 5        S S S 5        g ! , (       d  f       GN= f! , (       d  f       N)= f! , (       d  f       g = f)Nr   r   rs  r  r   z
pyvenv.cfgr  r  r   z	home = %sfilez$include-system-site-packages = falser   r   r=  )r>  r@  r?  r<  r5   rA  r>  rD  r]  r  Tr  )r  r{  r|  r4   rt  r   r   r   r6   rC  ru  rv  rw  r  rb  r  r   
STDLIB_DIRr   r\   rA  r   r7   r  r  r   rp  r  r  r  r  )r=   r  pyvenv_homerx  lib_dynload
lib_folderr  r   r  r5   r<  r?  r  r)   s                 r    test_init_pyvenv_cfg$InitConfigTests.test_init_pyvenv_cfg3  s    $$&&((*k""C: ggll;+.>>-3CII;a		{:,+W+8: K(WW\\+u=
J'GGLL!3!3W=GGLLW5
 ww||FL9Hhf5kK/b9<2F 6 ,,.E:'b	 GGLL)9)9%()CDGGLLe4 J ggll;8H8H8TUO%K(77A$/*#2(',F z(3}%#.x ')ww||K'G|$/2w7G7G3G/H+, (,'9'9|$/2w7G7G3G/H+,((0C""#<f'1s156 # Cq + '&( 65' +* '&s<   MEM
,L8F#M
'M8
MM


M	M
M)zspecific to Windowsc           	         SSSSSS[         R                  " 5        S34/nU R                  S0 [        5       ES	[         R                  R
                  R                  S
 U 5       5      0ES9u  p#U R                  US5         [        R                  " U5      nUS   S   n[        X5       H  u  u  pVnU R                  Xv5        M     g ! [        R                   a    U R                  SU< 35         N\f = f)N)z	C:/a. . .	C:\a. . .)r  r  )z\\?\C:////a////b. . .z\\?\C:\a\b. . .)z//a/b/c. . .\\a\b\c. . .)r  r  za. . .z\ar  r   c              3   *   #    U  H	  oS    v   M     g7f)r   Nr   ).0cs     r    	<genexpr>=InitConfigTests.test_getpath_abspath_win32.<locals>.<genexpr>  s     3H%QaD%s   r   r   r  r  rA  )r   r:   rc   r+   r   r   r6   r]   r   r  r  r  zip)r=   CASESra   rb   r   r   r  r	  s           r    test_getpath_abspath_win32*InitConfigTests.test_getpath_abspath_win32s  s    )(@04"))+c*+
 00)J(* Jrww333H%3HHJ 1 

 	b!	9**S/C h- 56%(%8!MQ6V. &9	 ## 	9II/w78	9s   C	 	)C54C5c                 T  ^	 [         R                  " S5      m	U	4S jnU" S5      nU" S5      nU" S5      nU" S5      nU" S5      nU" S5      n[        R                  " 5       S	   nU R	                  U" 5       R                  [        R                  R                  5      US
   5        U R	                  U" 5       US   5        U R	                  U" 5       US   5        U R	                  U" 5       US   5        U R	                  U" 5       US   5        U R	                  U" 5       US   5        g )Nctypesc                 d   > [        TR                  U 5      nSUl        TR                  Ul        U$ )Nr   )getattr	pythonapiargtypes	c_wchar_prestype)r   funcr  s     r    get_func8InitConfigTests.test_global_pathconfig.<locals>.get_func  s.    6++T2DDM!++DLKr"   
Py_GetPathPy_GetPrefixPy_GetExecPrefixPy_GetProgramNamePy_GetProgramFullPathPy_GetPythonHomer  rA  r=  r?  r5  r5   r;  )	r   import_module_testinternalcapiget_configsr]   r   r   r   r   )
r=   r  r  r  r  r  r  r  r  r  s
            @r    test_global_pathconfig&InitConfigTests.test_global_pathconfig  s    ,,X6	 l+
/#$67$%89 ()@ A#$67"..0:++BGGOO< 56	8)9:)+VM-BC*,f^.DE.0&2FG)+VF^<r"   c                 d    / SQn[        [        S9nSSSU/ SQS.nU R                  SX2[        S9  g )N)zignore:::PyConfig_Insert0rP  zignore:::env1zignore:::env2zignore:::cmdline1zignore:::cmdline2r  zignore:::PySys_AddWarnOption1zignore:::PySys_AddWarnOption2zignore:::PyConfig_BeforeReadzignore:::PyConfig_AfterReadr  r   )r  z-Wignore:::cmdline1z-Wignore:::cmdline2)r#  r)  rF  r9  r7  test_init_warnoptionsr  )r%   r  r  r  )r=   r9  r  r  s       r    r  %InitConfigTests.test_init_warnoptions  sK    + #89	&1
 	6#- 	 	/r"   c                 <    SSS/S.nU R                  SU[        S9  g )Nr   r
   zerror::BytesWarning)r\  rF  r9  test_init_set_configr  r  r$  s     r    r  $InitConfigTests.test_init_set_config  s2    12

 	5v#/ 	 	1r"   c                 &    U R                  S5        g )Ntest_get_argc_argvrc   rG   s    r    r  "InitConfigTests.test_get_argc_argv  s    %%&:;r"   c           
         1 SknU He  u  p#SU 3nSS/SSUSS/SSSU/US	.nU(       a  S
USS  0OS nU R                  [        U5      5         U R                  SU[        US9  S S S 5        Mg     g ! , (       d  f       My  = f)N>   z=onTz=offFr   Tr  Tfrozen_modulesTr  rZ  r  r  r  )r  r6  r7  r5  rU  r"  r8  r]  
TESTFROZENr   test_init_use_frozen_modulesr  )r  reprr  r  )r=   testsrawr  optvalr  r)   s          r    r  ,InitConfigTests.test_init_use_frozen_modules  s    
 #MC%cU+F"'vtVD )'#'#H&.	F .1<QR)dCd3i(&&'Ev+53 ' @ )( # )(s   A11
B 	c                 4   SnSnSnSnSnSnX-  U-  U-  U-  SS.nU R                  S	5      u  pU R                  U	S
5         [        R                  " U5      nU R                  X5        g ! [        R                   a    U R                  SU< 35         N=f = f)N       i   i   i   i   T)feature_flagsown_gil#test_init_main_interpreter_settingsr   r  )rc   r]   r   r  r  r  )
r=   OBMALLOC
EXTENSIONSTHREADSDAEMON_THREADSFORKEXECr  ra   rb   s
             r    r  3InitConfigTests.test_init_main_interpreter_settings  s    
 $&0>A	
 001
 	b!	9**S/C 	' ## 	9II/w78	9s   A+ +)BBc                 N    U R                  S5      u  pU R                  US5        g )Ntest_init_in_background_threadr   r   r   s      r    r  .InitConfigTests.test_init_in_background_thread  s'     001QRb!r"   )r7   rF   )NNNN)NN)dr}   r~   r   r   r   r   r  objectr  r  r  PYMEM_ALLOCATOR_NOT_SETr  r  r%   r  r  r  r  r  r4   int_infodefault_max_str_digitsrC  r   rp  r  r  r   r  r  r  r  r  rS   r{  classmethodr|  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r
  r  r  r  r  r"  r'  r+  r.  r1  r4  r7  r:  r   skiprD  rJ  rO  rS  r[  r^  rd  rh  ro  rA  
contextlibcontextmanagerr  r  r  r  skipIfr  r  r  r  r  r  r  r  r  r  r  r   requires_working_threadingr  r   r   r"   r    r  r    s   G+5;L   HM #, !   (!"
 	 .*$	 0!OM
MEM 	4M 	E	M 	"4M 	M 	QM 	cllAAM 	RM 	M 	qM 	%M 	uM 	TM  	%!M" 	U#M$ 	$%M& 	'M* 	1+M, 	/-M0 	$1M2 	*3M4 	e5M6 	7M8 	R9M< 	B=M> 	r?MB 	$CMD 	EMF 	(GMH 	-IML 	$MMN 	)OMP 	)QMR 	.SMT 	1UMV 	"4WMX 	cnnYMZ 	([M^ 	t_M` 	aMb 	 cMd 	5eMf 	ugMh 	aiMj 	kMl 	$mMn 	1oMp 	qMr 	tsMt 	UuMv ,*"'" )#")"2"22)YMM\ $%j!'+m$&(l#"A
 	 M
 =!! %!O 23./ ,-$%01 	%( %% '
 	 	!! #
 	 O# #<>" 6:=8~/+$=, ;?-1)-!%4 >B"%T	4lNMJ/.A/F /D!/F//
//&1$RQQQNMJ/ ]] < =;=;L(MS$	O/ 3,L2&  6'8R:8x __Z!AB!C C!CF %?@%D A%DN>C@ %:;/ </6#=J/61<@0(0 002" 3"r"   r  c                       \ rS rSrS rSrg)SetConfigTestsi  c                    [         R                  " S5        [        R                  SSSSS/n[        R
                  " U[        R                  [        R                  SSS	9nUR                  (       a?  [        R                  (       a*  [        UR                  5        [        UR                  5        U R                  UR                  S
UR                  UR                  UR                  45        g )N	_testcapir  r  r  z-mztest._test_embed_set_configr   backslashreplace)rP   rQ   r   r   r   )r   r  r4   r5   rU   r   rW   rK   r   r[   r\   rP   rQ   r]   )r=   r_   r  s      r    test_set_configSetConfigTests.test_set_config  s    ##K0~~tVT49VW~~c%/__%/__'.7IK ??w$++$++!//4;;D	Fr"   r   N)r}   r~   r   r   r  r   r   r"   r    r  r    s    Fr"   r  c                   P    \ rS rSrS rS rS rS rS rS r	S r
S	 rS
 rS rSrg)AuditingTestsi$  c                 &    U R                  S5        g )Ntest_open_code_hookr  rG   s    r    r"  !AuditingTests.test_open_code_hook%  s    %%&;<r"   c                 &    U R                  S5        g )N
test_auditr  rG   s    r    r%  AuditingTests.test_audit(  s    %%l3r"   c                 &    U R                  S5        g )Ntest_audit_tupler  rG   s    r    r(  AuditingTests.test_audit_tuple+  s    %%&89r"   c                 &    U R                  S5        g )Ntest_audit_subinterpreterr  rG   s    r    r+  'AuditingTests.test_audit_subinterpreter.      %%&ABr"   c                 B    U R                  S[        R                  SS9  g )Ntest_audit_run_commandr   rJ   rK   rc   r   SHORT_TIMEOUTrG   s    r    r/  $AuditingTests.test_audit_run_command1  s$    %%&>.5.C.C12 	& 	4r"   c                 B    U R                  S[        R                  SS9  g )Ntest_audit_run_filer   r0  r1  rG   s    r    r5  !AuditingTests.test_audit_run_file6  s$    %%&;.5.C.C12 	& 	4r"   c                    [         R                  R                  U R                  [        R
                  5      S-   n[        USSS9 n[        SUS9  [        SUS9  S S S 5         0 [        5       ESU0EnU R                  S	[        R                  S
US9  [         R                  " U5        g ! , (       d  f       NV= f! [         R                  " U5        f = f)N.pyr  r   r   z
import sysr  z&sys.__interactivehook__ = lambda: NonePYTHONSTARTUPtest_audit_run_interactivehook
   rJ   rK   r)   r   r   r6   r;   r   TESTFNr   r\   r+   rc   r   r2  unlinkr=   startupr  r)   s       r    r:  ,AuditingTests.test_audit_run_interactivehook;  s    '',,t{{I,<,<=E'31Q,Q':C 2	G*,GowGC))*J292G2G57S * B IIg 21 IIgs   B,%0B= ,
B:=Cc                    [         R                  R                  U R                  [        R
                  5      S-   n[        USSS9 n[        SUS9  S S S 5         0 [        5       ESU0EnU R                  S[        R                  S	US
9  [         R                  " U5        g ! , (       d  f       NV= f! [         R                  " U5        f = f)Nr8  r  r   r   r  r  r9  test_audit_run_startupr;  r<  r=  r@  s       r    rD  $AuditingTests.test_audit_run_startupH  s    '',,t{{I,<,<=E'31Q&q! 2	G*,GowGC))*B292G2G57S * B IIg 21 IIgs   B"0B3 "
B03Cc                 B    U R                  S[        R                  SS9  g )Ntest_audit_run_stdinr   r0  r1  rG   s    r    rG  "AuditingTests.test_audit_run_stdinT  s$    %%&<.5.C.C12 	& 	4r"   c                 &    U R                  S5        g )Ntest_get_incomplete_framer  rG   s    r    rJ  'AuditingTests.test_get_incomplete_frameY  r-  r"   r   N)r}   r~   r   r   r"  r%  r(  r+  r/  r5  r:  rD  rG  rJ  r   r   r"   r    r   r   $  s6    =4:C4
4

4
Cr"   r   c                   "   \ rS rSrS r\R                  " \R                  S:H  S5      \R                  " \	SL S5      S 5       5       r
\R                  " \R                  S5      S	 5       r\R                  " \R                  S
5      S 5       rSrg)	MiscTestsi]  c                 &    U R                  S5        g )Ntest_unicode_id_initr  rG   s    r    rO  MiscTests.test_unicode_id_init^  s     	%%&<=r"   ntz(Py_FrozenMain is not exported on WindowsNr  c                    [        [        R                  5      nSUS'   U R                  SUS9u  p#[        R                  R                  S5      n[        R                  " SU S35      R                  5       nU R                  X%5        g )Nr  PYTHONUNBUFFEREDtest_frozenmainr   rZ  z
            Frozen Hello World
            sys.argv ['./argv0', '-E', 'arg1', 'arg2']
            config program_name: ./argv0
            config executable: z
            config use_environment: True
            config configure_c_stdio: True
            config buffered_stdio: False
        )
r%   r   r&   rc   r   r}  r   r   lstripr]   )r=   r)   ra   rb   r5   r  s         r    rT  MiscTests.test_frozenmaind  s     2::"%001B0LWW%%i0
?? (  !+| ,		$  VX 	 	'r"   z--X showrefcount requires a Python debug buildc           	         SnU GH1  u  p#SU 3n[         R                  SSSSUSU/n[        R                  " U[        R                  [        R
                  SS9nU R                  UR                  S	5        UR                  R                  5       n[        R                  " S
U5      nU(       d  U R                  SU< 35        [        UR                  S5      5      n	[        UR                  S5      5      n
U R                  X#S9   U R                  U	S	U5        U R                  U
S	U5        S S S 5        GM4     g ! , (       d  f       GMG  = f)N))offr  )onr  )rX  import __hello__)rY  rZ  zfrozen_modules=r  r  showrefcountr  TrP   rQ   r  r   z!^\[(-?\d+) refs, (-?\d+) blocks\]zunexpected output: r   r
   )r  stmt)r4   r5   rU   r   rW   STDOUTr]   rK   rP   r   rm   rn   r  r   groupr  )r=   r  flagr]  xoptr_   r  ra   rn   refsblockss              r    test_no_memleakMiscTests.test_no_memleakw  s   
  JD$TF+D>>4~tT4QUVC>>#)3)3):):'+-D T__a0++$$&CHHA3GE		/w78u{{1~&DQ(FT=  q#.  C0 >=   >=s   'D<<
E	z(-X presite requires a Python debug buildc                 n   [         R                  SSSSS/n[        R                  " U[        R                  [        R
                  SS9nU R                  UR                  S5        UR                  R                  5       nU R                  S	U5        U R                  S
U5        U R                  SU5        g )Nr  r  zpresite=test.reperfr  zprint('cmd')Tr\  r   z10 times subzCPU secondsr_   )r4   r5   rU   r   rW   r^  r]   rK   rP   r   r   )r=   r_   r  ra   s       r    test_presiteMiscTests.test_presite  s     ~~tT+@$W~~??$$	
 	!,kk!nc*mS)eS!r"   r   )r}   r~   r   r   rO  r   r  r   r   r  rT  r  r   rp  rd  rg  r   r   r"   r    rM  rM  ]  s    > __RWW_?A__&$.0LM( NA(  ))HJ1J14 ))CE"E"r"   rM  __main__)@testr   test.supportr   r   r   r   r   collectionsr   r  ior   r   os.pathrm   rb  rU   r4   r  r{  r   has_subprocess_supportr   r  ImportErrorplatformra  r  r  PYMEM_ALLOCATOR_MALLOCPYMEM_ALLOCATOR_MIMALLOCr   r  hasattrr  r  r  r  r   MAX_HASH_SEEDr  rw  r   r6   r=  rC  rt  ru  rv  STDLIB_INSTALLisfiler!   r+   r-   TestCaser   r  r  r  r   rM  r}   rz   r   r"   r    <module>ry     s'    O O  "  	  	  	   
   %%


=
>>
 
	!    
313$ 


,,->??SR

 cjj#..S##$Ac&6&6&<&<%=>@	ww~~bggll>7;<<N5k! k!\r8((*;*; r8j	 
"d*,HI`")8+<+< `" J`"F)FX&& F 6C'):): 6CrD"#X%6%6 D"N zMMO U<  s   1H H%$H%