python (3.12.0)

(root)/
lib/
python3.12/
test/
__pycache__/
test_embed.cpython-312.opt-1.pyc

͑eddlmZddlmZddlmZddlmZddlZddlmZddl	Z	ddl
Z
ddlZddlZddl
Z
ddlZddlZddlZddlZddlZddlZej(sej*dej,dk(Zej0d	k(ZdZd
ZdZdZd
ZdZd
Z dZ!ejDjGejHejJdejLjNdejLjPZ)ejDjUejDjGe)dsdZ)dZ+dZ,GddZ-Gdde-ej\Z/Gdde-ej\Z0Gddej\Z1Gdde-ej\Z2Gdde-ej\Z3Gd d!e-ej\Z4e5d"k(rejlyy)#)support)
import_helper)	os_helper)requires_specializationN)
namedtupleztest module requires subprocessntdarwinlpython.os.pyctjj|}tjj|d}|j	jdj	S)Nr_d)ospathbasenamesplitextcasefoldendswith)programnames  C/BuggyBox/python/3.12.0/bootstrap/lib/python3.12/test/test_embed.pydebug_buildr0sLggw'G
77G$Q'D==?##DMMO44cttj}t|D]}|j	ds||=|S)NPYTHON)dictrenvironlist
startswith)envkeys  rremove_python_envvarsr&6s=
rzz
CCy>>(#CJrc2eZdZdZdZdddddddZdZy)EmbeddingTestsMixincd}tjjtj}t
r(t
tjrdnddz}||z
}|}n tjj|d}tjj||x|_}tjj|s|jd|ztj|_tj|y)N
_testembedr.exeProgramsz%r doesn't exist)rrdirnamesys
executable
MS_WINDOWSrjointest_exeexistsskipTestgetcwdoldcwdchdir)selfexenamebuilddirextexepathexes      rsetUpzEmbeddingTestsMixin.setUp@s77??3>>2&s~~64B&HCsNGGggll8Z8G ggll7G<<
ww~~c"MM,s23iik
rcBtj|jyN)rr8r7r9s rtearDownzEmbeddingTestsMixin.tearDownRs
rNr)r$timeout
returncodeinputcwdc|jg}|j||,tr&|j}tj
d|d<t
j|tjtjd||}	|j||\}	}
|j|k7rFtjr6td|dtd|	td|
td	|j!|j|d
|j|
fz|	|
fS#|j|jxYw)z'Runs a test in the embedded interpreter
SYSTEMROOTT)stdoutstderruniversal_newlinesr$rG)rFrDz--- z failed ---zstdout:
zstderr:
z------zbad returncode %d, stderr is %r)r3extendr1copyrr!
subprocessPopenPIPEcommunicate	terminatewaitrErverboseprintassertEqual)r9r$rDrErFrGargscmdpouterrs           rrun_embedded_interpreterz,EmbeddingTestsMixin.run_embedded_interpreterUs!}}o

4?z((*C "

< 8CS$.OO$.OO04!$!$
&	UGDJS#

<<:%'//D[)*IcU#$IcU#$(Oz:,,,-	.Cx	
KKM
FFHsD  #Ec#ZK|jd\}}|j|dd}tdd}d}g}|jD][}|dj	|k(r?|jt|dtjdkDrt||dz
}W|jt|d	tj||}||j||||j}	tjdkDrt|	|j|	j|j|	j |j|	j"|j%|	t|d	k(s?|d}
|j|	|
|g}^yw)
N&test_repeated_init_and_subinterpretersr+zS^interp (\d+) <(0x[\dA-F]+)>, thread state <(0x[\dA-F]+)>: id\(modules\) = ([\d]+)$Interpzid interp tstate modulesrz--- Pass {} ---r)r]rWr
splitlinesformatlenrrUrV
assertLessrematchassertRegexgroups
assertTrueinterptstatemodulesappend)r9r[r\
interp_patr`numloopscurrent_runlinergrkmains           r%run_repeated_init_and_subinterpretersz9EmbeddingTestsMixin.run_repeated_init_and_subinterpretersxsw001YZSb!2
H&@ANN$	!D(//99  [!115??Q&$KA
OOC,a0HHZ.E}  z2U\\^,F"f
OOFMM*OOFMM*OOFNN+v&;1$"1~  .!! 9	!sFF+
!F+)__name__
__module____qualname__r?rCr]rtrrr(r(?s&$37)-!4%)!F1!rr(czeZdZdZdZdZdZdZdZdZ	dZ
d	Zd
ZdZ
dZd
ZdZdZedZdZy)EmbeddingTestsicp|jD]#}|d}|j|jd%y)Nr0)rtrWid)r9runrss   rtest_subinterps_mainz#EmbeddingTests.test_subinterps_mains7==?	+Cq6DTWWc*	+rc	|jD][}|^}}}t|j}t|D]0\}}|j	|jt||zdz2]y)Nr)rtintr}	enumeraterWstr)r9r~rssubs_mainidisubs        rtest_subinterps_different_idsz,EmbeddingTests.test_subinterps_different_idssj==?	>C ND4\F#D/
>3  VaZ!^)<=
>		>rc^|jD]}|^}}}d|vrtjd|D]t}|j|j|j|j|j
|j
|j|j|jvy)N0x0zplatform prints pointers as 0x0)rtunittestSkipTestassertNotEqualrkrlrm)r9r~rsrrrs      rtest_subinterps_distinct_statez-EmbeddingTests.test_subinterps_distinct_states==?	?C ND4}
''(IJJ
?##CJJ<##CJJ<##CKK>
?	?rc|jd\}}|j|dtdtdzDcgc]}d|d
}}dj	|dz}|j||ycc}w)Ntest_repeated_init_and_inittabr+rz	--- Pass z ---
)r]rWrange
INIT_LOOPSr2)r9r[r\rliness     rrz-EmbeddingTests.test_repeated_init_and_inittabsw001QRSb!.3Az!|.DE9QCt$EE		% 4'e$Fs
A2cpttjd}|jd|\}}tj
dkDr t
t
|t
|d}d}djgd	}|j|||
}d|_	|j|j|y)Nzutf-8:surrogateescape)PYTHONIOENCODINGtest_forced_io_encodingr$rutf-8surrogateescaper)z--- Use defaults ---Expected encoding: defaultExpected errors: defaultzstdin: {in_encoding}:{errors}zstdout: {out_encoding}:{errors}'stderr: {out_encoding}:backslashreplacez--- Set errors only ---rzExpected errors: ignorezstdin: {in_encoding}:ignorezstdout: {out_encoding}:ignorerz--- Set encoding only ---Expected encoding: iso8859-1rzstdin: iso8859-1:{errors}zstdout: iso8859-1:{errors}"stderr: iso8859-1:backslashreplacez--- Set encoding and errors ---rzExpected errors: replacezstdin: iso8859-1:replacezstdout: iso8859-1:replacer)in_encodingout_encodingerrors)r rr!r]rrUrVr2rcmaxDiffrWstrip)r9r$r[r\expected_stream_encodingexpected_errorsexpected_outputs       rrz&EmbeddingTests.test_forced_io_encodings2::0GH001JPS0TS??QG#J#J#* +))%./2*00,D-E'618
o6rcttjtjj	t
j}|jd|\}}tr
|j}n2tjj	tjd}d|d}|j|||j|dy)	z
        Checks some key parts of the C-API that need to work before the runtime
        is initialized (via Py_Initialize()).
        )
PYTHONPATHtest_pre_initialization_apirspamzsys.executable: rr+N)
r rr!pathsepr2r/rr]r1r3r6assertInrW)r9r$r[r\
expected_pathrs      rrz*EmbeddingTests.test_pre_initialization_apis
2::"**//#((*CD001NTW0XS MMMGGLLf=M,]O2>

os+b!rct}tjjtj
|d<|j
d|\}}d}|j|||j|dy)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_optionsrzsys.warnoptions: ['once', 'module', 'default']
sys._xoptions: {'not_an_option': '1', 'also_not_an_option': '2'}
warnings.filters[:3]: ['default', 'module', 'once']
r+N)	r&rrr2r/rr]rrW)r9r$r[r\rs     rrz2EmbeddingTests.test_pre_initialization_sys_optionssq
$%JJOOCHH5L00=31HS
D	
	


os+b!rct|jd\}}|j|d|j|dy)ze
        bpo-20891: Calling PyGILState_Ensure in a non-Python thread must not
        crash.
        
test_bpo20891r+Nr]rWr9r[r\s   rrzEmbeddingTests.test_bpo20891%s8
00ASb!b!rct|jd\}}|j|d|j|dy)zf
        bpo-33932: Calling Py_Initialize() twice should do nothing (and not
        crash!).
        test_initialize_twicer+Nrrs   rrz$EmbeddingTests.test_initialize_twice.s9
001HISb!b!rc|jd\}}|j|jd|j|dy)zS
        bpo-34008: Calling Py_Main() after Py_Initialize() must not fail.
        test_initialize_pymainz6Py_Main() after Py_Initialize: sys.argv=['-c', 'arg2']r+Nr]rWrstriprs   rrz%EmbeddingTests.test_initialize_pymain7s@001IJS'_`b!rc|jd\}}|j|jd|j|dy)N
test_run_mainz%Py_RunMain(): sys.argv=['-c', 'arg2']r+rrs   rrzEmbeddingTests.test_run_main?s=00AS'NOb!rc~d}|jd\}}|j|d|z|j|dy)Nratest_run_main_loopz&Py_RunMain(): sys.argv=['-c', 'arg2']
r+r)r9nloopr[r\s    rrz!EmbeddingTests.test_run_main_loopDsD001EFSG%OPb!rctjd}t|d5}|j}ddd|j	d\}}|j|dtzy#1swY8xYw)Nz_test_embed_structseq.pyrencodingtest_repeated_init_exec
Tests passed
)rfindfileopenreadr]rWr)r9scriptfpcoder[r\s      rtest_finalize_structseqz&EmbeddingTests.test_finalize_structseqLsn!!"<=
&7
+	r779D	001JDQS.;<		sA++A4c^|jd\}}|j|dtzy)Ntest_repeated_simple_initz
Finalized
r]rWrrs   rtest_simple_initialization_apiz-EmbeddingTests.test_simple_initialization_apiXs.001LMSmj89rctjd}|j}|d|\}}|j|dtzy)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_instructions
                        # 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")
        rr)textwrapdedentr]rWr)r9rr~r[r\s     r>test_specialized_static_code_gets_unspecialized_at_Py_FINALIZEzMEmbeddingTests.test_specialized_static_code_gets_unspecialized_at_Py_FINALIZE^sK 
>++0$7S.;<rcdd}|jd|\}}|j|dtzy)Nzprint('\N{digit nine}')rz9
r)r9rr[r\s    rtest_ucnhash_capi_resetz&EmbeddingTests.test_ucnhash_capi_resets3)001JDQSej01rN)rurvrwrrrrrrrrrrrrrrrrrrrxrrrzrzshG+>?*%)7V
"""""""
"
=:$=$=L2rrzczeZdZdZerdndZeZeZe	e
ddddddZerejddie
eedeeZe
eedddddd	Zgd
Zide	ddd
ddddddddddej(j*dddddddddddddddddeideddded dd!d"gd#gd$gd%gd&dd'dd(ed)ed*ed+ed,ed-ed.eid/dd0ej,d1ed2dd3dd4dd5dd6dd7dd8dd9dd:dd;dd<dd=dd>dd?eedddddd@ddej0dedAZerejdBdie
eeddCDZe
eedddddddddddE
ZerdedB<ddddFZdGgZgdHZer"ej?dIej?dJdZ e!dKZ"dLZ#dMZ$dNZ%	ddOZ&dPZ'dQZ(dRZ)				ddddSddTdUZ*dVZ+dWZ,dXZ-dYZ.dZZ/d[Z0d\Z1d]Z2d^Z3d_Z4d`Z5daZ6dbZ7dcZ8ddZ9deZ:dfZ;dgZ<dhZ=diZ>e?jdjdkZAdlZBdmZCdnZDdoZEdpZFdqZGdrZHdsZIddtZJeKjdduZMdvZNdwZOdxZPe?jedydzZRe?jed{d|ZTd}ZUe?jed~dZVdZWdZXdZYdZZdZ[dZ\y)InitConfigTestsi
surrogatepassrrr)_config_init	allocator
parse_argvconfigure_localecoerce_c_localecoerce_c_locale_warn	utf8_modelegacy_windows_fs_encoding)rrrr)rrisolateduse_environmentrdev_moder)rrrrrrrinstall_signal_handlers
use_hash_seed	hash_seedint_max_str_digitsfaulthandlertracemallocperf_profilingimport_timecode_debug_rangesshow_ref_count	dump_refsmalloc_statsfilesystem_encodingfilesystem_errorspycache_prefixNprogram_namerargvr+	orig_argvxoptionswarnoptionspythonpath_envhomer0base_executableprefixbase_prefixexec_prefixbase_exec_prefixmodule_search_pathsmodule_search_paths_set
platlibdir
stdlib_dirsite_import
bytes_warningwarn_default_encodinginspectinteractiveoptimization_levelparser_debugwrite_bytecoderUquietuser_site_directoryconfigure_c_stdiobuffered_stdiostdio_encodingdefault)stdio_errorsskip_source_first_linerun_command
run_modulerun_filename_install_importlibcheck_hash_pycs_modepathconfig_warnings
_init_mainuse_frozen_modules	safe_path_is_python_buildlegacy_windows_stdior
)rrr)rrrr
rrrrrrrr)Py_HasFileSystemDefaultEncodingPy_HashRandomizationFlag$_Py_HasFileSystemDefaultEncodeErrors)Py_UTF8Moder))Py_BytesWarningFlagr)Py_DebugFlagr
)Py_DontWriteBytecodeFlagrT) Py_FileSystemDefaultEncodeErrorsr)Py_FileSystemDefaultEncodingr)
Py_FrozenFlagrT)Py_IgnoreEnvironmentFlagrT)Py_InspectFlagr)Py_InteractiveFlagr)Py_IsolatedFlagr)
Py_NoSiteFlagrT)Py_NoUserSiteDirectoryr
T)Py_OptimizeFlagr	)Py_QuietFlagr)Py_UnbufferedStdioFlagrT)Py_VerboseFlagrU))Py_LegacyWindowsFSEncodingFlagr))Py_LegacyWindowsStdioFlagrcd|_yrA)EXPECTED_CONFIG)clss r
tearDownClasszInitConfigTests.tearDownClassEs#rc`i}|D]&}d|vr|jdd\}}|||<"d||<(|S)N=rT)split)r9
xoptions_listroptr%values      r
main_xoptionszInitConfigTests.main_xoptionsJsJ 	%Ccz YYsA.
U %
 $
	%rct}tjd}tjdd|g}tj||t
jt
j}|jr%td|jd|j|jjd}	tj|S#tj$r|j!d|YywxYw)	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$rJrKz)failed to get the default config: stdout=z stderr=rfail to decode stdout: )r&rrr/r0rOr~rQrE	ExceptionrJrKdecodejsonloadsJSONDecodeErrorfail)r9r$rrXprocrJs      r_get_expected_config_implz)InitConfigTests._get_expected_config_implTs#% 
dD1~~d%/__%/__6??&&*kk_HT[[OMN
N##G,	<::f%%##	<II/z:;	<s6C'C54C5c$t}|j|j|_i}|jjD]I\}}i}|jD]*\}}t	|t
r|j
}|||<,|||<K|SrA)rr6rJitems
isinstancer"rN)r9r7configs
config_keyconfig_valueconfigr%r>s        r_get_expected_configz$InitConfigTests._get_expected_configss&"&"@"@"BC(+(;(;(A(A(C	)$JF*002
$
UeT*!JJLE#s
$#)GJ
	)rc|j}|d}|jD]\}}	|	|jus||||<|dr	|tk(rdD]}|j||<|ds|j|d<|ddk(rb|d|jurd|d<|d|jur|j
|d<|d	|jurd|d	<|d
|jurd|d
<tr
|j}
nf|d|jur#tjj|d}
n2tjjtjd
}
|d|jur|
|d<|d|jur|
|d<|d|jurd|d<|d}|jD]\}}	|	|jus||||<|d|jur_|d}|5|jtjj}
g|
|d|d<|!|dj|d<||d|j D]}||vs||||<y)N
pre_configr)rrrrrrrrrrrrrr*r0rz./_testembedrQrr)rRrLGET_DEFAULT_CONFIG
API_COMPAT
IGNORE_CONFIGUTF8_MODE_ERRORSr1r3rrabspathr2r6r;rrNCOPY_PRE_CONFIG)r9expected_preconfigexpectedr$apimodify_path_cbrNrTr%r>default_executablerQrpathss              rget_expected_configz#InitConfigTests.get_expected_configs++-\*
,224	:JC///*4S/"3'	:""45
9J:
3 $ 2 2

3""45/3.@.@{+k*a/-.$2I2II29./+,0G0GG040E0E,-()T-D-DD-4)*'4+B+BB+<(!%
n
%T-D-D
D!#.1I!J!#biik<!HL!T%<%<<%7H\"%&$*A*AA*<H&'N#t'>'>>'5H^$""..*	,JC/// &s
	,)*$2D2DD%&67N)&,,RWW__=2\E2\HEZ<[2\./)2:;P2Q2V2V2X./x(=>?''	8C,,*23-"3'	8rct|d}t|jD])\}}||jus|j	|d||=+|j||y)NrT)r r"rLrWpoprW)r9rNr\rTr%r>s      rcheck_pre_configz InitConfigTests.check_pre_configse',/0
x~~/0	"JC***sD)SM	"	
X.rct|d}tr|jdx}}|rt|trt|dt|j
jd}ttjr+|dt|j
jd}|||<t|jD])\}}||jus|j|d||=+|j||y)NrQrr,r)r r1getrMrrdlowerremovesuffixrr/r0r"rLrWrcrW)r9rNr\rQr%r>s      rcheck_configzInitConfigTests.check_configsgh'(JJn4s5EE3/Fs5;;=#=#=f#EFGs~~.!"H3u{{}'A'A$'G#HIE#sx~~/0	"JC***

3%SM	"	
*rch|d}|d}t|j}|jD]0}t|dk(r|\}}}||rdnd||<$|\}}||||<2|jD]0}t|dk(r|\}}}||rdnd||<$|\}}||||<2|j|d|y)NrTrQrrr
global_config)r DEFAULT_GLOBAL_CONFIGCOPY_GLOBAL_CONFIGrdCOPY_GLOBAL_PRE_CONFIGrW)	r9rNrTrQr\item
global_keycore_keyopposites	         rcheck_global_configz#InitConfigTests.check_global_configs\*
"223++	8D4yA~15.
Hh,28,<q!$'+$
H'-h'7$
	8//	<D4yA~15.
Hh,6x,@qa$'+$
H'1(';$
	<	
18<rF)
preconfig_apir$
ignore_stderrrGct}||j||}||}|tk(r
|j}n"|tk(r
|j
}n|j}|i}t|fi|}|i}|tk(r
|j}
n"|tk(r
|j}
n|j}
t|
fi|}|j||||||j|||
\}}||dsd}|"|	s |j|j|	tj |}|j'||j)|||j+||S#tj"$r|j%d|Y`wxYw)N)r$rGrUr+rB)r&updateAPI_ISOLATEDPRE_CONFIG_ISOLATED
API_PYTHONPRE_CONFIG_PYTHONPRE_CONFIG_COMPATr 
CONFIG_PYTHONCONFIG_ISOLATED
CONFIG_COMPATrar]rWrrErFrGrHrdrirs)r9testnameexpected_configr[r^rKr]rtr$rurGnew_envdefault_preconfigdefault_configr[r\rNs                 rcheck_all_configsz!InitConfigTests.check_all_configss
()?NN3 ML( $ 8 8
j
( $ 6 6 $ 6 6%!#!"3J7IJ" O*!//N
L
 !11N!//N~AA  !3!0!$!$n	6
0058c1CS>/)"<FmSZZ\62	9jjoG	
g'9:'?3  )
##	9II/w78	9sE'FFc2|jdty)Ntest_init_initialize_configr]rrVrBs rtest_init_default_configz(InitConfigTests.test_init_default_config%s<*Mrc2|jdty)Ntest_preinit_compat_configrrrBs rrz*InitConfigTests.test_preinit_compat_config(;Lrc2|jdty)Ntest_init_compat_configrrrBs rrz'InitConfigTests.test_init_compat_config+8jIrc`ddi}ddddgdddddddddd
}|jd||t	y)
Nrrz./globalvarrdefault::BytesWarningr
)
rrrrrrr	rrUrrr
rtest_init_global_configrrr9	preconfigrQs   rrz'InitConfigTests.test_init_global_config.s`
	*34"##$#$
 	
8&)#-		/rcLtdd}idddddddd	d
dddddd
ddddddddddddddgdgddd	dgdidgd d!d"d#dd$dd%dd&dd'd	d(dd)dd*dd+dd,dd-dd.dd/d0d1|jd2dd3d4dd5}|jd6||t7y)8Nrrrrrrr{rr
rrrrrr	iso8859-1rreplacerconf_pycache_prefixrz./conf_program_namerrAarg2r)python3-Wcmdline_warnoption-Xcmdline_xoptionrApassrrr)zconfig_xoption1=3zconfig_xoption2=config_xoption3rr)rrconfig_warnoptionrpass
rrrrr	rrUrrrr
rr
my_platlibdirrriizalways)rrrtest_init_from_configrPYMEM_ALLOCATOR_MALLOCrWrrVrs   rrz%InitConfigTests.test_init_from_configEs/
	7
%q7
Q7

7

1	7


a7

1
7

 7

a7

A7

k7

I7

37

17
 
T6N!7
"
"#7
,
!-7
.
/7
:
;7
D
8E7
H
1I7
J
QK7
L
qM7
N
1O7
P
!!Q7
R
aS7
T
qU7
V
QW7
X
 Y7
Z
a[7
\
"1]7
^
A_7
`
/a7
b
"4#5#5c7
d
e7
f#($,#$m7
p	
6	#-		/rcdti}idddddddd	d
ddd	ddd
ddddddddd	dddd	dddddd	ddgd|jddd}|jd||t y)!Nrrrr*rr
rrrrrrr	r/my/pathrenv_pycache_prefixrrUrrrrrr
EnvVarenv_platlibdirrrrrrrtest_init_compat_envrrrs   rrz$InitConfigTests.test_init_compat_envs/
	
Q


1

a	


1

 


A

q

!!

j

2

a

q

a

k
 
I!
"
"1#
$$:*#'#5#5"&/
2	
5vy#-		/rctdd}idddddddd	d
ddd	ddd
ddddddddd	dddd	dddddd	ddgd|jddd}|jd||t y)!Nrrrrrrr
rrrrrrr	rrrrrrUrrrrrr
rrrrtest_init_python_envr)rrWrrzrs   rrz$InitConfigTests.test_init_python_envs/
	
Q


1

a	


1

 


A

q

!!

j

2

a

q

a

k
 
I!
"
"1#
$$:*#'#5#5"&/
2	
5vy#-		/rcttt}tdddg}|jd||ty)Nrrrrrrtest_init_env_dev_moder)r PYMEM_ALLOCATOR_DEBUGrrVrs   rrz&InitConfigTests.test_init_env_dev_modes@#89	q#$#,+/	
7#-		/rcttt}tdddg}|jd||ty)Nrrrrtest_init_env_dev_mode_allocr)r rrrVrs   rrz,InitConfigTests.test_init_env_dev_mode_allocs@#9:	q#$#,+/	
=vy#-		/rcTdti}dddgd}|jd||ty)Nrrr)rrrtest_init_dev_moder)rrrzrs   rrz"InitConfigTests.test_init_dev_modesB.
	%;

	
3VY#-		/rc	dti}dggdtjjddddgdgdd}|j	d||t
	y)
Nr	script.py)rrdev-Prrrr)rrrrrrrrtest_preinit_parse_argvr)rrrrYrrzrs   rrz'InitConfigTests.test_preinit_parse_argvsd
.
	!MDGGOOK8%;	
	
8&)#-		/rcRddi}gd}||dd}|jd||ty)Nrr)	r-E-Irrrrutf8r)rrrtest_preinit_dont_parse_argvrrrx)r9rrrQs    rrz,InitConfigTests.test_preinit_dont_parse_argvsH

	

	
=vy#/		1rcBddddd}|jd|ty)Nrrrrrr
test_init_isolated_flagrrrzr9rQs  rrz'InitConfigTests.test_init_isolated_flags- #$	
	
8&jQrcBddddd}|jd|ty)Nrrrtest_preinit_isolated1rrrs  rrz&InitConfigTests.test_preinit_isolated1/ #$	
	
7ZPrcBddddd}|jd|ty)Nrrrtest_preinit_isolated2rrrs  rrz&InitConfigTests.test_preinit_isolated2rrc2|jdty)Ntest_preinit_isolated_configrrrBs rrz,InitConfigTests.test_preinit_isolated_config$s=<Prc2|jdty)Ntest_init_isolated_configrrrBs rrz)InitConfigTests.test_init_isolated_config's:Mrc2|jdty)Ntest_preinit_python_configrrrBs rrz*InitConfigTests.test_preinit_python_config*rrc2|jdty)Ntest_init_python_configrrrBs rrz'InitConfigTests.test_init_python_config-rrc@ddd}|jdi|ty)Nr)rrtest_init_dont_configure_localerr)r9rs  rrz/InitConfigTests.test_init_dont_configure_locale0s0!" 
		
@"i#-		/rzSas of 3.11 this test no longer works because path calculations do not occur on readcHdddd}d}|jd|t|y)Nz./init_read_set
my_executable)rr0rcJ|jdd|jdy)Nrtest_path_insert1test_path_append)insertrn)rs rmodify_pathz7InitConfigTests.test_init_read_set.<locals>.modify_pathAsKK./KK*+rtest_init_read_set)r]r^r)r9rQrs   rrz"InitConfigTests.test_init_read_set9s9.).

	,	
3V#-.9		;rcNdgdgdgdd}|jd|ty)Nr)config_xoptionrsysadd_xoptionr)ignore:::cmdline_warnoptionzignore:::sysadd_warnoptionzignore:::config_warnoption)rrrrr)rrrrtest_init_sys_addrrrs  rrz!InitConfigTests.test_init_sys_addHs3
3
"	
2F
KrcZd}ddgdd|dgd|dzdd}|jd	|t
y)NRimport _testinternalcapi, json; print(json.dumps(_testinternalcapi.get_configs()))rArr	./python3rr
)rrrrrtest_init_run_mainrrr9rrQs   rrz"InitConfigTests.test_init_run_main\sKE6N#T48'$;
	
3VLrc^d}ddgdd|dgd|dzddd	}|jd
|tdy)
NrrArrrrr
r)rrrrrrtest_init_mainz)Run Python code before _Py_InitializeMain)r]rKrrs   rrzInitConfigTests.test_init_mainhs]E6N# "($;	
	
/#-&Q		SrcNdgdgddddd}|jd|t	y)
Nr
)rAarg1-varg3./argv0rrArrrrrrr)rrrrrrtest_init_parse_argvrrrs  rrz$InitConfigTests.test_init_parse_argvys30N%# 

	
5v:NrcTddi}dgdgddd}|jd||ty)Nrrrr)rrrrtest_init_dont_parse_argvrr)r9rTrQs   rrz)InitConfigTests.test_init_dont_parse_argvsB!

IN%	
	
:FJ#-		/rctrd}|j}n.d}tr
|j}ntj|xsd}|j|||dy)Nrrr+)rrr0)r1r3MACOSshutilwhichrw)r9rQrr0s    rdefault_program_namez$InitConfigTests.default_program_namesQ#LJ$L!]]
#\\,7=2


()$
	rc|j}|dd}|dddddd}|j|dtjjj|i}|j
d|t|dy)	NrQrr+)rrrrrrTESTPATHtest_init_setpathTr]r$ru)rRrrrrr2rrVr9rQr`r$s    rrz!InitConfigTests.test_init_setpaths**,x !67$) "	
	
!!&)277??//672F#-3-1		3rc|j}|dd}|dddddtjdddd
}dtjj
j
|i}|jd|t|d	
y)NrQrr+conf_program_nameconf_executable)
rrrrrrrrrr0rtest_init_setpath_configTr)	rRrPy_DEBUGrrrr2rrzrs    rrz(InitConfigTests.test_init_setpath_configs**,x !67$) "&-&6&6"6/0+
 277??//6796#-3d		Lrc
<|j}||dd}||dd}tr|ddStj}tj
j
|tjd|j|jdtj
j
|tjd|jd|jtj
j
|tjd|jd|jdgS)NrQrrrz.ziprlib-dynload)
rRr1r/version_inforrr2rmajorminor)r9rrrQvers     rrz#InitConfigTests.module_search_pathss**,>H%h/F *84K(#$9::""CVS^^%cii[4@BVS^^%cii[#))=?[#..%cii[#))=}N
rc	#Ktj5}tjj	|}|rRtjjtjj
||}tj|trddl	}tjj|j}tj|D]g}|j|dstjtjj
||tjj
||itjj
|tjj|j}tj|j|tj |j|||_|dddy#1swYyxYww)Nrz*.dll)tempfileTemporaryDirectoryrrrealpathnormpathr2makedirsr1fnmatchr.r3listdirrcopyfilercopystat)r9subdirtmpdirrexedirf	exec_copys       rtmpdir_with_pythonz"InitConfigTests.tmpdir_with_pythons<
(
(
*	fWW%%f-F))"'',,vv*FGF#7F+ZAq'2VQ(?fVWAXYZ
VRWW-=-=dmm-LMIOODMM95OODMM95%DML/			s$G$CG)C&G	G$G!G$c	|j}|dd}tjjj	|}|D]}tjj|s#tjj
tjj	|dsatjj|}n|jd|x}}trGtjj	|d}|dtjj	|d|g}	n|tjjdtjj}
tjj	|tjd	|
}|j||
}	||	||||||d}|j!|||d}|j#d
|t$|y)NrQrrUnable to find home in LibrDLLsrrrrrrrrrrrrTESTHOMErtest_init_setpythonhomer]r$)rRrrrr2isdirr4r.rHr1r/rr
rrrrrrV)r9rQr`	paths_strrrrrstdlibexpected_pathsversionr$s            rr(z'InitConfigTests.test_init_setpythonhomes**,x !67GGOO((/		;D77==&ww~~bggll49:wwt,	;
II/y9:##WW\\$.F$AhT6(BFKN))//0#2B2B2H2H1IJGWW\\$&	8JKF!55Tt5TN#1!& +' 	
	
!!&)y98&#-3		8rc	6|j}|dd}tjjj	|}|D]}tjj|s#tjj
tjj	|dsatjj|}n|jd|x}}trGtjj	|d}|dtjj	|d|g}	n|tjjdtjj}
tjj	|tjd	|
}|j||
}	||	||||||d}||d}d
|d<d|d<|j!d|t"|d|d<d|d<tjjtj$}t'tjj	|dd5}
tjj)tjj	||
j+dj-d|	trdnd<dddts?tj.x}}|j|d|	d<|j1|||||j!d|t"|y#1swYhxYw)NrQrrr!r"rr#rrr$r%r&1NEGATIVE_ISPYTHONBUILDrtest_init_is_python_buildr)r|rpybuilddir.txtrrz
$r
)r)rrrr)rRrrrr2r*r4r.rHr1r/rr
rrrrrVr0rrrrbrrw)r9rQr`r+rrrrr,r-r.r$rrs              r#test_init_is_python_build_with_homez3InitConfigTests.test_init_is_python_build_with_home(s**,x !67GGOO((/		;D77==&ww~~bggll49:wwt,	;
II/y9:##WW\\$.F$AhT6(BFKN))//0#2B2B2H2H1IJGWW\\$&	8JKF!55Tt5TN#1!& +' 	
 y9(+$%%&!":F#-3		8),$%%&!"0
"'',,v'786
J	Ha57WW5E5EVz%5%@%@%B1%EF6HN
12	H#&::-F[ $ 8 8 8 G JN1MMV&1K

Q:F#-3		8	H	Hs
=A+LLc|j}|dd}tjjj	|}||d<d|i}|S)NrQrrr)rRrrrr2)r9rQall_configsr`r+r$s      rcopy_paths_by_envz!InitConfigTests.copy_paths_by_envdsR//1H%&;<GGOO((/	#, Y'
rzSee test_init_pybuilddir_win32c	|j5}tjdxsd}d}tjj||}tjj
tjj||d}tj|tjj|d}t|dd5}|j|ddd|j}||d	<||d
<|j}	tjdtjd|	|	||d
}
|j|
}|jd|
t|d|dddy#1swYxYw#1swYyxYw)NVPATHr+libdirr"r3wrrrr)rrrr0rrrTr]r$rurG)r	sysconfigget_config_varrrr2rmkdirrwriterr3r7rrV)r9rvpathrr:	stdlibdirfilenamerrr0rQr$s            rtest_init_pybuilddirz$InitConfigTests.test_init_pybuilddirlsj
$
$
&	C&,,W5;EFWW\\&&1F((feU)KLIHHVww||F,<=Hhf5
! 
!#'":":"<&/#&,#J$-$<$<]$K(77A#-(':'
F((0C""#<f'1s156
#
C9	C	C
!
!	C	Cs%B=E>E2 B	E>2E;	7E>>FzSee test_init_pybuilddirc
tjd}d}tjj	|jtjdk(r tjj|d}|j|5}tjj	tjj||}tjj	tjj||d}tjj|d}t|dd	5}|j|ddd|j}tjj|tjj|d
|d
<||d<||d<|j}	|||	|	||||d
}
|j|
}|jd|
t |d|dddy#1swYxYw#1swYyxYw)Nr9zPCbuild\archr
instrumentedr"r3r;rrr<r=)rrrr0rrrrrFr>)r?r@rrrcountsepr2rrrBrrr3r7rrV)r9rCrrrrDrErrr0rQr$s            rtest_init_pybuilddir_win32z*InitConfigTests.test_init_pybuilddir_win32s((1 
77E"((0A5WW\\&.9F

$
$V
,	DWW%%bggll65&ABF((feU)KLIww||F,<=Hhf5
! 
!#'":":"<&(ggll6277;K;KL_`bLc;d&e#&,#&/#J$*%#-( %':'	F((0C""#<f'1s16F
#
D7	D	D
!
!	D	Ds&B*H2G5B(H5G>	:HH
c
|j5}tj5}tj}t
s`tjj|tjd|jd|jd}t
j|ntjj|d}t
j|tjtjjtj dtjj|dtjj|d}t#|dd	5}t%d
|z|t%d|ddd|j'}t
s|d
<natjj|tjj)|d|tjj|dg}|j*}	tjj|tjj)|	}
|}t-j.d|||
|	|d}t
rK||d<||d<tjj|d|d<t1tj2|d<n,|j4|d<t1tj2|d<|j7|}
|j9d|t:|
d|ddddddy#1swYxYw#1swYxYw#1swYyxYw)Nrrrr"rz
pyvenv.cfgr;rrz	home = %sfilez$include-system-site-packages = falser=rr)rrrrr0rrrrrTr>)rrrr/rr1rrr2rr
rrrrr
STDLIB_DIRrrVrrr3r?r@rr	rWr7rrV)r9rpyvenv_homerlib_dynload
lib_folderrErr`r0rrrQr$s              rtest_init_pyvenv_cfgz$InitConfigTests.test_init_pyvenv_cfgs
$
$
&;	C&

(
(
*;	C.9""C ggll;+.>>-3CII;a		{+K+8:K(WW\\+u=
J'GGLL!3!3W=GGLLW5
ww||FL9Hhf5
GkK/b9<2F
G,,.E'b	GGLL)9)9%()CDGGLLe4J ggll;8H8H8TUO%K(77A$/*#2(',
F(3}%#.x ')ww||K'G|$/2w7G7G3G/H+,(,'9'9|$/2w7G7G3G/H+,((0C""#<f'1s156
#
Cs;	C;	C;	C(
G
G);	C;	C;	C;	Cs<L=D:L1 L$>FL1L=$L.)L11L:	6L==Mzspecific to Windowsc	ddddddtjdfg}|jditd	tjj
j
d
|Di\}}|j|d	tj|}|dd}t||D]\\}}}|j||y#tj$r|jd
|Y[wxYw)N)z	C:/a. . .	C:\a. . .)rVrV)z\\?\C:////a////b. . .z\\?\C:\a\b. . .)z//a/b/c. . .\\a\b\c. . .)rWrWza. . .z\arrc3&K|]	}|dyw)rNrx).0cs  r	<genexpr>z=InitConfigTests.test_getpath_abspath_win32.<locals>.<genexpr>s3HQAaD3Hsrr+rBrQr)
rr6r]r&rrr2rWrErFrGrHzip)r9CASESr[r\resultsrr\results        rtest_getpath_abspath_win32z*InitConfigTests.test_getpath_abspath_win32s
)(@04
"))+c*+

00)J(*Jrww333H%3HHJ1
S
	
b!	9**S/Ch- 56%(%8	/!MQ6VX.	/	##	9II/w78	9sC'C65C6cp
tjd
tjd}
fd}|d}|d}|d}|d}|d}|d	}|jd
}	|j|j	t
jj|	d|j||	d|j||	d
|j||	d|j||	d|j||	dy)Nctypes_testinternalcapicdtj|}d|_j|_|S)Nrx)getattr	pythonapiargtypes	c_wchar_prestype)rfuncrbs  rget_funcz8InitConfigTests.test_global_pathconfig.<locals>.get_func#s.6++T2DDM!++DLKr
Py_GetPathPy_GetPrefixPy_GetExecPrefixPy_GetProgramNamePy_GetProgramFullPathPy_GetPythonHomerQrrrrr0r)r
import_moduleget_configsrWr;rrr)r9rcrkrlrmrnrorprqrQrbs          @rtest_global_pathconfigz&InitConfigTests.test_global_pathconfigs-,,X6)778KL	l+
/#$67$%89 ()@ A#$67"..0:++BGGOO< 56	8)9:)+VM-BC*,f^.DE.0&2FG)+VF^<rcrgd}tt}ddd|gdd}|jd||ty)N)zignore:::PyConfig_Insert0rz
ignore:::env1z
ignore:::env2zignore:::cmdline1zignore:::cmdline2rzignore:::PySys_AddWarnOption1zignore:::PySys_AddWarnOption2zignore:::PyConfig_BeforeReadzignore:::PyConfig_AfterReadrr)rz-Wignore:::cmdline1z-Wignore:::cmdline2)rrrrrtest_init_warnoptionsr)r rrrz)r9rrrQs    rrvz%InitConfigTests.test_init_warnoptions:sM+#89	&1
	
6	#-		/rcBdddgd}|jd|ty)Nrr
zerror::BytesWarning)rrrtest_init_set_configrrrs  rrxz$InitConfigTests.test_init_set_configUs212

	
5v#/		1rc&|jdy)Ntest_get_argc_argvr]rBs rrzz"InitConfigTests.test_get_argc_argv^s%%&:;rc
hd}|D]c\}}d|}ddgdd|ddgddd	|g|d
}|rd|d	dind}|jt|5|jd|t|
dddey#1swYpxYw)N>z=onrz=offrr+rr:rfrozen_modulesr
rArrrrr)rrrrrrrr
TESTFROZENtest_init_use_frozen_modulesr))subTestreprrrz)r9testsrawr\optvalrQr$s       rrz,InitConfigTests.test_init_use_frozen_modulesbs
#	@MC%cU+F'vtVD )'#$#H&.	F.1<QR)dCd3i(
@&&'Ev+53'@
@
@	@
@
@s	A..A7	c4d}d}d}d}d}d}||z|z|z|zdd}|jd	\}}	|j|	d
	tj|}|j||y#tj$r|jd|Y<wxYw)N iiiiT)
feature_flagsown_gil#test_init_main_interpreter_settingsr+rB)r]rWrErFrGrH)
r9OBMALLOC
EXTENSIONSTHREADSDAEMON_THREADSFORKEXECr\r[r\s
          rrz3InitConfigTests.test_init_main_interpreter_settingszs
4$&0>A	
001
S	
b!	9**S/C	
h'##	9II/w78	9sA--'BBrA)NNNN)NN)]rurvrwrr1rXobjectrUrWrVPYMEM_ALLOCATOR_NOT_SETr|rwr rzr{rxryrZr/int_infodefault_max_str_digitsrrr	rr}r~rlrnrmrMr6classmethodr8r?rJrRrardrirsrrrrrrrrrrrrrrrrrrrrrrskiprrrrrrrrrr
contextlibcontextmanagerrr(r4r7skipIfrF
skipUnlessrLrTr`rtrvrxrzrrrxrrrrsG+5;L HM#, !  (!"
	.*$	0!OJ
JAJ	1J	A	J	"1
J	J	QJ	cllAAJ	J	qJ	!J	qJ	QJ	!J 	Q!J"	#J&	1'J(	/)J,	$-J.	*/J0	a1J2	3J4	R5J8	B9J:	r;J>	$?J@	AJB	(CJD	-EJH	$IJJ	)KJL	)MJN	.OJP	1QJR	"1SJT	cnnUJV	(WJZ	q[J\	]J^	 _J`	1aJb	qcJd	aeJf	gJh	!iJj	1kJl	mJn	qoJp	QqJr	!sJv	,wJx+"# ) ")"2"22)SJMV"A
	M
=! !
O23./,-$%01	%(%%'
		!!#
	O##<>"6:=8~/
+=,;?-1)-!%4>B"%T	4lNMJ/.>/@/@/B//
//&1$RQQQNMJ/X]]<=;=;L(
MS"	O/ 3,L2&6'8R:8xX__Z!AB!CC!CFX%?@%DA%DN>C@X%:;/</6$=L/61<@0(rrceZdZdZy)SetConfigTestsctjdtjdddddg}t	j
|tjtjdd	}|jr:tjr*t|jt|j|j|jd
|j|j|jfy)N	_testcapirrrz-mztest._test_embed_set_configrbackslashreplace)rJrKrrr)rrrr/r0rOr~rQrErrUrVrJrKrW)r9rYrIs   rtest_set_configzSetConfigTests.test_set_configs##K0~~tVT49VW~~c%/__%/__'.7IK??w$++$++!//4;;D	FrN)rurvrwrrxrrrrsFrrcBeZdZdZdZdZdZdZdZdZ	dZ
d	Zy
)
AuditingTestsc&|jdy)Ntest_open_code_hookr{rBs rrz!AuditingTests.test_open_code_hooks%%&;<rc&|jdy)N
test_auditr{rBs rrzAuditingTests.test_audits%%l3rc&|jdy)Ntest_audit_subinterpreterr{rBs rrz'AuditingTests.test_audit_subinterpreter%%&ABrcH|jdtjdy)Ntest_audit_run_commandrrDrEr]r
SHORT_TIMEOUTrBs rrz$AuditingTests.test_audit_run_commands$%%&>.5.C.C12	&	4rcH|jdtjdy)Ntest_audit_run_filerrrrBs rrz!AuditingTests.test_audit_run_files$%%&;.5.C.C12	&	4rctjj|jtj
dz}t
|dd5}td|td|ddd	itd|i}|jd	tjd
|tj|y#1swYSxYw#tj|wxYw)N.pyr;rrz
import sysrNz&sys.__interactivehook__ = lambda: None
PYTHONSTARTUPtest_audit_run_interactivehook
rDrEr$
rrr2r7rTESTFNrrVr&r]rrunlinkr9startuprr$s    rrz,AuditingTests.test_audit_run_interactivehooks'',,t{{I,<,<=E
'3
1	DQ,Q':C	D	G*,GowGC))*J292G2G57S
*
B
IIg	D	D
IIgs
B7.3C7CCctjj|jtj
dz}t
|dd5}td|ddd	itd|i}|jdtjd	|
tj|y#1swYSxYw#tj|wxYw)Nrr;rrrrNrtest_audit_run_startuprrrrs    rrz$AuditingTests.test_audit_run_startups'',,t{{I,<,<=E
'3
1	"Q&q!	"	G*,GowGC))*B292G2G57S
*
B
IIg	"	"
IIgs
B*!3B6*B36C
cH|jdtjdy)Ntest_audit_run_stdinrrrrBs rrz"AuditingTests.test_audit_run_stdins$%%&<.5.C.C12	&	4rc&|jdy)Ntest_get_incomplete_framer{rBs rrz'AuditingTests.test_get_incomplete_framerrN)rurvrwrrrrrrrrrrxrrrrs1=4C4
4

4
CrrceZdZdZej
ejdk(ddZeje
jddZy)	MiscTestsc&|jdy)Ntest_unicode_id_initr{rBs rrzMiscTests.test_unicode_id_inits	
%%&<=rrz(Py_FrozenMain is not exported on Windowscttj}d|d<|jd|\}}tjjd}t
jd|dj}|j||y)Nr0PYTHONUNBUFFEREDtest_frozenmainrrz
            Frozen Hello World
            sys.argv ['./argv0', '-E', 'arg1', 'arg2']
            config program_name: ./argv0
            config executable: z|
            config use_environment: 1
            config configure_c_stdio: 1
            config buffered_stdio: 0
        )
r rr!r]rrrrlstriprW)r9r$r[r\r0r\s      rrzMiscTests.test_frozenmains2::"%001B0LSWW%%i0
??( !+|,		$
VX		
h'rz--X showrefcount requires a Python debug buildc	d}|D]0\}}d|}tjdddd|d|g}tj|tjtj
d}|j
|jd	|jj}tjd
|}|s|jd|t|jd}	t|jd
}
|j||5|j
|	d	||j
|
d	|ddd3y#1swY?xYw)N))offr)onr)rimport __hello__)rrzfrozen_modules=rrshowrefcountrAT)rJrKtextrz!^\[(-?\d+) refs, (-?\d+) blocks\]zunexpected output: rr
)rstmt)r/r0rOr~rQSTDOUTrWrErJrrfrgrHrgroupr)r9rflagrxoptrYrIr[rgrefsblockss           rtest_no_memleakzMiscTests.test_no_memleaks*
 	1JD$$TF+D>>4~tT4QUVC>>#)3)3):):'+-D
T__a0++$$&CHHA3GE		/w78u{{1~&DQ(FT=
1  q#.  C0
1
1	1
1
1s'D::E	N)
rurvrwrrrrrrrrr	rrxrrrrsc>X__RWW_?A(A( X))HJ1J1rrc(eZdZdZdZdZdZdZy)StdPrinterTestsrctjd}|jj}|jf|_|j|_||S)Nrb)rrrrfPyFile_NewStdPrinterc_intrg	py_objectri)r9fdrbrs    rcreate_printerzStdPrinterTests.create_printersM,,X6%//DD)/%'-'7'7$#B''rc|d}|j}tj|}|jtj|tj
\}}|jtj||jtj|	tj|||j|}|j|tj||tj|d}|j||jddy#tj||wxYw)Nuunicode:é-€-!
drr)	STDOUT_FDrdup
addCleanupclosepipedup2rrBrrWencode)r9message	stdout_fdstdout_fd_copyrfdwfdprinterdatas        r
test_writezStdPrinterTests.test_writes1NN		*.1779S#&#&	/
GGC#)))4GMM'"GGNI.wwsC w~~f6HIJ
GGNI.s8D##D;c$|j}|j|}|j|j||j|j	tj||j
|jyrA)rrrWfilenoisattyrflushrr9rrs   rtest_methodszStdPrinterTests.test_methods4sc
^^%%b))2.)299R=9



rc||j}|j|}tj|t	|yrA)rrrcheck_disallow_instantiationtypers   rtest_disallow_instantiationz+StdPrinterTests.test_disallow_instantiation<s/
^^%%b),,T4=ArN)rurvrwrrrrrrxrrrrs
I(K.Brr__main__)7testrtest.supportrrrrcollectionsrrrEros.pathrfrrOr/r?rrhas_subprocess_supportrrr1platformrrrrrVrzrxr
MAX_HASH_SEEDrr2rrrr
rSTDLIB_INSTALLisfilerr&r(TestCaserzrrrrrrursrxrr<module>r
s&"0"		

%%
(

=
>>ggo
		!





cjj#..S


#
#$Ac&6&6&<&<%=>@	ww~~bggll>7;<N5j!j!Z]2((*;*;]2~E()8+<+<E(P(
FX&&
F 3C'):):3Cl31#X%6%631l0B)8+<+<0BfzHMMOr