+
    Bi                       ^ RI t ^ RIt^ RIt^ RIt^ RIt^ RIHt ^ RIH	t	H
t
HtHtHt ^ RIt^ RIt^ RIt^ RIt^ RIt^ RIt^ RIt^ RIt^ RIt^ RIt^ RIt^ RIt^ RIt^ RIHt ^ RIt^ RIHt ^ RIHtH t H!t!H"t"H#t#H$t$H%t%H&t&H't'H(t(H)t)H*t*H+t+H,t, ^ RI-H.t.H/t/H0t0H1t1H2t2H3t3H4t4H5t5 ^ RI6H7t7H8t8H9t9H:t: ^ R	IH;t; ^ R
IH<t< ^ RI=H>t> ^ RIH?t?  ^ RI@t@ ^ RIBtB ^ RICtC ^ RIEtE]P                  ! ]P                  R4      tHR tIRR/R ltJRR/R ltKRR/R ltLRR/R ltMR tNRR/R ltOR tP]@e   R]@/R ltQR tRR tS ! R R]P                  4      tU], ! R  R!]P                  4      4       tW]H ! R" R#]P                  4      4       tX ! R$ R%]P                  4      tY ! R& R']P                  4      tZ ! R( R)]P                  4      t[ ! R* R+]P                  4      t\ ! R, R-]P                  4      t] ! R. R/]P                  4      t^]" ! R0 R1]P                  4      4       t_]" ! R2 R3]P                  4      4       t` ! R4 R5]P                  4      ta ! R6 R7]P                  4      tb ! R8 R9]P                  4      tc ! R: R;]U4      td]R ! R< R=]P                  4      4       te]" ! R> R?]P                  4      4       tf]gR@8X  d   ]P                  ! 4        R# R#   ]A d    Rt@ EL
i ; i  ]A d    RtB ELi ; i  ]D d    RtC EL i ; i  ]A d    RtE EL+i ; i)A    N)_get_sourcefile)AppleFrameworkLoaderBuiltinImporterExtensionFileLoaderFrozenImporterSourceFileLoader)mock)	os_helper)
STDLIB_DIR	swap_attr	swap_itemcpython_onlyis_apple_mobileis_emscripten	is_wasm32run_in_subinterprun_in_subinterp_with_configPy_TRACE_REFSrequires_gil_enabledPy_GIL_DISABLEDno_rerunforce_not_colorized_test_class)forgetmake_legacy_pycunlinkunloadready_to_importDirsOnSysPathCleanImportimport_module)TESTFNrmtree
temp_umaskTESTFN_UNENCODABLE)script_helper)threading_helper)uncache)
ModuleTypez*test meaningful only when writing bytecodec           
         \        V \        4      '       d   \        V 4      p \        R \        R\
        R\        R\        R/pTpW4,          pV P                  P                  p\        V\        4      '       g   \        V4      pW5,          pWT8w  d<   RV RV P                   2pV'       d   \        P                  ! V4      h\        V4      hV # )zbuilt-in	extensionzframework extensionfrozenzpure Pythonzexpected module to be z, got )
isinstancestr
__import__r   r   r   r   r   __spec__loadertypeunittestSkipTest	Exception)moduler0   skipMODULE_KINDSexpectedactualerrs   &&&    0/usr/lib/python3.14/test/test_import/__init__.py_require_loaderr<   O   s    &#F# 	[3-L H%H__##Ffd##f!F&xjv6GH##C((nM    r6   Fc                (    \        V \        V4      p R # N)r<   r   r5   r6   s   &$r;   require_builtinrA   k   s    V_d;Fr=   c                f    \         '       d   \        V \        V4       R # \        V \        V4       R # r?   )r   r<   r   r   r@   s   &$r;   require_extensionrC   o   s#      4d; 3T:r=   Tc                (    \        V \        V4      p R # r?   )r<   r   r@   s   &$r;   require_frozenrE   w   s    V^T:Fr=   c                (    \        V \        V4       R # r?   )r<   r   r@   s   &$r;   require_pure_pythonrG   {   s    F,d3r=   c                 F    \         '       d   \        W4      # \        W4      # r?   )r   r   r   )modnamefilenames   &&r;   create_extension_loaderrK   ~   s     #G66"755r=   put_in_sys_modulesc                    \        W4      p\        P                  P                  W4      p\        P                  P	                  V4      pVP                  V4       V'       d   V\        P                  V &   V# r?   )rK   	importlibutilspec_from_loadermodule_from_specexec_modulesysmodules)rI   rJ   rL   r0   specr5   s   &&$   r;   import_extension_from_filerV      sX    $W7F>>**7;D^^,,T2F
v%GMr=   c                     V R ,           V R,           V R,           V R,           3 F  p\        V4       K  	  \        R4       R# ).py.pyc.pywz	$py.class__pycache__N)r   r"   )namefs   & r;   remove_filesr^      s>    UlVmVm[ " 	q		"
 =r=   _origc                     \         P                  P                  R R4       V P                  4        V P                  P
                  p\        P                  ! R V4       ^ RIpR# )_testsinglephaseN)	rS   rT   pop_clear_globalsr/   origin_testinternalcapiclear_extensionra   )r_   rd   ra   s   $  r;   restore__testsinglephaserg      sF     	*D1&&))*<fEr=   c                    \        V \        4      '       g   V 3R lp \        V 4      p Rp\        V4      ! V 4      p \        P
                  ! \        RJ R4      ! V 4      # )zADecorator to skip if single-phase init modules are not supported.c                 F     V! V 4      \        4        #   \        4        i ; ir?   )rg   )self_meths   &&r;   meth'requires_singlephase_init.<locals>.meth   s    +T{(*(*s     zggh-117694: free-threaded build does not currently support single-phase init modules in sub-interpretersN%test requires _testsinglephase module)r,   r1   r   r   r2   skipIfra   )rl   msgs   & r;   requires_singlephase_initrq      s^    dD!!! 	+
 D
sC$T*D??+t3BDDHJ Jr=   c                H    \         P                  ! \        RJ R4      ! V 4      # )z>Decorator to skip a test if subinterpreters are not supported.Nzsubinterpreters required)r2   ro   _interpreters)rl   s   &r;   requires_subinterpretersrt      s%    ??=D0577;= =r=   c            	         a  ] tR t^t o Rt]! RP                  4       4      t]R 4       t	]
P                  ! R4      t]
P                  ! R4      P                  4       t]
P                  ! R4      P                  4       t]
P                  ! R4      P                  4       t]RR	R
RRR	RR/R l4       t]R 4       t]RRR	/R ll4       t]R 4       tRtV tR	# )ModuleSnapshota  A representation of a module for testing.

Fields:

* id - the module's object ID
* module - the actual module or an adequate substitute
   * __file__
   * __spec__
      * name
      * origin
* ns - a copy (dict) of the module's __dict__ (or None)
* ns_id - the object ID of the module's __dict__
* cached - the sys.modules[mod.__spec__.name] entry (or None)
* cached_id - the object ID of the sys.modules entry (or None)

In cases where the value is not available (e.g. due to serialization),
the value will be None.
z#id module ns ns_id cached cached_idc           
        VP                   P                  p\        P                  P	                  V4      pV ! \        V4      V\        P                  ! R/ VP                  B \        VP                  4      V\        V4      R 7      # ))idr5   nsns_idcached	cached_id )	r/   r\   rS   rT   getrx   typesSimpleNamespace__dict__)clsmodr\   r{   s   &&  r;   from_moduleModuleSnapshot.from_module   se    ||  &#w$$4s||4S\\"j
 	
r=   z
        {imports}

        name = {name!r}

        {prescript}

        mod = {name}

        {body}

        {postscript}
        z
        import sys
        a  
        # Capture the snapshot data.
        cached = sys.modules.get(name)
        snapshot = dict(
            id=id(mod),
            module=dict(
                __file__=mod.__file__,
                __spec__=dict(
                    name=mod.__spec__.name,
                    origin=mod.__spec__.origin,
                ),
            ),
            ns=None,
            ns_id=id(mod.__dict__),
            cached=None,
            cached_id=id(cached) if cached else None,
        )
        zL
        # Clean up the module.
        sys.modules.pop(name, None)
        	prescriptNimport_firstF
postscriptpostcleanupc               &   VR J d   V P                   pMe\        V\        4      '       dN   \        P                  ! V4      P                  4       pV P                   \        P                  ,           V,           pMRpV'       d%   \        P                  ! V4      P                  4       MRpV'       d%   \        P                  ! V4      P                  4       MRpV'       d1   V'       d'   V\        P                  ^,          ,           V,           pMTpV'       d!   V\        P                  ! RV 24      ,          pV P                  P                  V P                  P                  4       VVP                  4       V P                  P                  4       VR7      # )T zq

                # Now import the module.
                assert name not in sys.modules
                import )importsr\   r   bodyr   )CLEANUP_SCRIPTr,   r-   textwrapdedentstriposlinesepSCRIPTformatIMPORTSSCRIPT_BODY)r   r\   r   r   r   r   s   &&$$$$r;   build_scriptModuleSnapshot.build_script  s(    $,,KS))"//+6<<>K,,rzz9KGKK:CHOOI.446	<FX__Z0668B
'"**q.8;F
(
 . v	*! " "I zz  KK%%'oo'&&(! ! 
 	
r=   c                    \         P                  ! V4      pVR ,          p\        P                  ! R/ VR,          B VR&   \        P                  ! R/ VB VR &   V ! R/ VB # )r5   r/   r}   )jsonloadsr   r   )r   textrawr   s   &&  r;   parseModuleSnapshot.parse(  sW    jj(m//B#j/BJ--44HzSzr=   pipec               H   Ve   V P                  WW44      # \        P                  ! 4       p V P                  WW44      Vw  rV\        P                  ! V4       \        P                  ! V4       #   Tw  rV\        P                  ! T4       \        P                  ! T4       i ; ir?   )_from_subinterpr   r   close)r   r\   interpidr   script_kwdsrws   &&&$,  r;   from_subinterpModuleSnapshot.from_subinterp0  sy    &&ttIIwwy	&&ttIDAHHQKHHQK DAHHQKHHQKs   A/ /2B!c                   Vw  rV\         P                  ! R V R24      pVP                  R4      pV'       d-   \         P                  ! V4      P                  4       pWx,          pVP	                  4       VR&   V P
                  ! V3/ VB p	Vf"   \        V	4      p
V
^ 8w  d   \        V
 R24      hM\        P                  ! W)4       \        P                  ! VR4      pV P                  VP                  4       4      # )zq
            # Send the result over the pipe.
            import json
            import os
            os.write(z., json.dumps(snapshot).encode())

            r   z != 0  )r   r   r~   lstripr   r   r   AssertionErrorrs   
run_stringr   readr   decode)r   r\   r   r   script_kwargsr   r   r   _postscriptscriptretr   s   &&&&&       r;   r   ModuleSnapshot._from_subinterp<  s     __ * S 	& 
 $''5"//+6==?K%J&0&6&6&8l#!!$8-8 "6*Cax$uE]33  $$X6 wwq$yy''r=   r}   r?   )__name__
__module____qualname____firstlineno____doc__tuplesplit_fieldsclassmethodr   r   r   r   r   r   r   r   r   r   r   r   __static_attributes____classdictcell____classdict__s   @r;   rv   rv      s$    $ 9??ABG

 

 __  F oo  UW  // # " UW# $ __ &  UW 
 #
##
"'#
 !%#
 "'	#
 #
J   	 	 	 ( (r=   rv   c                   F  a  ] tR tRt o R tR tR tR tR tR t	]
R 4       tR	 tR
 tR tR tR tR tR2R ltR tR tR tR t]R 4       tR tR t]R 4       tR t]
R 4       tR tR tR t ]
R 4       t!]"PF                  ! 4       R 4       t$]%PL                  ! ]'PP                  R8H  R 4      R! 4       t)R" t*R# t+R$ t,R% t-R& t.R' t/R( t0R) t1]%Pd                  ! ]'PP                  R8H  R*4      ]%Pd                  ! ]'PP                  R+8H  R,4      R- 4       4       t3R. t4R/ t5R0t6V t7R1# )3ImportTestsi\  c                N    \        \        4       \        P                  ! 4        R # r?   )r^   r!   rN   invalidate_cachesrj   s   &r;   setUpImportTests.setUp_  s    V##%r=   c                $    \        \        4       R # r?   )r   r!   r   s   &r;   tearDownImportTests.tearDownc  s	    vr=   c                    V P                  \        4      ;_uu_ 4        ^ RIpRRR4       R#   + '       g   i     R# ; ir   N)assertRaisesModuleNotFoundError(something_that_should_not_exist_anywhererj   r   s   & r;   &test_import_raises_ModuleNotFoundError2ImportTests.test_import_raises_ModuleNotFoundErrorf  s&    233; 4333   ->	c                    V P                  \        4      ;_uu_ 4        ^ RIHp RRR4       R#   + '       g   i     R# ; i)r   )blahN)r   r   r   r   )rj   r   s   & r;   :test_from_import_missing_module_raises_ModuleNotFoundErrorFImportTests.test_from_import_missing_module_raises_ModuleNotFoundErrorj  s&    233E 4333	   /A 	c                    V P                  \        4      ;_uu_ 4        ^ RIHp RRR4       R#   + '       g   i     R# ; i)r   )r   N)r   ImportErrorrN   r   r   s   & r;   0test_from_import_missing_attr_raises_ImportError<ImportTests.test_from_import_missing_attr_raises_ImportErrorn  s%    {++J ,+++r   c           	        \        R 4      ;_uu_ 4        ^ RIpV P                  \        4      ;_uu_ 4       p^ RIHp RRR4       RRR4       V P                  XP                  P                  R 4       V P                  VP                  P                  XP                  4       V P                  \        VP                  4      R4       R#   + '       g   i     L; i  + '       g   i     L; i)r   Ni_dont_existz7cannot import name 'i_dont_exist' from 'os' \(.*os.py\))r   r   r   r   r   assertEqual	exceptionr\   path__file__assertRegexr-   )rj   r   cmr   s   &   r;   /test_from_import_missing_attr_has_name_and_path;ImportTests.test_from_import_missing_attr_has_name_and_pathr  s    "";//2+ 0  	**D1**BKK8R\\*,fg	 0/ s!   "CC
	C
CCC-	c                   \        R 4      pV P                  \        4      ;_uu_ 4       p^ RIHp RRR4       V P                  XP                  P                  R 4       \        VR4      '       db   V P                  VP                  P                  VP                  P                  4       V P                  \        VP                  4      R4       R# V P                  \        VP                  4      R4       R#   + '       g   i     L; i)	_testcapir   Nr   zFcannot import name 'i_dont_exist' from '_testcapi' \(.*(\.(so|pyd))?\)zEcannot import name 'i_dont_exist' from '_testcapi' (unknown location))r    r   r   r   r   r   r   r\   hasattrr   r/   rd   r   r-   )rj   r   r   r   s   &   r;   2test_from_import_missing_attr_has_name_and_so_path>ImportTests.test_from_import_missing_attr_has_name_and_so_path{  s    !+.	{++r. ,**K89j))
 R\\..	0B0B0I0IJBLL!Y
 BLL!W ,+s   C88D	c                   V P                  \        4      ;_uu_ 4       p^ RIHp RRR4       V P	                  XP
                  P                  R4       V P                  VP
                  P                  4       R#   + '       g   i     L]; i)r   r   N_warning)	r   r   r   r   r   r   r\   assertIsNoner   rj   r   r   s   &  r;   &test_from_import_missing_attr_has_name2ImportTests.test_from_import_missing_attr_has_name  sZ    {++r- , 	**J7",,++,	 ,+s   A::B
	c                
   V P                  \        4      ;_uu_ 4       p^ RIHp RRR4       V P	                  XP
                  P                  RR04       V P                  VP
                  4       R#   + '       g   i     LU; i)r   r   N	posixpathntpath)r   r   os.pathr   assertInr   r\   assertIsNotNoner   s   &  r;   /test_from_import_missing_attr_path_is_canonical;ImportTests.test_from_import_missing_attr_path_is_canonical  sU    {++r, ,bll''+x)@AR\\* ,+s   A22B	c           	        ^ RI p\        4       ;_uu_ 4       w  r#\        VRRR7      ;_uu_ 4       pVP                  R4       RRR4       / pV P	                  \
        VP                  V4       R24      ;_uu_ 4        \        RV R2V4       RRR4       V P                  R	V4       RRR4       \        4       ;_uu_ 4       w  r#\        VRRR7      ;_uu_ 4       pVP                  R
4       RRR4       / pV P	                  \
        VP                  V4       R24      ;_uu_ 4        \        RV R2V4       RRR4       V P                  R	V4       RRR4       R#   + '       g   i     EL"; i  + '       g   i     L; i  + '       g   i     L; i  + '       g   i     L; i  + '       g   i     Ly; i  + '       g   i     R# ; i)r   Nr   utf-8encodingz__all__ = [b'invalid_type']z\.__all__ must be strzfrom z	 import *s   invalid_typez%globals()[b'invalid_type'] = object()z\.__dict__ must be str)	rer   openwriteassertRaisesRegex	TypeErrorescapeexecassertNotIn)rj   r  r\   r   r]   globalss   &     r;   "test_from_import_star_invalid_type.ImportTests.test_from_import_star_invalid_type  sh   ,4dC'22a56 3G''biio..DE  uTF),g6 _g6  ,4dC'22a?@ 3G''biio..EF  uTF),g6 _g6  322 	  32 	 sv   FE	:F<E/	FF;F	,:F;&F(	7F;E,&	F/E?:FF	F% F;(F83F;;G	c                    V P                  \        4      ;_uu_ 4        ^ RIpRRR4       R#   + '       g   i     R# ; ir   )r   r   RAnDoM)rj   r  s   & r;   test_case_sensitivity!ImportTests.test_case_sensitivity  s'     {++ ,+++r   c                4    ^ RI Hp \        R4       ^ RI Hp R# )r   )double_constz"test.test_import.data.double_constN)test.test_import.datar  r   )rj   r  s   & r;   test_double_constImportTests.test_double_const  s     	7346r=   c                <  a  V 3R  lp\         P                  P                  ^ \        P                  4        V! R4       \         P
                  P                  R4      '       d   R F  pV! V4       K  	  \         P                  ^  R#   \         P                  ^  i ; i)c           	        < \         V ,           p\         R ,           p\        VRRR7      ;_uu_ 4       p\        RV RVR7       \        P                  ! R4      p\        P                  ! R4      p\        RWCR7       \        R	WSR7       R
R
R
4       \         \
        P                  9   d   \
        P                  \          \        P                  ! 4          \        \         4      pSP                  XP                  XRV,          4       SP                  VP                  XRV,          4       \        \         4       \!        V4       \!        V4       R
#   + '       g   i     L; i  \         d$   pSP                  RT : RT: 24        R
p?LR
p?ii ; i  \        \         4       \!        T4       \!        T4       i ; i)rY   r   r   r   z)# This tests Python's ability to import azfile.filer   za =zb =Nzimport from z	 failed: z'module loaded (%s) but contents invalid)r!   r  printrandom	randrangerS   rT   rN   r   r.   r   failr   abr   r   )	extsourcepycr]   r  r  r   r:   rj   s	   &       r;   test_with_extension4ImportTests.test_import.<locals>.test_with_extension  sK   c\F6/CfcG44A7,$$T*$$T*eQ'eQ' 5 $KK''')H$V,C   =CE  =CE vvs1 54 # HIIS#FGGH vvss=   AEE& $AF E#	&F1F
F FF 'F>rX   winN)z.PYz.Pyz.pYrZ   z.PYWz.pYw)rS   r   insertr   curdirplatform
startswith)rj   r#  r   s   f  r;   test_importImportTests.test_import  sn    	> 	299%	&||&&u--HC', I s   ,B $B Bc                   VR ,           p\        VRRR7      ;_uu_ 4       pVP                  R4       \        R4       F  pVP                  R4       K  	  VP                  R4       RRR4        \        P                  ! V4       \        V4       \        P                  P                  R	4       \        P                  ! 4        / p \        V4       \        R
V,           RV4       \        P                  R \        VR,           4       \        VR,           4       VP                  4         \        P                  V R#   + '       g   i     L; i  \        T4       i ; i  \         d     R# i ; i  \        P                  R \        TR,           4       \        TR,           4       TP                  4         \        P                  T i   \         d     i i ; i; i)rX   r   r   r   zd = [
i  z"",
]Nr   zimport co)r  r  range
py_compilecompiler   rS   r   appendrN   r   r   r  clearrT   KeyError)rj   r5   rJ   r]   i	namespaces   &&    r;   test_module_with_large_stack(ImportTests.test_module_with_large_stack  so   E> (C'22aGGI5\  "GGCL	 3	 x(8 	##%		H%V#T95 8c>"8c>" OOKK'? 32 8*   8c>"8c>" OOKK' s[   AD?/E E4 ,E" ?E	E"E10E14AG;GGGGGGc                   \         R ,           p\        VRRR7      ;_uu_ 4       p\        RVR7       RRR4       \        P                  P                  ^ \        P                  4       \        P                  ! 4        \         \        P                  9   d   \        P                  \           R FN  pV P                  \        \        \         4       V P                  \         \        P                  RV,          4       KP  	  \        P                  ^  \        \         4       R#   + '       g   i     L; i  \        P                  ^  \        \         4       i ; i)	rX   r   r   r   za = 1/0r  Nz'damaged module in sys.modules on %i try)         )r!   r  r  rS   r   r&  r   r'  rN   r   rT   r   ZeroDivisionErrorr.   r	  r^   )rj   r!  r]   r7  s   &   r;   test_failing_import_sticks&ImportTests.test_failing_import_sticks  s    %&#00A)!$ 1
 	299%##%S[[ F#	!!!"3ZH  !JQ!NP 
  ! 10  s   D",AD5 "D2	5"Ec                    ^ RI p^ RIpV P                  WVP                  4       V P	                  VP
                  R4       ^ RIHp V P                  W2P
                  VP                  4       R# )r   Nr   )testtest.supportassertIsr   assertHasAttrsupport)rj   xrC  ys   &   r;   test_import_name_binding$ImportTests.test_import_name_binding&  sI    aqzz*4<<4 	!aqzz2r=   c                     R p^ RI Hu Hp ^ pV^
8  d   ^ RI Hu Hp V^,          pK  \        ^4       F  p^ RI Hu Hp K  	  R#   ^ RI Hu Hp i ; i).N)test.support.script_helperrG  r%   r1  )rj   rH  r7  s   &  r;   test_issue31286ImportTests.test_issue312861  sO    	3A22 "f22FA qA22  32s   A Ac                   \         \        P                  ,           R ,           p\        VRRR7      ;_uu_ 4       pVP	                  R4       RRR4       \
        P                  P                  ^ \        P                  4        \        \         4      pV P                  \         \
        P                  4       V P                  VP                  ^R4       V P                  VP                  ^R4       \        \         4       \        VRRR7      ;_uu_ 4       pVP	                  R4       RRR4       V P!                  \"        \$        P&                  V4       \
        P                  P)                  \         4      pV P+                  VR4       V P                  VP                  ^
R4       V P                  VP                  ^R4       \
        P                  ^  \        \         4       \-        \         4       R#   + '       g   i     EL; i  + '       g   i     L; i  \
        P                  ^  \        \         4       \-        \         4       i ; i)	pyr   r   r   z
a = 1
b=2
Nz!module has wrong attribute valuesza = 10
b=20//0
z$expected module to be in sys.modules)r!   r   extsepr  r  rS   r   r&  r'  r.   r   rT   r   r  r  r^   r   r?  rN   reloadr~   r   r   )rj   r!  r]   r   s   &   r;   test_failing_reloadImportTests.test_failing_reloadB  s   "))#d*&#00AGGN# 1 	299%	V$CMM&#++.SUUA'JKSUUA'JK   fcG44+, 5 /1A1A3G++//&)C  &LM SUUB(KLSUUA'JK  6NC 100" 54  6Ns1   G3BH H&BH 3H	H	H 1Ic                   \         R ,           p\        VRRR7      ;_uu_ 4       pVP                  R4       RRR4       \        P                  P                  ^ \        P                  4        \        \         4      pV P                  VP                  R 4       \        P                  ! V4       \        P                  \          \        V4       \        P                  ! 4        \        \         4      p\        P                  P!                  VP                  4      w  rEV P#                  VR4       \        P                  ^  \%        \         4       \         \        P                  9   d   \        P                  \          R# R#   + '       g   i     ELT; i  \        P                  ^  \%        \         4       \         \        P                  9   d   \        P                  \          i i ; i)rX   r   r   r   ztest = None
NrY   )r!   r  r  rS   r   r&  r   r'  r.   assertEndsWithr   removerT   r   rN   r   splitextr   r^   )rj   r!  r]   r   baser   s   &     r;   test_file_to_sourceImportTests.test_file_to_sourceh  s9    %&#00AGGO$ 1 	299%	(V$Ce4IIfF#F#'')V$C((6IDS&) $KK' %# 100  $KK' %s   F-CF F	AG&c                   \         P                  P                  \        4      p\        P
                  ! 4       p VP                  V4       V P                  \        4      ;_uu_ 4       p\        V4       RRR4       R#   \         d$    T P                  R P                  T4      4        L`i ; i  + '       g   i     R# ; i)zpath is not encodable to {}N)r   r   abspathr!   rS   getfilesystemencodingencodeUnicodeEncodeErrorskipTestr   r   r   r.   )rj   r   r  r.  s   &   r;   test_import_by_filename#ImportTests.test_import_by_filename  s    wwv&,,.	JKK! {++qt ,+ " 	JMM7>>xHI	J+++s   A> (B/>+B,+B,/C 	c                    \         P                  ! R \        \        P                  ! R4      4      p\         P
                  ! V4       R# )r   z            import sys
            class C:
               def __del__(self):
                  import importlib
            sys.argv.insert(0, C())
            N)r%   make_scriptr!   r   r   assert_python_ok)rj   testfns   & r;   !test_import_in_del_does_not_crash-ImportTests.test_import_in_del_does_not_crash  s7    **2vx H 8  	&&v.r=   c                4   \         P                  P                  ^ \        P                  4        \
        R,           p\        P                  P                  V4      p\        VRRR7      ;_uu_ 4       p RRR4        \        P                  ! VR
4       \#        \
        4       \        P$                  ! V4       \         P                  ^  \'        \
        4       R#   + '       g   i     Lo; i  \         d    T P                  R4        Lx\         d]   pTP                  \        \        RR4      \        \        RR4      39  d   h T P                  R	P!                  T4      4        Rp?LRp?ii ; i  \         P                  ^  \'        \
        4       i ; i)r   rX   r   r   r   Nz-cannot set modification time to large integer	EOVERFLOWEINVALz2cannot set modification time to large integer ({}))    rn  )rS   r   r&  r   r'  r!   rN   rO   cache_from_sourcer  utimeOverflowErrorrb  OSErrorerrnogetattrr   r.   statr^   )rj   r!  compiledr]   es   &    r;   test_timestamp_overflow#ImportTests.test_timestamp_overflow  s$    	299%	!e^F ~~77?HfcG44 5^!;< vGGH ! 54 ! OMN ^7775+t#D#*5(D#A#C CRYYZ[\]]	^  sa   AE5 2C4E5 =C. %E5 C+	&E5 .E2
E5 E2E2AE-(E5 -E22E5 5"Fc                j     \        R R.R7       R#   \         d    T P                  R4        R# i ; i)httpr   )fromlistzfromlist must allow bogus namesN)r.   r   r  r   s   &r;   test_bogus_fromlistImportTests.test_bogus_fromlist  s/    	9v1 	9II78	9s    22c                ~    R R.p\         P                  ! V!  pVP                  4       w  r4V P                  RV4       R# )-cz&del __builtins__.__import__; import oss   ImportErrorN)r%   spawn_pythoncommunicater   )rj   argspopenstdoutstderrs   &    r;   test_delete_builtins_import'ImportTests.test_delete_builtins_import  s;    >?**D1**,nf-r=   c                    V P                  \        R 4      ;_uu_ 4        ^ RIHp RRR4       R#   + '       g   i     R# ; i)z^No module named 'bogus')fooN)r  r   bogusr  )rj   r  s   & r;   /test_from_import_message_for_nonexistent_module;ImportTests.test_from_import_message_for_nonexistent_module  s)    ##K1KLL! MLLL	   0A	c                    V P                  \        R 4      ;_uu_ 4        ^ RIHp RRR4       R#   + '       g   i     R# ; i)z^cannot import name 'bogus')r  N)r  r   r  r  )rj   r  s   & r;   ,test_from_import_message_for_existing_module8ImportTests.test_from_import_message_for_existing_module  s)    ##K1NOO  POOOr  c                B    ! R  R4      pRpV P                  \        V4       V! 4       \        P                  V&   V P	                  \
        4      ;_uu_ 4       p^ RIHp RRR4       V P                  \        XP                  4      R4       R#   + '       g   i     L7; i)c                   &   a  ] tR tRt o R tRtV tR# )IImportTests.test_from_import_AttributeError.<locals>.AlwaysAttributeErrori  c                    \         hr?   )AttributeError)rj   _s   &&r;   __getattr__UImportTests.test_from_import_AttributeError.<locals>.AlwaysAttributeError.__getattr__  s    $$r=   r}   N)r   r   r   r   r  r   r   r   s   @r;   AlwaysAttributeErrorr    s     % %r=   r  test_from_import_AttributeErrordoes_not_existNzScannot import name 'does_not_exist' from '<unknown module name>' (unknown location))
addCleanupr   rS   rT   r   r   r  r  r   r-   r   )rj   r  module_namer   r  s   &    r;   r  +ImportTests.test_from_import_AttributeError  su    	% 	% 8,#7#9K {++rF , 	R\\*a	c ,+s   BB	c           	        \        \        R R4      ;_uu_ 4        V P                  \        4      ;_uu_ 4        ^ RIHp RRR4       V P                  \
        4      ;_uu_ 4        \        P                   RRR4       RRR4       R#   + '       g   i     LP; i  + '       g   i     L-; i  + '       g   i     R# ; i)r   Nr  )r   r   r   r   r  r  )rj   r  s   & r;   test_issue31492ImportTests.test_issue31492  sq    
 r:t,,"";//- 0 "">22!! 3	 -,// 32	 -,,s9   B-B	%B-$B	5B-BB-B*%B--B>	c                  aaa R  o\         P                  P                  ^ \        P                  P	                  \        P                  P                  \        4      R4      4        RoVVV3R lp\        ^
4       F  p\        P                  ! 4       o\        ^4       Uu. uF  p\        P                  ! VR7      NK  	  pp \        P                  ! VSP                  4      ;_uu_ 4        \        P                  ! ^ 4       RRR4       \         P                   P#                  RR4       \         P                   P#                  RR4       Sf   K  Sh	  \         P                  ^  R# u upi   + '       g   i     Lr; i  \         P                   P#                  RR4       \         P                   P#                  RR4       i ; i  \         P                  ^  i ; i)c                 ~    VR 8X  d6   V P                   P                  R8X  d   \        P                  ! R4       R# R# R# )callhas_deadlockg?N)f_codeco_nametimesleep)frameeventargs   &&&r;   delay_has_deadlock8ImportTests.test_concurrency.<locals>.delay_has_deadlock  s-    5<<#7#7>#I

3 $Jr=   dataNc                     < \         P                  ! S4       SP                  4         ^ RIp \         P                  ! R4       R#   \         d   pTo Rp?L*Rp?ii ; ir   )rS   settracewaitpackageBaseException)r  rw  r  r  excs     r;   run)ImportTests.test_concurrency.<locals>.run  sF    /0

" T" % Cs   A AAA)targetr  zpackage.submodule)rS   r   r&  r   joindirnamer   r1  	threadingEventThreadr&   start_threadssetr  r  rT   rb   )rj   r  r7  rH  threadsr  r  r  s   &    @@@r;   test_concurrencyImportTests.test_concurrency  s4   	  	277<<(A6JK	C# 2Y!)AFqJA9++37J?)77KK

1 L KKOOIt4KKOO$7>?I   KKK KKOOIt4KKOO$7> sV   ':G ! E)G )F-E.FAG G )G .E>9FAGG Gwin32Windows-specificc                   ^ RI Hp V! \        P                  4      p\        P
                  P                  R4      P                  p\        P                  P                  \        P                  P                  V4      RP                  RV9   d   RMR4      4      p\        P                  ! 4       ;_uu_ 4       p\        P                  P                  VR4      p\        P                  ! V4       \        P                  P                  V\        P                  P!                  \        P"                  4      4      p\$        P&                  ! \        P"                  V4       \$        P&                  ! W%4       \(        P(                  ! \        P                  P                  \(        P*                  ! \        P,                  4      R4      4       F  p\$        P&                  ! W4       K  	  \$        P&                  ! W64       Rp	\        P.                   U
u/ uF(  qP1                  4       \        P.                  V
,          bK*  	  p	p
VR	,           \2        ,           V	R
&   \4        P6                  ! VRR	P                  RRP                  \        P                  P                  V4      4      RR.4      .\4        P8                  V	\        P                  P                  V4      R7       \$        P&                  ! WF4       \4        P6                  ! VRR.\4        P8                  V	\        P                  P                  V4      R7       RRR4       R# u up
i   + '       g   i     R# ; i)r   )GetModuleFileName_sqlite3zsqlite3{}.dll_dr   DLLszvcruntime*.dllN;
PYTHONPATHz-Scz	import oszp = os.add_dll_directory({!r})zimport _sqlite3zp.close)r  envcwd)_winapir  rS   	dllhandlerN   rO   	find_specrd   r   r   r  r  r   r
   temp_dirmkdirbasename
executableshutilcopyglobr  prefixenvironupperr   
subprocess
check_callSTDOUT)rj   r  dllnamepydnamedepnametmptmp2pyexer]   r  ks   &          r;   test_dll_dependency_import&ImportTests.test_dll_dependency_import  s5   -#CMM2..**:6=='',,GGOOG$""47?4CE !!S77<<V,DHHTNGGLLbgg&6&6s~~&FGEKK.KK%YYrww||DKK

,CEUVWA# X KK&C57ZZ@Z779bjjm+ZC@ $s
Z 7C !!uchh4;;02%( # "((GGOOE*
, KK&!!5%1B"C+5+<+<(+(*(>@? "! A "!!s    8EM.M C>MMM	c                    V P                  \        4      ;_uu_ 4       p\        P                  ! R R4       RRR4       V P	                  R\        XP                  4      4       R#   + '       g   i     L7; i)rH  s   6'CuNz"Frozen object named 'x' is invalid)r   r   _impget_frozen_objectr   r-   r   )rj   r   s   & r;   test_issue105979ImportTests.test_issue1059790  sO    {++r""3(89 ,:",,'	) ,+s   A%%A5	c                   V P                  \        4      ;_uu_ 4       p^ RIHp RRR4       T P	                  R\        P
                   R2\        XP                  4      4       V P                  \        4      ;_uu_ 4       p^ RIHp RRR4       V P	                  R\        VP                  4      4       . R	OpV Fb  pV P                  VR7      ;_uu_ 4        Rp\        P                  ! RV4      pVP                  4       w  rxV P	                  WW4       RRR4       Kd  	  R#   + '       g   i     EL; i  + '       g   i     L; i  + '       g   i     K  ; i)
r   )this_will_never_existNz6cannot import name 'this_will_never_exist' from 'os' ()zHcannot import name 'this_will_never_exist' from 'sys' (unknown location)r   sG   cannot import name 'this_will_never_exist' from 'os' (unknown location)r  )zb
import os
os.__spec__.has_location = False
os.__file__ = []
from os import this_will_never_exist
za
import os
os.__spec__.has_location = False
del os.__file__
from os import this_will_never_exist
zY
import os
os.__spec__.origin = []
os.__file__ = []
from os import this_will_never_exist
)r   r   r   r  r   r   r-   r   rS   subTestr%   r  r  )	rj   r   r  scriptsr   expected_errorr  r  r  s	   &        r;   $test_frozen_module_from_import_error0ImportTests.test_frozen_module_from_import_error7  s   {++r0 ,DR[[MQRS	
 {++r1 ,V	


( FV,,4  &224@!&!2!2!4n5 -, C ,++ ,+8 -,,s#   D#D7=E
#D4	7E	
Ec                &   R pVR,           VR,           .pV Fc  pV P                  VR7      ;_uu_ 4        RpRRR4       \        P                  ! RV4      pVP                  4       w  rgV P	                  XV4       Ke  	  R#   + '       g   i     LQ; i)z
import sys
class NotAModule: ...
nm = NotAModule()
nm.symbol = 123
sys.modules["not_a_module"] = nm
from not_a_module import symbol
z'from not_a_module import missing_symbolz8nm.__spec__ = []
from not_a_module import missing_symbolr  s`   ImportError: cannot import name 'missing_symbol' from '<unknown module name>' (unknown location)Nr  )r  r%   r  r  r   )rj   r  r  r   r  r  r  r  s   &       r;   !test_non_module_from_import_error-ImportTests.test_non_module_from_import_errorc  s     >>PP
 FV,,B  -
 "..tV<E"..0NFMM.&1 ,,s   B  Bc                   RR.pV EF  w  r#V P                  VR7      ;_uu_ 4        \        P                  ! 4       ;_uu_ 4       p\        \        P
                  P                  VR4      RRR7      ;_uu_ 4       pVP                  V4       RRR4       VR,           p\        P                  ! \        P
                  P                  VR4      VR7      pVP                  4       w  rV P                  W4       \        P                  ! R	R
VR7      pVP                  4       w  rV P                  W4       \        P                  ! RRVR7      pVP                  4       w  rV P                  W4       \        P                  ! RRVR7      pVP                  4       w  rV P                  VR4       \        P
                  P                  VR4      p
\        P                  ! V
4       \        P                  ! \        P
                  P                  VR4      V
R7      pVP                  4       w  rV P                  W4       \        P                  ! R	R
V
R7      pVP                  4       w  rV P                  VR4       \        P                  ! RRV
R7      pVP                  4       w  rV P                  VR4       RRR4       RRR4       EK  	  R#   + '       g   i     ELH; i  + '       g   i     L3; i  + '       g   i     EK  ; i)#import fractions
fractions.Fractionr  fractions.pyr   r   r   N    \(consider renaming '.*fractions.py' since it has the same name as the standard library module named 'fractions' and prevents importing that standard library module\)r  -m	fractionsr  zimport fractions-Pr=   childr  >   AttributeError: module 'fractions' has no attribute 'Fraction'zfrom fractions import Fractions;   ImportError: cannot import name 'Fraction' from 'fractions')r  r
   r  r  r   r   r  r  r%   r  r  r   r   r  )rj   script_errorsr   errorr  r]   r  r  r  r  	tmp_childs   &          r;   test_script_shadowing_stdlib(ImportTests.test_script_shadowing_stdlibz  s[   	
 +MFV,,i.@.@.B.Bc"'',,sN;S7SSWXGGFO T "'N" &22277<<^3TZ]^!&!2!2!4  8%224#N!&!2!2!4  8%2249KQTU!&!2!2!4  8 &224SQ!&!2!2!4  -GGLLg6	# &22277<<^3TZcd!&!2!2!4  8%224)T!&!2!2!4  -%2249KQZ[!&!2!2!4  -S /C,, +SSS /C.B,,,s<   K25K:KH(K4K2K	KK/*K22Lc                   RR.pV EF  w  r#V P                  VR7      ;_uu_ 4        \        P                  ! 4       ;_uu_ 4       p\        P                  ! \        P
                  P                  VR4      4       \        \        P
                  P                  VRR4      RRR7      ;_uu_ 4       pVP                  R4       RRR4       \        \        P
                  P                  VR	4      RRR7      ;_uu_ 4       pVP                  R
4       VP                  V4       RRR4       VR,           p\        P                  ! \        P
                  P                  VR	4      VR7      pVP                  4       w  rV P                  W4       \        P                  ! RRVR7      pVP                  4       w  rV P                  W4       \        P                  ! RR	VR7      pVP                  4       w  rV P                  VR4       RRR4       RRR4       EK  	  R#   + '       g   i     ELb; i  + '       g   i     EL; i  + '       g   i     LG; i  + '       g   i     EK`  ; i)fractions.Fractionr  r   __init__.pyr   r   r   shadowing_module = TrueNmain.pyz-import fractions; fractions.shadowing_module
s    \(consider renaming '.*[\\/]fractions[\\/]+__init__.py' since it has the same name as the standard library module named 'fractions' and prevents importing that standard library module\)r  r  mainr  s6   module 'fractions' has no attribute 'shadowing_module')r  r  r  )r  r
   r  r   r  r   r  r  r  r%   r  r  r   
rj   r  r   r  r  r]   r  r  r  r  s
   &         r;   $test_package_shadowing_stdlib_module0ImportTests.test_package_shadowing_stdlib_module  s   	
 +MFV,,i.@.@.B.Bcc;78GGLLk=A3QX GG56 "'',,sI6gNNRSGGLMGGFO O "'N" &22277<<Y3OUXY!&!2!2!4  8%224SI!&!2!2!4  8 &224L!&!2!2!4  )bc7 /C,, +   ONN /C.B,,,sU   IA*I/H<I=#H. C#IIH+%	I.H?9	IIII'c                |   RR.pV EFu  w  r#V P                  VR7      ;_uu_ 4        \        P                  ! 4       ;_uu_ 4       p\        \        P
                  P                  VR4      RRR7      ;_uu_ 4       pVP                  V4       RRR4       VR,           p\        P                  ! \        P
                  P                  VR4      4      pVP                  4       w  rV P                  W4       \        P                  ! RR	VR
7      pVP                  4       w  rV P                  W4       \        P                  ! RRVR
7      pVP                  4       w  rV P                  W4       RRR4       RRR4       EKx  	  R#   + '       g   i     L; i  + '       g   i     L2; i  + '       g   i     EK  ; i)import numpy
numpy.arrayr  numpy.pyr   r   r   Nsd    \(consider renaming '.*numpy.py' if it has the same name as a library you intended to import\)\s+\zr  numpyr  r  zimport numpy)r  s7   AttributeError: module 'numpy' has no attribute 'array')zfrom numpy import arrays4   ImportError: cannot import name 'array' from 'numpy'r  r
   r  r  r   r   r  r  r%   r  r  r   r  s
   &         r;   !test_script_shadowing_third_party-ImportTests.test_script_shadowing_third_party  sP   	
 +MFV,,i.@.@.B.Bc"'',,sJ7wOOSTGGFO P "'M"
 &22277<<Z3PQ!&!2!2!4  8%224cJ!&!2!2!4  8%224SQ!&!2!2!4  8' /C,, +OO /C.B,,,s<   F)5F:FC F,F)FFF&!F))F;c           	     4   \         P                  ! 4       ;_uu_ 4       p\        \        P                  P                  VR 4      RRR7      ;_uu_ 4       pVP                  R4       RRR4       Rp\        P                  ! RRVR	7      pVP                  4       w  rVV P                  WS4       R
p\        P                  ! RRVR	7      pVP                  4       w  rVV P                  WS4       RRR4       R#   + '       g   i     L; i  + '       g   i     R# ; i)r  r   r   r   z3this_script_does_not_attempt_to_import_numpy = TrueNs;   AttributeError: module 'numpy' has no attribute 'attr'\s+\zr  zimport numpy; numpy.attrr  s?   ImportError: cannot import name 'attr' from 'numpy' \(.*\)\s+\zzfrom numpy import attr)r
   r  r  r   r   r  r  r%   r  r  r   )rj   r  r]   r  r  r  r  s   &      r;   +test_script_maybe_not_shadowing_third_party7ImportTests.test_script_maybe_not_shadowing_third_party  s    !!Sbggll3
3S7KKqMN L P  "..t5OUXYE"..0NFV4 T  "..t5MSVWE"..0NFV4! "!KK "!!s$   5DC3	%BD3D>DD	c           	     ~
   \         P                  ! 4       ;_uu_ 4       p\        \        P                  P                  VR 4      RRR7      ;_uu_ 4       pVP                  R4       RRR4       \        \        P                  P                  VR4      RRR7      ;_uu_ 4       pVP                  R4       RRR4       \        P                  ! RVR7      pVP                  4       w  rEV P                  R	VP                  4       4       \        \        P                  P                  VR4      RRR7      ;_uu_ 4       pVP                  R
4       RRR4       \        P                  ! RVR7      pVP                  4       w  rEV P                  R	VP                  4       4       \        \        P                  P                  VR4      RRR7      ;_uu_ 4       pVP                  R4       RRR4       \        P                  ! RVR7      pVP                  4       w  rEVP                  4       pV P                  \        V4      ^4       V F  pV P                  VR4       K  	  \        \        P                  P                  VR4      RRR7      ;_uu_ 4       pVP                  R4       RRR4       \        P                  ! RVR7      pVP                  4       w  rEVP                  4       pV P                  \        V4      ^4       V F  pV P                  VR4       K  	  \        \        P                  P                  VR4      RRR7      ;_uu_ 4       pVP                  R4       RRR4       \        P                  ! RVR7      pVP                  4       w  rEVP                  4       pV P                  \        V4      ^4       V F  pV P                  VR4       K  	  \        \        P                  P                  VR4      RRR7      ;_uu_ 4       pVP                  R4       RRR4       \        P                  ! RVR7      pVP                  4       w  rEVP                  4       pV P                  \        V4      ^4       V F  pV P                  VR4       K  	  RRR4       R#   + '       g   i     ELC; i  + '       g   i     EL	; i  + '       g   i     EL; i  + '       g   i     EL; i  + '       g   i     ELW; i  + '       g   i     EL; i  + '       g   i     EL; i  + '       g   i     R# ; i)r  r   r   r   r  Nr  z
import fractions
fractions.shadowing_module
class substr(str):
    __hash__ = None
fractions.__name__ = substr('fractions')
try:
    fractions.Fraction
except TypeError as e:
    print(str(e))
r  s   unhashable type: 'substr'z
import fractions
fractions.shadowing_module
class substr(str):
    __hash__ = None
fractions.__name__ = substr('fractions')
try:
    from fractions import Fraction
except TypeError as e:
    print(str(e))
ac  
import fractions
fractions.shadowing_module

import sys
sys.stdlib_module_names = None
try:
    fractions.Fraction
except AttributeError as e:
    print(str(e))

del sys.stdlib_module_names
try:
    fractions.Fraction
except AttributeError as e:
    print(str(e))

sys.path = [0]
try:
    fractions.Fraction
except AttributeError as e:
    print(str(e))
s.   module 'fractions' has no attribute 'Fraction'a~  
import fractions
fractions.shadowing_module

import sys
sys.stdlib_module_names = None
try:
    from fractions import Fraction
except ImportError as e:
    print(str(e))

del sys.stdlib_module_names
try:
    from fractions import Fraction
except ImportError as e:
    print(str(e))

sys.path = [0]
try:
    from fractions import Fraction
except ImportError as e:
    print(str(e))
s5   cannot import name 'Fraction' from 'fractions' \(.*\)z
import fractions
fractions.shadowing_module
del fractions.__spec__.origin
try:
    fractions.Fraction
except AttributeError as e:
    print(str(e))

fractions.__spec__.origin = []
try:
    fractions.Fraction
except AttributeError as e:
    print(str(e))
a  
import fractions
fractions.shadowing_module
del fractions.__spec__.origin
try:
    from fractions import Fraction
except ImportError as e:
    print(str(e))

fractions.__spec__.origin = []
try:
    from fractions import Fraction
except ImportError as e:
    print(str(e))
)r
   r  r  r   r   r  r  r%   r  r  r   rstrip
splitlinesr   lenr   )rj   r  r]   r  r  r  lineslines   &       r;   'test_script_shadowing_stdlib_edge_cases3ImportTests.test_script_shadowing_stdlib_edge_cases  s    !!Sbggll37wOOST12 P bggll3	2C'JJa 
 
 K "..ycBE"..0NFMM6Hbggll3	2C'JJa 
 
 K "..ycBE"..0NFMM6H bggll3	2C'JJa   K0 "..ycBE"..0NF%%'ESZ+  'XY  bggll3	2C'JJa   K0 "..ycBE"..0NF%%'ESZ+  '`a  bggll3	2C'JJa   K" "..ycBE"..0NF%%'ESZ+  'XY  bggll3	2C'JJa   K  "..ycBE"..0NF%%'ESZ+  '`a e "!OOO KJJ  KJJ$ KJJ> KJJ@ KJJ0 KJJ} "!!s   5T+R	%<T+!R3	3BT+9S	BT+S	#B,T+S/	!B,T+T	B,T+T	A8T+R0*	T+3S>	T+S	T+S,&	T+/T :	T+T	T+T("	T++T<	zCannot delete cwd on Windowssunos5z$Cannot delete cwd on Solaris/Illumosc           	     $   \         P                  ! 4       ;_uu_ 4       p\        P                  P	                  VR 4      p\        P
                  ! V4       \        \        P                  P	                  VR4      RRR7      ;_uu_ 4       pVP                  R4       RRR4       \        P                  ! RRVR	7      pVP                  4       w  rVR
pV P                  WW4       RRR4       R#   + '       g   i     LX; i  + '       g   i     R# ; i)subtmpr  r   r   r   zl
import sys
assert sys.path[0] == ''

import os
import shutil
shutil.rmtree(os.getcwd())

os.does_not_exist
Nr  zimport mainr  s=   AttributeError: module 'os' has no attribute 'does_not_exist')r
   r  r   r   r  r  r  r  r%   r  r  r   )rj   r  r(  r]   r  r  r  r  s   &       r;   (test_script_shadowing_stdlib_cwd_failure4ImportTests.test_script_shadowing_stdlib_cwd_failure  s     !!SWW\\#x0FHHVbggll695sWMMQR 	 	 N "..t]OE"..0NF^NV4% "! NM "!!s%   A+C>	C+	AC>+C;6C>>D	c                8   RR.pV EF@  w  r#V P                  VR7      ;_uu_ 4        \        P                  ! 4       ;_uu_ 4       p\        \        P
                  P                  VR4      RRR7      ;_uu_ 4       pVP                  R4       RRR4       \        \        P
                  P                  VR4      RRR7      ;_uu_ 4       pVP                  R	4       VP                  V4       RRR4       VR
,           p\        P                  ! RVR7      pVP                  4       w  rV P                  W4       RRR4       RRR4       EKC  	  R#   + '       g   i     L; i  + '       g   i     L~; i  + '       g   i     LE; i  + '       g   i     EK  ; i)r  r  r  r   r   r   r  Nr  z=import sys; sys.path.insert(0, "this_folder_does_not_exist")
r  r  r  r  r  r  s
   &         r;   2test_script_shadowing_stdlib_sys_path_modification>ImportTests.test_script_shadowing_stdlib_sys_path_modification  s'   	
 +MFV,,i.@.@.B.Bc"'',,sN;S7SSWXGG56 T"'',,sI6gNNRSGG\]GGFO O "'N" &229#F!&!2!2!4  8 /C,, +SSNN /C.B,,,sT   F5E4:E<E4#E!+AE47FEE4!E1,E44F?FFc                   V P                  \        R 4      ;_uu_ 4         ! R R4      p\        P                  ! V! 4       4       RRR4       V P                  \        R 4      ;_uu_ 4         ! R R4      p\        P                  ! V! 4       4       RRR4       R#   + '       g   i     L^; i  + '       g   i     R# ; i)zembedded null characterc                       ] tR tRtRtRtRtR# )2ImportTests.test_create_dynamic_null.<locals>.Speci  a babcr}   Nr   r   r   r   r\   rd   r   r}   r=   r;   Specr0    s    r=   r4  Nc                       ] tR tRtRtRtRtR# )3ImportTests.test_create_dynamic_null.<locals>.Spec2i  r2  r1  r}   Nr3  r}   r=   r;   Spec2r6    s    !r=   r7  )r  
ValueErrorr  create_dynamic)rj   r4  r7  s   &  r;   test_create_dynamic_null$ImportTests.test_create_dynamic_null  s    ##J0IJJ  '	 K ##J0IJJ" " (	 KJ KJ KJJs   &B+&B.B+	.B?	r}   N)longlist)8r   r   r   r   r   r   r   r   r   r   r   r   r   r   r  r  r  r*  r9  r@  rJ  rN  rT  skip_if_dont_write_bytecoder[  rc  ri  rx  r}  r  r  r  r  r  r&   requires_working_threadingr  r2   
skipUnlessrS   r(  r  r  r  r  r	  r  r  r  r$  ro   r)  r,  r:  r   r   r   s   @r;   r   r   \  s    &<FKh  *-+7*7'R&P!(	33"$L !( !(.	/ !! !!29 . ."!c  	" 	" 002  3 D 02DE*@ F*@X)*6X2.5.n'dR9B5&Tbl __S\\W,.LM__S\\X-/UV5 W N5*98) )r=   r   c                   r  a  ] tR tRt o ]P
                  ! ]P                  R8H  R4      ]P                  ! ]	R4      R 4       4       t
]P
                  ! ]P                  R8H  R4      ]P                  R 4       4       t]P
                  ! ]P                  R8H  R4      ]P                  R 4       4       tR tR	tV tR
# )FilePermissionTestsi  posix%test meaningful only on posix systemsz$Emscripten's/WASI's umask is a stub.c           	     H   ^p\        V4      ;_uu_ 4        \        4       ;_uu_ 4       w  r#\        P                  P	                  V4      p\        V4      p\        P                  P                  V4      '       g   V P                  R4       \        P                  ! V4      pRRR4       RRR4       V P                  \        \        P                  ! XP                  4      4      \        RV( ,          4      4       R#   + '       g   i     Ld; i  + '       g   i     Lo; i)   4__import__ did not result in creation of a .pyc fileNi  )r#   r   rN   rO   ro  r.   r   r   existsr  ru  r   octS_IMODEst_mode)rj   maskr\   r   cached_pathr5   	stat_infos   &      r;   test_creation_mode&FilePermissionTests.test_creation_mode  s     00LT#..::4@K%F77>>+..		 ( ),I  1 	T\\)*;*;<=UdU]+	-  10s#   DA9C>	"D>D	DD!	c           	     d   R p\        ^4      ;_uu_ 4        \        4       ;_uu_ 4       w  r#\        P                  P	                  V4      p\
        P                  ! W14       \        V4       \
        P                  P                  V4      '       g   V P                  R4       \
        P                  ! V4      pRRR4       RRR4       V P                  \        \        P                  ! XP                  4      4      \        V4      4       R#   + '       g   i     L\; i  + '       g   i     Lg; i)  rF  Nr#   r   rN   rO   ro  r   chmodr.   r   rG  r  ru  r   rH  rI  rJ  )rj   moder\   r   rL  rM  s   &     r;   test_cached_mode_issue_2051/FilePermissionTests.test_cached_mode_issue_2051  s    
  1 1\d#..::4@KHHT t77>>+..		 ( ),I !2 	T\\)*;*;<=s4yI !2 1s#   DBD	8DDDD/	c           	     v   R p\        ^4      ;_uu_ 4        \        4       ;_uu_ 4       w  r#\        P                  P	                  V4      p\
        P                  ! W14       \        V4       \
        P                  P                  V4      '       g   V P                  R4       \
        P                  ! V4      pRRR4       RRR4       V^,          pV P                  \        \        P                  ! XP                  4      4      \        V4      4       R#   + '       g   i     Le; i  + '       g   i     Lp; i)   rF  NrR  )rj   rT  r\   r   rL  rM  r8   s   &      r;   test_cached_readonly(FilePermissionTests.test_cached_readonly  s      1 1\d#..::4@KHHT t77>>+..		 ( ),I !2 %<T\\)*;*;<=s8}M !2 1s#   D(BD	8D(D% D((D8	c           	     `   \        4       ;_uu_ 4       w  r\        VR RR7      ;_uu_ 4       pVP                  R4       RRR4       \        P                  ! V4      p\        P
                  ! W$P                  VP                  R,
          34       \        P                  ! VR4       \        V4      pV P                  VP                  R4       \        P                  ! VR4       \        VR RR7      ;_uu_ 4       pVP                  R	4       RRR4       \        V4       \        P                  ! 4        \        V4      pV P                  VP                  R
4       \        V4       \        V4       \        P                  ! 4        VR,           p\        P                   ! \        P"                  P%                  V4      V4       \        V4      pV P                  VP                  R
4       RRR4       R#   + '       g   i     EL; i  + '       g   i     EL; i  + '       g   i     R# ; i)r   r   r   zx = 'original'
Ni rX  originalrQ  zx = 'rewritten'
	rewrittenr.  )r   r  r  r   ru  rp  st_atimest_mtimerS  r.   r   rH  r   rN   r   r   renamerO   ro  )rj   r\   r   r]   smbytecode_onlys   &      r;   test_pyc_always_writable,FilePermissionTests.test_pyc_always_writable   sw    ,4dC'22a*+ 3 AHHTJJ

9(<=>HHT5!4 AQSS*-HHT5!dC'22a+, 34L'')4 AQSS+.4L4L'') 3JMIIinn66t<mL4 AQSS+.3 222 322 s;   HG4	B<H:H	CH4H?	HH	HH-	r}   N)r   r   r   r   r2   r?  r   r\   ro   r   rN  r
   skip_unless_working_chmodrU  rY  rd  r   r   r   s   @r;   rA  rA    s      G+@B__.-	B- G+@B((J )BJ G+@B((N )BN/ /r=   rA  c                   &  a  ] tR tRt o RtRt]P                  P                  ]	4      t
]P                  P                  ]
]4      ]P                  ,           R,           t]P                  P!                  ]4      tR tR tR tR tR	 tR
 tR tRtV tR# )PycRewritingTestsi?  unlikely_module_namez
import sys
code_filename = sys._getframe().f_code.co_filename
module_filename = __file__
constant = 1000
def func():
    pass
func_filename = func.__code__.co_filename
rQ  c                   \         P                  R ,          V n        \         P                  P	                  V P
                  R4      V n        \        P                  ! V P                  4       \        V P                  RRR7      ;_uu_ 4       pVP                  V P                  4       RRR4       \         P                  P                  ^ V P                  4       \        P                   ! 4        R#   + '       g   i     LQ; i)NNNNr   r   r   )rS   r   sys_pathrT   rb   r  orig_moduler   r  dir_namer  	file_namer  module_sourcer&  rN   r   )rj   r]   s   & r;   r   PycRewritingTests.setUpR  s    ;;??4+;+;TB
$..#88AGGD&&' 94==)##% 98s   C11D	c                T   V P                   \        P                  R &   V P                  e)   V P                  \        P                  V P
                  &   M\        V P
                  4       \        V P                  4       \        V P                  4       \        V P                  4       R# rk  N)rl  rS   r   rm  rT   r  r   r   ro  compiled_namer"   rn  r   s   &r;   r   PycRewritingTests.tearDown[  sm    mm',0,<,<CKK(()4##$t~~t!!"t}}r=   c                    \        4       p\        V P                  W4       \        P                  V P                  ,          # r?   )r
  r.   r  rS   rT   )rj   ry   s   & r;   r    PycRewritingTests.import_modulee  s.    Y4##R,{{4++,,r=   c                D   V P                  4       pV P                  VP                  V P                  4       V P                  VP                  V P                  4       V P                  VP
                  V P                  4       \        P                  V P                   V P                  4       pV P                  VP                  V P                  4       V P                  VP                  V P                  4       V P                  VP
                  V P                  4       R # r?   )	r    r   module_filenamero  code_filenamefunc_filenamerS   rT   r  rj   r   s   & r;   test_basicsPycRewritingTests.test_basicsj  s      ",,dnn=**DNN;**DNN;KK(()  ",,dnn=**DNN;**DNN;r=   c                N   \         P                  ! V P                  R R7       V P                  4       pV P	                  VP
                  V P                  4       V P	                  VP                  V P                  4       V P	                  VP                  V P                  4       R# zanother_module.py)dfileN)r2  r3  ro  r    r   ry  rz  r{  r|  s   & r;   test_incorrect_code_name*PycRewritingTests.test_incorrect_code_nameu  ss    4>>1DE  ",,dnn=**DNN;**DNN;r=   c                   R p\         P                  ! V P                  VR7       \        P                  ! V P                  4       \        V P                  4      p\        P                  ! 4        V P                  4       pV P                  VP                  V4       V P                  VP                  V4       V P                  VP                  V4       R# r  )r2  r3  ro  r   rX  r   rN   r   r    r   ry  rz  r{  )rj   r  pyc_filer   s   &   r;   test_module_without_source,PycRewritingTests.test_module_without_source|  s    $4>>8
		$..!"4>>2##%  ",,h7**F3**F3r=   c                   \         P                  ! V P                  4       \        V P                  R 4      ;_uu_ 4       pVP                  ^4      p\        P                  ! V4      pRRR4       \        XP                  4      p\        P                  P                  pVP                  R4      pWTV&   VP                  \        V4      R7      p\        V P                  R4      ;_uu_ 4       pVP!                  X4       \        P"                  ! W14       RRR4       V P                  4       pV P%                  VP&                  P(                  VP(                  4       R#   + '       g   i     L; i  + '       g   i     Le; i)rbNr   )	co_constswb)r2  r3  ro  r  rt  r   marshalloadlistr  rN   r    __code__indexreplacer   r  dumpr   constantco_filename)rj   r]   headercode	constantsforeign_codeposr   s   &       r;   test_foreign_code#PycRewritingTests.test_foreign_code  s   4>>*$$$d++qVVBZF<<?D , (	 ..77ood#%#||eI&6|7$$$d++qGGFOLL! ,   "11<3K3KL ,+ ,+s   (E,(E1E.	1F	)rm  rl  N)r   r   r   r   r  rp  r   r   r^  r!   rn  r  rR  ro  rN   rO   ro  rt  r   r   r    r}  r  r  r  r   r   r   s   @r;   rh  rh  ?  s     
 )KM wwv&HX{3bii?$FINN44Y?M&-
	<<	4M Mr=   rh  c                      a  ] tR tRt o R
t]tR tR tR t	]
P                  ! ]P                  R8H  R4      R 4       tRtV tR	# )
PathsTestsi  c                ~    \         P                  ! V P                  4       \        P                  R ,          V n        R# rs  )r   r  r   rS   syspathr   s   &r;   r   PathsTests.setUp  s!    
xx{r=   c                j    \        V P                  4       V P                  \        P                  R &   R# rs  )r"   r   r  rS   r   s   &r;   r   PathsTests.tearDown  s    tyyllr=   c                   \        \        P                  P                  V P                  R 4      RRR7      ;_uu_ 4       pVP	                  R4       RRR4       \
        P                  P                  V P                  R,           4       \        R4      pV P                  VP                  R4       \        R4       R#   + '       g   i     Lt; i)ztest_trailing_slash.pyr   r   r   z testdata = 'test_trailing_slash'N/test_trailing_slash)r  r   r   r  r  rS   r4  r.   r   testdatar   )rj   r]   r   s   &  r;   r  PathsTests.test_trailing_slash  s    "'',,tyy*BC) ),-GG67) 			#&./'<=$%) )s   B==C	r  r  c                    \        \        P                  P                  V P                  R 4      R4      ;_uu_ 4       pVP	                  R4       RRR4       \
        P                  ! 4        \        P                  P                  V P                  4      p^ RIpVP                  4       pV^ ,          pRV: RV: R2pWbR,          ,          p \        P                  ! V4       \"        P                  P%                  ^ T4        \'        R	4      pT P-                  XP.                  R	4       T P1                  TP2                  T4       \5        R	4       R#   + '       g   i     EL; i  \         dZ   pTP                  \        P                  \        P                  \        P                  39   d   T P!                  RT: 24       h Rp?ii ; i  \(         d$   pT P+                  R
T: RT: 24        Rp?LRp?ii ; i)ztest_unc_path.pyr   ztestdata = 'test_unc_path'Nz\\\$r=  NNz#cannot access administrative share test_unc_pathz&could not import 'test_unc_path' from z: )r  r   r   r  r  rN   r   r^  socketgethostnamelistdirrr  rs  EPERMEACCESENOENTrb  rS   r&  r.   r   r  r   r  assertStartsWithr   r   )	rj   r]   r   r  hndriveuncrw  r   s	   &        r;   test_UNC_pathPathsTests.test_UNC_path  si   "'',,tyy*<=sCCqGG01 D##%wwtyy)!Q'Bx	JJsO 	3	"_-C 	7cllC03 DCC  	ww5;;ellCCNO		  	"IIa! " "	"s<   EE( G E%	(G3AGGG=G88G=)r  N)rC  u   testäöüßu   testéèu
   test°³²)r   r   r   r   SAMPLESr!   r   r   r   r  r2   r?  rS   r(  r  r   r   r   s   @r;   r  r    sL     )GD##
& 02DE  F r=   r  c                   Z   a  ] tR tRt o R t]tR tR tR tR t	R t
R tR	 tR
 tRtV tR# )RelativeImportTestsi  c                    \        R 4       R# )ztest.relimportN)r   r   s   &r;   r   RelativeImportTests.tearDown  s     r=   c                6    ^RI Hp V P                  VR4       R# )r=  )	relimportr  N)r   r  rF  )rj   r  s   & r;   test_relimport_star'RelativeImportTests.test_relimport_star  s     9&;<r=   c                D  a V3R  lp\        RRR7      oV! 4        \        RRR7      oV! 4        \        RRR7      oV P                  \        V4       \        RRR7      oV P                  \        V4       \        \        4       R7      oV P                  \        V4       R# )c                      < \        R S 4       R# )zfrom . import relimportN)r  )ry   s   r;   check_relative:RelativeImportTests.test_issue3221.<locals>.check_relative  s    *B/r=   rC  ztest.notarealmodule)__package__r   znotarealpkg.notarealmoduler  )r  N)dictr   r   objectr  )rj   r  ry   s   & @r;   test_issue3221"RelativeImportTests.test_issue3221  s    	0 f/DE f/KL e.CD-~> e.JK-~> fh')^4r=   c                8    \         P                  ! R RRR4       R# )z-Wignorer  zfoo = 1; from . import fooN)r%   assert_python_failurer   s   &r;   )test_parentless_import_shadowed_by_global=RelativeImportTests.test_parentless_import_shadowed_by_global  s    ++D(D(	*r=   c                    V P                  \        4      ;_uu_ 4        ^RIHp V P	                  R4       RRR4       R#   + '       g   i     R# ; i)r<  )sepz>explicit relative import triggered an implicit absolute importN)r   r   r   r  r  )rj   r  s   & r;   #test_absolute_import_without_future7RelativeImportTests.test_absolute_import_without_future  s8     {++II 1 2 ,+++s   A  A	c                D   \         P                  P                  \         P                  P                  \        4      R R4      p\        RR4      ;_uu_ 4        \        V4      ;_uu_ 4        V P                  \        4      ;_uu_ 4        ^ RI	pRRR4       V P                  R\        P                  4       V P                  R\        P                  4       RRR4       RRR4       R#   + '       g   i     Lb; i  + '       g   i     L-; i  + '       g   i     R# ; i)r  package2
submodule1
submodule2N)r   r   r  r  r   r'   r   r   r   r  r	  rS   rT   )rj   r   r  s   &  r;   test_import_from_non_package0RelativeImportTests.test_import_from_non_package  s    ww||BGGOOH5vzJ\<00-2E2E"";//! 0\3;;7\3;;7	 3F00// 3F2E000s=   D+C;		C(AC;	D(C83C;	;DDD	c           	     z   \        R RR4      ;_uu_ 4        \        \        P                  P	                  \        P                  P                  \        4      R4      4      ;_uu_ 4        ^ RIpVP                  P                   RRR4       RRR4       R#   + '       g   i     L; i  + '       g   i     R# ; i)r  zpackage2.submodule1zpackage2.submodule2r  N)
r'   r   r   r   r  r  r   package2.submodule1r  r  )rj   r  s   & r;   !test_import_from_unloaded_package5RelativeImportTests.test_import_from_unloaded_package  so    Z!68MNN277<<(A6JKK&** L ONKK ONNs$   AB))B	B)B&!B))B:	c           	        \         P                  P                  \         P                  P                  \        4      R 4      p\        RR4      ;_uu_ 4        \        V4      ;_uu_ 4        ^ RIHp V P                  VP                  R4       ^ RIHp V P                  VP                  R4       RRR4       RRR4       \        RR4      ;_uu_ 4        \        V4      ;_uu_ 4        ^ RIHp V P                  VP                  R4       ^ RIHp V P                  VP                  R4       RRR4       RRR4       R#   + '       g   i     L; i  + '       g   i     L; i  + '       g   i     L@; i  + '       g   i     R# ; i)r  package3zpackage3.submodule	submodulereboundN)r   r   r  r  r   r'   r   r  r  r   attrpackage3.submodulerj   r   r  s   &  r;   test_rebinding"RelativeImportTests.test_rebinding  s     ww||BGGOOH5v>Z!566d8K8K*Y^^Y72Y^^Y7	 9L6
 Z!566d8K8K2Y^^Y7*Y^^Y7	 9L66 9L8K66
 9L8K666J   E*AD>	/EE7'AE$	,E7>E	EE!	$E4/E77F	c           	        \         P                  P                  \         P                  P                  \        4      R 4      p\        RR4      ;_uu_ 4        \        V4      ;_uu_ 4        ^ RIHp V P                  VP                  R4       ^ RIHp V P                  VP                  R4       RRR4       RRR4       \        RR4      ;_uu_ 4        \        V4      ;_uu_ 4        ^ RIHp V P                  VP                  R4       ^ RIHp V P                  VP                  R4       RRR4       RRR4       R#   + '       g   i     L; i  + '       g   i     L; i  + '       g   i     L@; i  + '       g   i     R# ; i)r  package4zpackage4.submoduleNr  r  rd   )r   r   r  r  r   r'   r   package4.submoduler  r   r  r  r  s   &  r;   test_rebinding2#RelativeImportTests.test_rebinding2!  s    ww||BGGOOH5v>Z!566d8K8K2Y^^[9*Y^^[9	 9L6
 Z!566d8K8K*Y^^X62Y^^[9	 9L66 9L8K66
 9L8K666r  r}   N)r   r   r   r   r   r   r  r  r  r  r  r  r  r  r   r   r   s   @r;   r  r    s<     !E=
5:*
28+8: :r=   r  c                   &   a  ] tR tRt o R tRtV tR# )OverridingImportBuiltinTestsi/  c                   ^ RI pR pV P                  V! 4       V4       \        \        RR 4      ;_uu_ 4        V P                  V! 4       ^4       RRR4       \	        \        4       RR 4      ;_uu_ 4        V P                  V! 4       V4       RRR4       R#   + '       g   i     LP; i  + '       g   i     R# ; i)r   Nc                      ^ RI p V # r   r   r  s    r;   r  ?OverridingImportBuiltinTests.test_override_builtin.<locals>.foo4  s
    Ir=   r.   c                      ^#    r}   rH  s   *r;   <lambda>DOverridingImportBuiltinTests.test_override_builtin.<locals>.<lambda>9  s    !r=   c                      ^# r  r}   r  s   *r;   r  r  ?  s    1r=   )r   r   r   builtinsr   r
  )rj   r   r  s   &  r;   test_override_builtin2OverridingImportBuiltinTests.test_override_builtin0  s    	 	#x|<<SUA& = wy,==SUB' >= =< >==s   B7B,B)	,B=	r}   N)r   r   r   r   r  r   r   r   s   @r;   r  r  /  s     ( (r=   r  c                   R  a  ] tR tRt o R tR tR t]R 4       t]	P                  ! ]P                  R8H  R4      ]]P                  ]P                  ]	P                   ! ]R4      R	 4       4       4       4       4       t]R
 4       t]R 4       tR t]R 4       t]R 4       tR tR tRtV tR# )PycacheTestsiC  c                d    \        \        4       \        R 4       \        V P                  4       R# )r[   N)r   r!   r"   r   r!  r   s   &r;   _cleanPycacheTests._cleanF  s    v}t{{r=   c                b   \         R ,           V n        V P                  4        \        V P                  RRR7      ;_uu_ 4       p\	        RVR7       RRR4       \
        P                  P                  ^ \        P                  4       \        P                  ! 4        R#   + '       g   i     LU; i)rX   r   r   r   z/# This is a test file written by test_import.pyr  N)r!   r!  r  r  r  rS   r   r&  r   r'  rN   r   )rj   fps   & r;   r   PycacheTests.setUpK  sf    un$++sW55C"M 6299%##% 65s   BB.	c                H    \         P                  ^  V P                  4        R# r   )rS   r   r  r   s   &r;   r   PycacheTests.tearDownS  s    HHQKr=   c                   V P                  \        P                  P                  R 4      4       \	        \
        4       V P                  \        P                  P                  R 4      4       \        P                  P                  V P                  4      pV P                  \        P                  P                  V4      RP                  V\
        4      4       R# )r[   z*bytecode file {!r} for {!r} does not existN)assertFalser   r   rG  r.   r!   
assertTruerN   rO   ro  r!  r   rj   pyc_paths   & r;   test_import_pyc_path!PycacheTests.test_import_pyc_pathX  s    676}56>>33DKK@x0  &x 8	:r=   rB  rC  zumask is a stubc                   \        ^4      ;_uu_ 4        \        \        4       RRR4       V P                  \        P
                  P                  R4      4       \        P                  P                  V P                  4      pV P                  \        P
                  P                  V4      RP                  V\        4      4       R#   + '       g   i     L; i)   Nr[   z"bytecode file {!r} for {!r} exists)r#   r.   r!   r
  r   r   rG  rN   rO   ro  r!  r	  r   r  s   & r;   test_unwritable_directory&PycacheTests.test_unwritable_directoryb  s     v }56>>33DKK@1!!'&!9	;	 s   CC	c                   \        \        4       \        P                  P	                  V P
                  4      pV P                  \        P                  P                  V4      4       \        P                  ! V P
                  4       \        \        4       \        P                  ! 4        V P                  \        \         \        4       R # r?   )r.   r!   rN   rO   ro  r!  r
  r   r   rG  rX  r   r   r   r   )rj   r  s   & r;   test_missing_source PycacheTests.test_missing_sources  sr     	6>>33DKK@x01
		$++v##%+z6:r=   c           	     ,   \        \        4       \        V P                  4      p\        P
                  ! V P                  4       \        \        4       \        P                  ! 4        \        \        4      p V P                  VP                  \        P                  P                  \        P                  ! 4       \        P                  P                  V4      4      4       \        P
                  ! V4       R #   \        P
                  ! T4       i ; ir?   )r.   r!   r   r!  r   rX  r   rN   r   r   r   r   r  getcwdrelpathrj   r  rb  s   &  r;   test_missing_source_legacy'PycacheTests.test_missing_source_legacy  s     	6"4;;/
		$++v##%v	 QZZWW\\"))+rwwx7PQS IIhBIIhs   9A*C; ;Dc                   \        \        4      p\        P                  P	                  \        R ,           4      pV P                  VP                  \        P                  P                  \        P                  ! 4       V4      4       R# )rX   N)r.   r!   rN   rO   ro  r   
__cached__r   r   r  r  )rj   rb  r  s   &  r;   test___cached__PycacheTests.test___cached__  sM    v>>33FUNCrww||BIIK'JKr=   c           	        \        \        4       \        V P                  4      p\        P
                  ! V P                  4       \        \        4       \        P                  ! 4        \        \        4      pV P                  VP                  \        P                  P                  \        P                  ! 4       \        P                  P                  V4      4      4       R # r?   )r.   r!   r   r!  r   rX  r   rN   r   r   r  r   r  r  r  r  s   &  r;   test___cached___legacy_pyc'PycacheTests.test___cached___legacy_pyc  s     	6"4;;/
		$++v##%vbiik277??83LM	Or=   c                ,   R  p\         P                  ! R4       V P                  V4       \        \         P                  P                  RR4      R4      ;_uu_ 4         RRR4       \        \         P                  P                  RR4      R4      ;_uu_ 4         RRR4       \        P                  ! 4        \        R4      p\        P                  P                  \         P                  P                  RR4      4      pV P                  VP                  \         P                  P                  \         P                  ! 4       V4      4       \        P                  P                  \         P                  P                  RR4      4      pV P                  \        P                  R,          P                  \         P                  P                  \         P                  ! 4       V4      4       R#   + '       g   i     EL; i  + '       g   i     ELp; i)c                  H    \        R 4       \        R4       \        R 4       R# pep3147pep3147.fooNr"   r   r}   r=   r;   cleanup5PycacheTests.test_package___cached__.<locals>.cleanup      9=!9r=   r&  r  r  Nfoo.pyr'  )r   r  r  r  r   r  rN   r   r.   rO   ro  r   r  r  rS   rT   rj   r)  rb  init_pycfoo_pycs   &    r;   test_package___cached__$PycacheTests.test_package___cached__  s@   	 	 "'',,y-8$?? @"'',,y(3T:: ;##%}%>>33GGLLM24rww||BIIK'JK..22277<<	83TU]3>>biik7;	= @??:::s   G.H.G?	H	c                   R  p\         P                  ! R4       V P                  V4       \        \         P                  P                  RR4      R4      ;_uu_ 4         RRR4       \        \         P                  P                  RR4      R4      ;_uu_ 4         RRR4       \        P                  ! 4        \        R4      p\        R4       \        R4       \        P                  ! 4        \        R4      p\        P                  P                  \         P                  P                  RR4      4      pV P                  VP                  \         P                  P                  \         P                  ! 4       V4      4       \        P                  P                  \         P                  P                  RR4      4      pV P                  \        P                   R,          P                  \         P                  P                  \         P                  ! 4       V4      4       R#   + '       g   i     EL; i  + '       g   i     EL; i)c                  H    \        R 4       \        R4       \        R 4       R# r%  r(  r}   r=   r;   r)  >PycacheTests.test_package___cached___from_pyc.<locals>.cleanup  r+  r=   r&  r  r  Nr,  r'  )r   r  r  r  r   r  rN   r   r.   r   rO   ro  r   r  r  rS   rT   r-  s   &    r;    test_package___cached___from_pyc-PycacheTests.test_package___cached___from_pyc  sf   	 	 "'',,y-8$?? @"'',,y(3T:: ;##%}%}y##%}%>>33GGLLM24rww||BIIK'JK..22277<<	83TU]3>>biik7;	= @??:::s   H$H8$H5	8I		c                *   \        \        4       \        \        4       \        V P                  R RR7      ;_uu_ 4       p\        RVR7       RRR4       \        \        4      pV P                  VP                  ^4       R#   + '       g   i     L=; i)r  r   r   zx = 5r  N)r.   r!   r   r  r!  r  r   rH  )rj   r  rb  s   &  r;   test_recompute_pyc_same_second+PycacheTests.test_recompute_pyc_same_second  s^     	6v$++sW55'# 6va  65s   BB	)r!  N)r   r   r   r   r  r   r   r=  r  r2   r?  r   r\   r
   rf  skip_if_dac_overridero   r   r  r  r  r  r!  r0  r5  r8  r   r   r   s   @r;   r  r  C  s     
&
 !: !: G+@B ((##__]$56	; 7 $ ) !B	; !	; !	; !  ! $L !O !O != !=,=6! !r=   r  c                      a  ] tR tRt o Rt]R,           tR tR t]P                  ! ]
! ]R4      '       * ;'       g    ]P                  ! 4       R8  R4      ]P                  R 4       4       tR	tV tR
# )TestSymbolicallyLinkedPackagei  samplez-taggedc                   \         P                  ! V P                  4       \         P                  ! V P                  4       \        P
                  R ,          V n        \        P                  ! V P                  4       V P                  \         P                  V P                  4       \        P
                  P                  V P                  R4      p\         P                  ! V4       \        P                  ! V P                  V P                  RR7       V P                  \         P                  V P                  4       \        P                  ! 4        V P!                  \        P
                  P#                  V P                  4      R4       R# )rk  r  T)target_is_directoryN)r
   r"   taggedpackage_namerS   r   orig_sys_pathr   r  r  r  create_empty_filesymlinkr   rN   r   r   isdir)rj   	init_files   & r;   r   #TestSymbolicallyLinkedPackage.setUp  s    %**+ XXa[ 		(($++6GGLLm<	##I.
 	

4;; 1 1tL	(($*;*;<##%t'8'894@r=   c                @    V P                   \        P                  R &   R# rs  )rB  rS   r   r   s   &r;   r   &TestSymbolicallyLinkedPackage.tearDown   s    ((r=   getwindowsversionzWindows Vista or later requiredc                n    R .\         P                  R&   \        P                  ! V P                  4       R# ).rk  N)rS   r   rN   r    rA  r   s   &r;   test_symlinked_dir_importable;TestSymbolicallyLinkedPackage.test_symlinked_dir_importable  s)     e
 	 1 12r=   )rB  N)   r   )r   r   r   r   rA  r@  r   r   r2   r?  r   rS   rJ  r
   skip_unless_symlinkrM  r   r   r   s   @r;   r<  r<    sz     LI%FN.) C,-- 	- 	-  "f,)+ ""3 #	+
3r=   r<  c                   8   a  ] tR tRt o R tR tR tR tRtV t	R# )ImportlibBootstrapTestsi  c                V    \         P                  R ,          pV P                  V4       R# )_frozen_importlibN)rS   rT   r
  r|  s   & r;   test_frozen_importlib-ImportlibBootstrapTests.test_frozen_importlib  s    kk-.r=   c                
   ^ RI Hp \        P                  R,          pV P	                  W!4       V P                  VP                  R4       V P                  VP                  R4       V P                  VP                  R4       R# )r   )
_bootstraprT  zimportlib._bootstraprN   z_bootstrap.pyN)
rN   rX  rS   rT   rE  r   r   r  rW  r   )rj   rX  r   s   &  r;   "test_frozen_importlib_is_bootstrap:ImportlibBootstrapTests.test_frozen_importlib_is_bootstrap  s]    (kk-.c&'=>+6CLL/:r=   c                
   ^ RI Hp \        P                  R,          pV P	                  W!4       V P                  VP                  R4       V P                  VP                  R4       V P                  VP                  R4       R# )r   )_bootstrap_external_frozen_importlib_externalzimportlib._bootstrap_externalrN   z_bootstrap_external.pyN)
rN   r\  rS   rT   rE  r   r   r  rW  r   )rj   r\  r   s   &  r;   4test_frozen_importlib_external_is_bootstrap_externalLImportlibBootstrapTests.test_frozen_importlib_external_is_bootstrap_external#  s^    1kk67c/'FG+6CLL*BCr=   c                    ^ RI Hp \        P                  R,          pV P	                  VP
                  VP
                  4       R# )r   )	machineryrT  N)rN   ra  rS   rT   rE  
ModuleSpec)rj   ra  r   s   &  r;   test_there_can_be_only_one2ImportlibBootstrapTests.test_there_can_be_only_one+  s.     	(kk-.i**CNN;r=   r}   N)
r   r   r   r   rU  rY  r^  rc  r   r   r   s   @r;   rR  rR    s     ;D< <r=   rR  c                   6   a  ] tR tRt o RtR tR tR tRtV t	R# )GetSourcefileTestsi4  zTest importlib._bootstrap_external._get_sourcefile() as used by the C API.

Because of the peculiarities of the need of this function, the tests are
knowingly whitebox tests.

c                    \         P                  ! R 4      ;_uu_ 4       pRVn        \        R,           p\        R,           pV P	                  \        V4      V4       RRR4       R#   + '       g   i     R# ; i)*importlib._bootstrap_external._path_isfileTrY   rX   Nr	   patchreturn_valuer!   r   r   )rj   _path_isfiler   expects   &   r;   test_get_sourcefile&GetSourcefileTests.test_get_sourcefile>  sU     ZZDEE(,L%F?De^F_T2F;	 FEEEs   =A&&A7	c                    \         P                  ! R 4      ;_uu_ 4       pRVn        \        R,           pV P	                  \        V4      V4       RRR4       R#   + '       g   i     R# ; i)rh  FrY   Nri  )rj   rl  r   s   &  r;   test_get_sourcefile_no_source0GetSourcefileTests.test_get_sourcefile_no_sourceG  sL     ZZDEE(-L%F?D_T2D9 FEEEs   0AA*	c                V    \         R ,           pV P                  \        V4      V4       R# )z.bad_extN)r!   r   r   )rj   r   s   & r;   test_get_sourcefile_bad_ext.GetSourcefileTests.test_get_sourcefile_bad_extO  s#     
".5r=   r}   N)
r   r   r   r   r   rn  rq  rt  r   r   r   s   @r;   rf  rf  4  s     <:6 6r=   rf  c                      a  ] tR tRt o R tR tRR ltR tR tR t	R t
R	 tR
 tR tR tR tR tR t]R 4       t]P*                  ! ]R4      R 4       tRtV tR# )ImportTracebackTestsiV  c                    \         P                  ! \        4       \        P                  R ,          V n        \        P                  P                  ^ \        4       R# rs  )r   r  r!   rS   r   old_pathr&  r   s   &r;   r   ImportTracebackTests.setUpX  s/    
6"r=   c                ^    V P                   \        P                  R &   \        \        4       R# rs  )ry  rS   r   r"   r!   r   s   &r;   r   ImportTracebackTests.tearDown]  s    mmvr=   c                6   \         P                  P                  \        W,           4      p\	        VR RR7      ;_uu_ 4       pVP                  V4       RRR4       V P                  \        V4       \        P                  ! 4        V#   + '       g   i     L=; i)r   r   r   N)
r   r   r  r!   r  r  r  r   rN   r   )rj   r   contentsr   fnamer]   s   &&&&  r;   create_module"ImportTracebackTests.create_modulea  sb    VSY/%w//1GGH 0$##%	 0/s   BB	c                Z   . pV'       dW   VP                   P                  pVP                  pV'       d   WSR,          8w  d   VP                  V4       VP                  pK^  V P                  \        V4      \        V4      V4       \        W24       F  w  rVV P                  We4       K  	  R# )r<  Nr0  )	tb_framer  r  r4  tb_nextr   r!  zipr   )rj   tbfilesdeduped_filesr  fnpats   &&&    r;   assert_traceback%ImportTracebackTests.assert_tracebacki  s    ;;%%D!!B B*;$;$$R(B]+SZG=0GBMM#" 1r=   c                     ^ RI pV P                  R4       V P	                  X\
        .4       R#   \         d   pTP                  p Rp?L5Rp?ii ; i)r   N#ImportError should have been raised)nonexistent_xyzzyr  r   __traceback__r  r   )rj   r  rw  r  s   &   r;   test_nonexistent_module,ImportTracebackTests.test_nonexistent_moduleu  sF    	=$ II;<b8*-	  	!B	!s   0 AAAc                    V P                  R R4        ^ RIpV P                  R4       V P                  X\        R.4       R#   \         d   pTP                  p Rp?L6Rp?ii ; i)r  zimport nonexistent_xyzzyNr  r,  )r  r  r  r   r  r  r   rj   r  rw  r  s   &   r;   test_nonexistent_module_nested3ImportTracebackTests.test_nonexistent_module_nested  sZ    5"<=	= II;<b8X"67	  	!B	!   A A$AA$c                    V P                  R R4        ^ RIpV P                  R4       V P                  X\        R.4       R#   \         d   pTP                  p Rp?L6Rp?ii ; i)r  1/0N)ZeroDivisionError should have been raisedr,  r  r  r  r?  r  r  r   r  s   &   r;   test_exec_failure&ImportTracebackTests.test_exec_failure  sZ    5%(	C IIABb8X"67	 ! 	!B	!r  c                    V P                  R R4       V P                  RR4        ^ RIpV P                  R4       V P                  X\        RR.4       R#   \         d   pTP                  p Rp?L7Rp?ii ; i)r  z
import barbarr  Nr  r,  bar.pyr  r  s   &   r;   test_exec_failure_nested-ImportTracebackTests.test_exec_failure_nested  sl    5,/5%(	C IIABb8Xx"@A	 ! 	!B	!s   A A7!A22A7c                    V P                  R R4        ^ RIpV P                  R4       V P                  X\        .4       R#   \         d   pTP                  p Rp?L5Rp?ii ; i)r  zinvalid syntax is invalidNz#SyntaxError should have been raised)r  r  r  SyntaxErrorr  r  r   r  s   &   r;   test_syntax_error&ImportTracebackTests.test_syntax_error  sW    5"=>	= II;<b8*-	  	!B	!s   A A#AA#c                b   R pV P                  \        V4       \        P                  P	                  \
        V4      p\        P                  ! V4       \        P                  P	                  VR4      p\        VRRR7      ;_uu_ 4       pVP                  V4       RRR4       \        P                  P	                  VR4      p\        VRRR7      ;_uu_ 4       pVP                  V4       RRR4       \        P                  ! 4        WW3#   + '       g   i     Lx; i  + '       g   i     L;; i)_parent_foor  r   r   r   Nr  )r  r   r   r   r  r!   r  r  r  rN   r   )rj   parentr  pkg_namepkg_path	init_pathr]   bar_paths   &&&     r;   _setup_broken_package*ImportTracebackTests._setup_broken_package  s     )77<<1
GGLL=9	)S733qGGFO 477<<(3(C'22aGGEN 3##%"" 43 32s   	DDD	D.	c                    V P                  R R4      w  r ^ RIpV P                  R4       V P                  X\        V.4       R#   \         d   pTP                  p Rp?L6Rp?ii ; i)r   r  Nr  r  _parent_foo.barr  r?  r  r  r   rj   r  r  r  rw  r  s   &     r;   test_broken_submodule*ImportTracebackTests.test_broken_submodule  s_    "88UC		C" IIABb8X"67	 ! 	!B	!   A A&A!!A&c                    V P                  R R4      w  r ^ RIHp V P                  R4       V P                  X\        V.4       R#   \         d   pTP
                  p Rp?L6Rp?ii ; i)r   r  r  r  Nr  r  r  r  r?  r  r  r   rj   r  r  r  rw  r  s   &     r;   test_broken_from%ImportTracebackTests.test_broken_from  s^    "88UC		=' II;<b8X"67	 ! 	!B	!   A A(A##A(c                    V P                  R R4      w  r ^ RIpV P                  R4       V P                  X\        V.4       R#   \         d   pTP                  p Rp?L6Rp?ii ; i)r  r   Nr  r  r  s   &     r;   test_broken_parent'ImportTracebackTests.test_broken_parent  s_    "88C		C" IIABb8Y"78	 ! 	!B	!r  c                    V P                  R R4      w  r ^ RIHp V P                  R4       V P                  X\        V.4       R#   \         d   pTP
                  p Rp?L6Rp?ii ; i)r  r   r  r  Nr  r  s   &     r;   test_broken_parent_from,ImportTracebackTests.test_broken_parent_from  s_    "88C		C' IIABb8Y"78	 ! 	!B	!r  c                $   V P                  R R4       \        P                  R,          pR\        VP                  4      9   d   VP                  P
                  pMRp R pW1P                  n         ^ RIpV P                  R4       V P                  X\        R\        .4       Vf   VP                  =R# W!P                  n        R#   \         d   pTP                  p Rp?L]Rp?ii ; i  Tf   TP                  =i Y!P                  n        i ; i)r  r   r]  load_moduleNc                      ^^ ,           R# )r<  Nr}   )r  s   *r;   rR   9ImportTracebackTests.test_import_bug.<locals>.exec_module  s    !r=   r  z<frozen importlib)r  rS   rT   varsSourceLoaderrR   r  r  r?  r  r  r   )rj   rN   old_exec_modulerR   r  rw  r  s   &      r;   test_import_bug$ImportTracebackTests.test_import_bug  s     	5"%KK <=	D!7!788'44@@O"O	E1<"".G 		EF!!"x1Dh&OP&**65D&&2 % %__% &**65D&&2s6   C, 2C 6.C, C)C$C, $C))C, ,#Dzneed TESTFN_UNENCODABLEc                    \         P                  ! R \        R4      pV P                  \        V4       VRR p\         P
                  ! RRV,          RR7       R# )r   passNr  zmod = __import__(%a)F)
__isolated)r%   rf  r$   r  r   rg  )rj   pynamer\   s   &  r;   test_unencodable_filename.ImportTracebackTests.test_unencodable_filename  sM     **2/A6J'cr{&&t-Cd-J27	9r=   )ry  N)rX   )r   r   r   r   r   r   r  r  r  r  r  r  r  r  r  r  r  r  r   r  r2   r?  r$   r  r   r   r   s   @r;   rw  rw  V  s     #

#.88	B.#8899 E E4 +-FG9 H9r=   rw  c                      a  ] tR tRt o RtR tR tR tR tR t	R t
R	 tR
 tR tR tR t]]P$                  ! ]RJ R4      R 4       4       tR tRtV tR# )CircularImportTestsi  zMSee the docstrings of the modules being imported for the purpose of the
test.c                    \        \        P                  P                  4       4       F-  pVP	                  R4      '       g   K  \        P                  V K/  	  R# )zKMake sure no modules pre-exist in sys.modules which are being used to
test.z&test.test_import.data.circular_importsN)r  rS   rT   keysr)  )rj   keys   & r;   r   CircularImportTests.tearDown  s<     ((*+C~~FGGKK$ ,r=   c                V     ^ RI pR#   \         d    T P                  R4        R# i ; i)r   Nz/circular import through relative imports failed),test.test_import.data.circular_imports.basicr   r  rj   rC  s   & r;   test_directCircularImportTests.test_direct  s)    	I? 	IIIGH	I    ((c                V     ^ RI pR#   \         d    T P                  R4        R# i ; i)r   Nz@relative import in module contributing to circular import failed)/test.test_import.data.circular_imports.indirectr   r  r  s   & r;   test_indirect!CircularImportTests.test_indirect  s*    	'B 	'II & '	'r  c                V     ^ RI pR#   \         d    T P                  R4        R# i ; i)r   Nz-circular import involving a subpackage failed)1test.test_import.data.circular_imports.subpackager   r  r  s   & r;   test_subpackage#CircularImportTests.test_subpackage  s)    	GD 	GIIEF	Gr  c                     ^ RI Hu Hu Hu Hp ^ RIHp V P                  VP                  XP                  4       R#   \
         d    T P                  R4        LLi ; i)r   Nz9circular import with rebinding of module attribute failed)rO   )
0test.test_import.data.circular_imports.rebindingr*  r  circular_imports	rebindingr   r  -test.test_import.data.circular_imports.subpkgrO   rE  )rj   r  rO   s   &  r;   r  "CircularImportTests.test_rebinding%  sJ    	SPP 	Gdii0  	SIIQR	Ss   ? AAc                V     ^ RI pR#   \         d    T P                  R4        R# i ; i)r   Nz9circular import with binding a submodule to a name failed).test.test_import.data.circular_imports.bindingr   r  r  s   & r;   test_binding CircularImportTests.test_binding-  s)    	SA 	SIIQR	Sr  c                    ^ RI p^ RIpR# r   )*test.test_import.data.circular_imports.use-test.test_import.data.circular_imports.sourcer  s   & r;   test_crossreference1(CircularImportTests.test_crossreference13  s    9<r=   c                :   V P                  \        4      ;_uu_ 4       p^ RIpRRR4       \        XP                  4      pV P                  RV4       V P                  RV4       V P                  RV4       V P                  RV4       R#   + '       g   i     Lo; i)r   Nz-test.test_import.data.circular_imports.sourcespamzpartially initialized modulezcircular import)r   r  r  r-   r   r   )rj   r   rC  errmsgs   &   r;   test_crossreference2(CircularImportTests.test_crossreference27  so    ~.."@ /R\\"EvNff%4f='0 /.s   B

B	c                    V P                  \        4      ;_uu_ 4       p^ RIpRRR4       V P                  R\	        XP
                  4      4       R#   + '       g   i     L7; i)r   Nzcannot import name 'b' from partially initialized module 'test.test_import.data.circular_imports.from_cycle1' (most likely due to a circular import))r   r   2test.test_import.data.circular_imports.from_cycle1r   r-   r   rj   r   rC  s   &  r;   test_circular_from_import-CircularImportTests.test_circular_from_import@  sE    {++rE ,5 		
 ,+   AA"	c                    V P                  \        R 4      ;_uu_ 4        ^ RIpRRR4       R#   + '       g   i     R# ; i)zpartially initialized module 'test.test_import.data.circular_imports.import_cycle' from '.*' has no attribute 'some_attribute' \(most likely due to a circular import\)N)r  r  3test.test_import.data.circular_imports.import_cycler  s   & r;   test_circular_import(CircularImportTests.test_circular_importJ  s9    ##d
 

 G
 
 
 
s   .?	c                    V P                  \        4      ;_uu_ 4       p^ RIpRRR4       V P                  R\	        XP
                  4      4       R#   + '       g   i     L7; i)r   Nzcannot access submodule 'parent' of module 'test.test_import.data.circular_imports.subpkg2' (most likely due to a circular import))r   r  5test.test_import.data.circular_imports.subpkg2.parentr   r-   r   r  s   &  r;    test_absolute_circular_submodule4CircularImportTests.test_absolute_circular_submoduleR  sE    ~.."H /5 		
 /.r  Nrn   c                   RpRp\        W4      ;_uu_ 4        \        P                  p\        WRR7      pV P	                  VP
                  V4       V P                  V\        P                  4       V P                  V\        P                  4       V P                  V\        P                  4       V P                  V\        P                  4       RRR4       V P                  V\        P                  4       V P                  V\        P                  4       V P                  XP                  4       V4       \        P                  ! RVP                  P                  4       R#   + '       g   i     L; i)a  Regression test for gh-123950

Import a single-phase-init module that imports itself
from the PyInit_* function (before it's added to sys.modules).
Manages its own cache (which is `static`, and so incompatible
with multiple interpreters or interpreter reset).
_testsinglephase_circularz2test.test_import.data.circular_imports.singlephaseF)rL   N)r'   ra   r   rV   r   helper_mod_namer   rS   rT   r	  rE  clear_static_varre   rf   r/   rd   )rj   r\   helper_namerJ   r   s   &    r;   test_singlephase_circular-CircularImportTests.test_singlephase_circular\  s    +JT'''00H -T@EGC S00+>MM$,MM+s{{3MM$,MM+s{{3 ( 	s{{+ckk2c**,c2))*E*-,,*=*=	?! ('s   B:E''E7	c                   V P                  \        R 4       V P                  \        R4       ^ RIHu Hu Hp V P                  \        4      ;_uu_ 4        ^ RIHp RRR4       V P                  \        V4      \        4       V P                  \        X4      \        4       V P                  \        4      ;_uu_ 4        ^*Vn        RRR4       R#   + '       g   i     L}; i  + '       g   i     R# ; i)z test.test_import.data.unwritablez"test.test_import.data.unwritable.xNr  )r  r    test.test_import.data.unwritabler*  r  
unwritableassertWarnsImportWarningrH  assertNotEqualr1   r(   r   r   r  )rj   r  rH  s   &  r;   test_unwritable_module*CircularImportTests.test_unwritable_module{  s     BC DE==m,,: - 	D,j9a*-~..JL /. -,
 /..s   C C%C"	%C6	r}   )r   r   r   r   r   r   r  r  r  r  r  r  r  r  r  r  rq   r2   ro   ra   r  r  r   r   r   s   @r;   r  r    s~     %I'G1S=1
G
 __%-/VW? X ?: r=   r  c                     a ] tR tRt o]! RRRRR7      t]! R^R7      t]P                  4        U Uu/ uF  w  rW'       * bK  	  upp t^]R&   ]	P                  ! ]! ]R4      R4      R	 4       tR"R ltR#RRRR
RR/R lltR#RRRR/R lltR#RR/R lltRRRR/R ltRR/R lt]	P(                  ! ]R
J R4      R 4       t]]	P(                  ! ]R
J R4      R 4       4       t]R 4       t]	P(                  ! ]R
J R4      R 4       t]	P(                  ! ]R
J R4      R 4       t]	P(                  ! ]R
J R4      R 4       t]	P(                  ! ]R
J R4      R 4       t]R 4       t ]	P(                  ! ]R
J R4      R 4       t!]"]R  4       4       t#R!t$Vt%R
# u upp i )$SubinterpImportTestsi  FT)
allow_fork
allow_execallow_threadsallow_daemon_threads)use_main_obmallocgilr   r   zrequires os.pipe()c                   \         P                  ! 4       w  rV P                  \         P                  V4       V P                  \         P                  V4       \	        \         R 4      '       d   \         P
                  ! VR4       W3# )set_blockingF)r   r   r  r   r   r"  )rj   r   r   s   &  r;   r   SubinterpImportTests.pipe  sU    wwy!$!$2~&&OOAu%vr=   Nc                    R pVe   RV R2pV'       dA   \         '       d   RpMRp\        P                  ! RV RV RV RV: R	V: R
V: RV R24      # \        P                  ! RV RV RV R24      # )r   zZ
                import _imp
                _imp._override_multi_interp_extensions_check()
                r   r   z
                from importlib.util import spec_from_loader, module_from_spec
                from importlib.machinery import z0
                import os, sys
                z
                loader = (z, z*)
                spec = spec_from_loader(a4  , loader)
                try:
                    module = module_from_spec(spec)
                    loader.exec_module(module)
                except ImportError as exc:
                    text = 'ImportError: ' + str(exc)
                else:
                    text = 'okay'
                os.write(z(, text.encode('utf-8'))
                z1
                try:
                    import z
                except ImportError as exc:
                    text = 'ImportError: ' + str(exc)
                else:
                    text = 'okay'
                os.write()r   r   r   )rj   r\   fdrJ   check_overrideoverride_textr0   s   &&&&&  r;   import_script"SubinterpImportTests.import_script  s    %!>>L=M NM  /.?? (117 9   4("XL 9))- 1  $  " ?? (   6 "
  
$ 
 
r=   check_singlephase_settingcheck_singlephase_overrideisolatedc               >   \        V4       \        R/ V P                  BV'       d   V P                  MV P                  BRV/B pV P                  4       w  rxV P                  WVV4      p	\        V	3/ VB p
V P                  V
^ 4       \        P                  ! V^d4      # )a#  
Try importing the named module in a subinterpreter.

The subinterpreter will be in the current process.
The module will have already been imported in the main interpreter.
Thus, for extension/builtin modules, the module definition will
have been loaded already and cached globally.

"check_singlephase_setting" determines whether or not
the interpreter will be configured to check for modules
that are not compatible with use in multiple interpreters.

This should always return "okay" for all modules if the
setting is False (with no override).
check_multi_interp_extensionsr}   )r.   r  
RUN_KWARGSISOLATEDNOT_ISOLATEDr   r*  r   r   r   r   )rj   r\   rJ   r,  r-  r.  kwargsr   r   r   r   s   &&&$$$     r;   run_hereSubinterpImportTests.run_here  s    ( 	4 
oo
 (t}}d.?.?
 +D
 yy{##DX$>@ +6<V<a wwq#r=   strictc               R    V P                  WVVR 7      pV P                  VR4       R# )r,  r.     okayNr5  r   )rj   r\   rJ   r7  r.  outs   &&&$$ r;   check_compatible_here*SubinterpImportTests.check_compatible_here  s1     mmD6<%-   	g&r=   c               x    V P                  WR VR7      pV P                  VP                  R4      RV R24       R# )Tr9  r   ImportError: module , does not support loading in subinterpretersN)r5  r   r   )rj   r\   rJ   r.  r<  s   &&&$ r;   check_incompatible_here,SubinterpImportTests.check_incompatible_here  sH     mmD6:%-   	JJw"4&(TU	
r=   c                  \        R/ V P                  BV'       d   V P                  MV P                  BR V/B pVR,          pV^ 8X  d   RMV^8X  d   RM
V^8X  d   RMTVR&   \        P
                  ! R\        P                  ! RV: RV: RV: R	V R
V P                  VR4      : R24      4      w  rgpV P                  VR4       V P                  VR4       R# )r0  r   defaultsharedownr  zP
            import _testinternalcapi, sys
            assert (
                z0 in sys.builtin_module_names or
                z( not in sys.modules
            ), repr(z2)
            config = type(sys.implementation)(**T)
            ret = _testinternalcapi.run_in_subinterp_with_config(
                sys.stdout.fileno()U,
                config,
            )
            assert ret == 0, ret
            r=   r:  Nr}   )
r  r1  r2  r3  r%   rg  r   r   r*  r   )	rj   r\   r7  r.  r4  r   r  r<  r:   s	   &&$$     r;   check_compatible_fresh+SubinterpImportTests.check_compatible_fresh	  s    
  
oo
 (t}}d.?.?
 +1

 Um%(AX	qHsaxeS 	u#44T8?? P   H 117 9##D*?@C DL <  	c"g&r=   c                  \        R/ V P                  BV'       d   V P                  MV P                  BR R/B pVR,          pV^ 8X  d   RMV^8X  d   RM
V^8X  d   RMTVR&   \        P
                  ! R\        P                  ! RV: RV: R	V R
V P                  VR4      : R2	4      4      w  rVpV P                  VR4       V P                  VP                  R4      RV R24       R# )r0  Tr   rE  rF  rG  r  z>
            import _testinternalcapi, sys
            assert z not in sys.modules, z1
            config = type(sys.implementation)(**rH  rI  rJ  r=   r   r@  rA  Nr}   )r  r1  r2  r3  r%   rg  r   r   r*  r   r   )rj   r\   r.  r4  r   r  r<  r:   s   &&$     r;   check_incompatible_fresh-SubinterpImportTests.check_incompatible_fresh(	  s     
oo
 (t}}d.?.?
 +/

 Um%(AX	qHsaxeS 	u#44T8?? P80 9117 9##D*?@C D	L 	< 	 	c"JJw"4&(TU	
r=   requires _testinternalcapic                f   R p\        V4       \        '       g9   V P                  V R24      ;_uu_ 4        V P                  VRR7       RRR4       V P                  V R24      ;_uu_ 4        V P                  VRR7       RRR4       R#   + '       g   i     LJ; i  + '       g   i     R# ; i)r  : not strictFr7  N: strict, not freshT)rA   r   r  r=  rj   r5   s   & r;   test_builtin_compat(SubinterpImportTests.test_builtin_compatD	  s     566**6%*@ 7\\VH$7899&&vd&; :9 76999s   B.BB	B0	c                   R p\        VRR7       \        V4      P                  P                  R8w  d   \        P
                  ! V R24      h\        '       g9   V P                  V R24      ;_uu_ 4        V P                  VRR7       RRR4       V P                  V R	24      ;_uu_ 4        V P                  VRR7       RRR4       R#   + '       g   i     LJ; i  + '       g   i     R# ; i)
rT  T)r6   r+   z is unexpectedly not frozenrR  FrS  NrT  )	rE   r.   r/   rd   r2   r3   r   r  r=  rU  s   & r;   test_frozen_compat'SubinterpImportTests.test_frozen_compatP	  s     %vD)f&&--9##vh.I$JKK566**6%*@ 7\\VH$7899&&vd&; :9 76999s   5C-CC	C/	c                r   R p\        V4       V P                  V R24      ;_uu_ 4        V P                  VRR7       RRR4       V P                  V R24      ;_uu_ 4        V P                  V4       RRR4       V P                  V R24      ;_uu_ 4        V P	                  V4       RRR4       V P                  V R24      ;_uu_ 4        V P	                  VRR	7       RRR4       R#   + '       g   i     L; i  + '       g   i     L; i  + '       g   i     Lp; i  + '       g   i     R# ; i)
ra   rR  FrS  NrT  : strict, freshz: isolated, freshTr.  )rC   r  r=  rB  rN  rU  s   & r;   !test_single_init_extension_compat6SubinterpImportTests.test_single_init_extension_compat]	  s    #&!\\VHL122&&ve&< 3\\VH$7899((0 :\\VHO455))&1 6\\VH$5677))&4)@ 87 329955777s/   C,"C?DD%,C<	?D	D"	%D6	z$test requires _testmultiphase modulec                   R p\        V4       \        '       g9   V P                  V R24      ;_uu_ 4        V P                  VRR7       RRR4       V P                  V R24      ;_uu_ 4        V P                  VRR7       RRR4       V P                  V R24      ;_uu_ 4        V P	                  VRR7       RRR4       R#   + '       g   i     L; i  + '       g   i     L]; i  + '       g   i     R# ; i)_testmultiphaserR  FrS  NrT  Tr\  )rC   r   r  r=  rK  rU  s   & r;    test_multi_init_extension_compat5SubinterpImportTests.test_multi_init_extension_compatj	  s     #&!566**6%*@ 7\\VH$7899&&vd&; :\\VHO455''t'< 65	 7699555#   C.C&C*C	C'	*C;	c                6   R p\         P                  p\        W4      p\        V4       V P	                  V R24      ;_uu_ 4        V P                  WRR7       RRR4       V P	                  V R24      ;_uu_ 4        V P                  WRR7       RRR4       \        '       g;   V P	                  V R24      ;_uu_ 4        V P                  WRR7       RRR4       R# R#   + '       g   i     L; i  + '       g   i     Lk; i  + '       g   i     R# ; i)	_test_non_isolatedz
: isolatedTr]  Nz: not isolatedFrR  rS  )ra  r   rV   rC   r  rB  r   r=  rj   rI   rJ   r5   s   &   r;   -test_multi_init_extension_non_isolated_compatBSubinterpImportTests.test_multi_init_extension_non_isolated_compatx	  s     '"+++G>&!\\WIZ011((T(J 2\\WI^455((U(K 6	677**7U*K 87 	 2155 877s$   C!=C4D!C1	4D	D	c                   R
 EF  pV P                  VR7      ;_uu_ 4        \        P                  p\        W4      p\	        V4       V P                  V R24      ;_uu_ 4        V P                  WRR7       RRR4       V P                  V R24      ;_uu_ 4        V P                  WRRR7       RRR4       \        '       g:   V P                  V R	24      ;_uu_ 4        V P                  WRRR7       RRR4       RRR4       EK  	  R#   + '       g   i     L; i  + '       g   i     Lw; i  + '       g   i     LE; i  + '       g   i     EKU  ; i)_test_shared_gil_only)rI   z: isolated, strictTr]  Nz: not isolated, strictFr7  r.  z: not isolated, not strict)rk  "_test_no_multiple_interpreter_slot)r  ra  r   rV   rC   rB  r=  r   rg  s   &   r;   4test_multi_init_extension_per_interpreter_gil_compatISubinterpImportTests.test_multi_init_extension_per_interpreter_gil_compat	  s   >Gg..*333GF!&)\\WI-?"@AA00:> 1 @ B \\WI-C"DEE..w6:U / L F '	1K&LMM22#ee 3 M N /.> BA FE NM /..sZ   AE$D8$ED 1EE!D36EDE D0+E3E>EEc                   R p\        V4       \        '       g9   V P                  V R24      ;_uu_ 4        V P                  VRR7       RRR4       V P                  V R24      ;_uu_ 4        V P                  VRR7       RRR4       V P                  V R24      ;_uu_ 4        V P	                  VRR7       RRR4       R#   + '       g   i     L; i  + '       g   i     L]; i  + '       g   i     R# ; i)r  rR  FrS  NrT  Tr\  )rG   r   r  r=  rK  rU  s   & r;   test_python_compat'SubinterpImportTests.test_python_compat	  s    F#566**6%*@ 7\\VH$7899&&vd&; :\\VHO455''t'< 65	 7699555rd  c                *  a a R o\        S4       VV 3R lpVV 3R lpS P                  R4      ;_uu_ 4        V! R^4       RRR4       S P                  R4      ;_uu_ 4        V! R^ 4       RRR4       S P                  R4      ;_uu_ 4        V! RR4       RRR4       S P                  R4      ;_uu_ 4        V! R	^4       RRR4       S P                  R
4      ;_uu_ 4        V! R	^ 4       RRR4       S P                  R4      ;_uu_ 4        V! R	R4       RRR4       R#   + '       g   i     L; i  + '       g   i     L; i  + '       g   i     L; i  + '       g   i     L; i  + '       g   i     L; i  + '       g   i     R# ; i)ra   c                 T   < SP                  SV VR 7      pSP                  VR4       R# )r,  r-  r:  Nr;  settingoverrider<  r5   rj   s   && r;   check_compatible_SubinterpImportTests.test_singlephase_check_with_setting_and_override.<locals>.check_compatible	  s1    --*1+3   C
 S'*r=   c                 T   < SP                  SV VR 7      pSP                  VR4       R# ru  )r5  r  rv  s   && r;   check_incompatibleaSubinterpImportTests.test_singlephase_check_with_setting_and_override.<locals>.check_incompatible	  s1    --*1+3   C
 W-r=   z(config: check enabled; override: enabledTNz+config: check enabled; override: use configz)config: check enabled; override: disabledz)config: check disabled; override: enabledFz,config: check disabled; override: use configz*config: check disabled; override: disabledr0  )rC   r  )rj   ry  r|  r5   s   f  @r;   0test_singlephase_check_with_setting_and_overrideESubinterpImportTests.test_singlephase_check_with_setting_and_override	  s   #&!	+	. \\DEEtQ' F\\GHHtQ' I\\EFFT2& G \\EFFua( G\\HIIUA& J\\FGGUB' HG FEHHFF GFIIGGGsG   
D""
D5
E8
E#
E.
F"D2	5E	E	E+	.E>	F	c                R   R p\        V4       V P                  V R24      ;_uu_ 4        V P                  VRRR7       RRR4       V P                  V R24      ;_uu_ 4        V P                  VRRR7       RRR4       R#   + '       g   i     LK; i  + '       g   i     R# ; i)r  rT  Trl  Nr\  )rG   r  r=  rK  rU  s   & r;   test_isolated_config)SubinterpImportTests.test_isolated_config	  s    F#\\VH$7899&&vdT&J :\\VHO455''td'K 65 :9555s   B#BB	B&	c                ,  a \         P                  ! R 4      p\        P                  ! 4       oV P	                  V3R l4       \        P
                  ! SV4      pV P                  VR4       \        P
                  ! SV4      pV P                  VR4       R# )zU
            import _testsinglephase
            print(_testsinglephase)
            c                  0   < \         P                  ! S 4      # r?   )rs   destroyr   s   r;   r  ?SubinterpImportTests.test_disallowed_reimport.<locals>.<lambda>	  s     5 5h ?r=   N)r   r   rs   creater  r   assertIsNot)rj   r   excsnapr   s   &  @r;   test_disallowed_reimport-SubinterpImportTests.test_disallowed_reimport	  sy      "  !'')?@**8V<$'**8V<$'r=   r}   )NNr?   )&r   r   r   r   r  r1  r2  itemsr3  r2   r?  r   r   r   r*  r5  r=  rB  rK  rN  ro   re   rV  r   rY  rq   r^  ra  rb  rh  rn  rq  r~  r  rt   r  r   r   )r  vr   s   00@r;   r  r    sS    "	J H *2)9:)9AuH)9:LLV,.BC D*X"+0",0"  "H
'%*
'',
'
u 
'U 'U ':
 
8 __&$.0LM	< N	< __&$.0LM	< N 	< 
A 
A ___,.TU= V= ___,.TUL VL  ___,.TUM VM6 __&$.0LM	= N	=  (  (D __&$.0LML NL (  (S
 ;s   F	r  c                      a a ] tR tRt oRt]V 3R l4       t]P                  ]	P                  ! R4      P                  4       ,           t]V 3R l4       tRtVtV ;t# )TestSinglePhaseSnapshoti	  a  A representation of a single-phase init module for testing.

Fields from ModuleSnapshot:

* id - id(mod)
* module - mod or a SimpleNamespace with __file__ & __spec__
* ns - a shallow copy of mod.__dict__
* ns_id - id(mod.__dict__)
* cached - sys.modules[name] (or None if not there or not snapshotable)
* cached_id - id(sys.modules[name]) (or None if not there)

Extra fields:

* summed - the result of calling "mod.sum(1, 2)"
* lookedup - the result of calling "mod.look_up_self()"
* lookedup_id - the object ID of self.lookedup
* state_initialized - the result of calling "mod.state_initialized()"
* init_count - (optional) the result of calling "mod.initialized_count()"

Overridden methods from ModuleSnapshot:

* from_module()
* parse()

Other methods from ModuleSnapshot:

* build_script()
* from_subinterp()

----

There are 5 modules in Modules/_testsinglephase.c:

* _testsinglephase
   * has global state
   * extra loads skip the init function, copy def.m_base.m_copy
   * counts calls to init function
* _testsinglephase_basic_wrapper
   * _testsinglephase by another name (and separate init function symbol)
* _testsinglephase_basic_copy
   * same as _testsinglephase but with own def (and init func)
* _testsinglephase_with_reinit
   * has no global or module state
   * mod.state_initialized returns None
   * an extra load in the main interpreter calls the cached init func
   * an extra load in legacy subinterpreters does a full load
* _testsinglephase_with_state
   * has module state
   * an extra load in the main interpreter calls the cached init func
   * an extra load in legacy subinterpreters does a full load

(See Modules/_testsinglephase.c for more info.)

For all those modules, the snapshot after the initial load (not in
the global extensions cache) would look like the following:

* initial load
   * id: ID of nww module object
   * ns: exactly what the module init put there
   * ns_id: ID of new module's __dict__
   * cached_id: same as self.id
   * summed: 3  (never changes)
   * lookedup_id: same as self.id
   * state_initialized: a timestamp between the time of the load
     and the time of the snapshot
   * init_count: 1  (None for _testsinglephase_with_reinit)

For the other scenarios it varies.

For the _testsinglephase, _testsinglephase_basic_wrapper, and
_testsinglephase_basic_copy modules, the snapshot should look
like the following:

* reloaded
   * id: no change
   * ns: matches what the module init function put there,
     including the IDs of all contained objects,
     plus any extra attributes added before the reload
   * ns_id: no change
   * cached_id: no change
   * lookedup_id: no change
   * state_initialized: no change
   * init_count: no change
* already loaded
   * (same as initial load except for ns and state_initialized)
   * ns: matches the initial load, incl. IDs of contained objects
   * state_initialized: no change from initial load

For _testsinglephase_with_reinit:

* reloaded: same as initial load (old module & ns is discarded)
* already loaded: same as initial load (old module & ns is discarded)

For _testsinglephase_with_state:

* reloaded
   * (same as initial load (old module & ns is discarded),
     except init_count)
   * init_count: increase by 1
* already loaded: same as reloaded
c                *  < \         SV `  V4      pVP                  ^^4      Vn        VP	                  4       Vn        \        VP
                  4      Vn        VP                  4       Vn        \        VR4      '       d   VP                  4       Vn        V# )r<  initialized_count)superr   sumsummedlook_up_selflookeduprx   lookedup_idstate_initializedr   r  
init_count)r   r   rj   	__class__s   && r;   r   #TestSinglePhaseSnapshot.from_moduleV
  sx    w"3'ggam((*dmm,!$!6!6!83+,,!335DOr=   a  
        snapshot['module'].update(dict(
            int_const=mod.int_const,
            str_const=mod.str_const,
            _module_initialized=mod._module_initialized,
        ))
        snapshot.update(dict(
            summed=mod.sum(1, 2),
            lookedup_id=id(mod.look_up_self()),
            state_initialized=mod.state_initialized(),
            init_count=mod.initialized_count(),
            has_spam=hasattr(mod, 'spam'),
            spam=getattr(mod, 'spam', None),
        ))
        c                R   < \         SV `  V4      pVP                  '       g   V=V=V# r?   )r  r   has_spamr  )r   r   rj   r  s   && r;   r   TestSinglePhaseSnapshot.parseq
  s)    w}T"}}}	Mr=   )r  r  r  r  r  )r   r   r   r   r   r   r   rv   r   r   r   r  r   r   r   __classcell__)r  r   s   @@r;   r  r  	  se     dL   !,,x @ 0 VXK    r=   r  c                   D  a  ] tR tRt o Rt]R 4       tR t]R 4       tR t	R t
R tR	 tR
 tR$RRRR/R lltR tR tR tR tR tR tR tR tR tR tR tR t]P8                  ! ]RJ R4      R 4       t]R 4       t ]!! RR 7      ]R! 4       4       t"]R" 4       t#R#t$V t%R# )%SinglephaseInitTestsiz
  ra   c                   \         P                  P                  V P                  4      p\	        VP
                  4      V n        \        '       d   VP                  V n	        \        VP                  R ,           R4      ;_uu_ 4       p\        P                  P                  \        P                  P                  \        P                   4      VP#                  4       P%                  4       4      V n        RRR4       M"VP                  V n	        VP                  V n        V P)                  4        R#   + '       g   i     L"; i)z.originr   N)rN   rO   r  NAMEr1   r0   LOADERr   rd   ORIGINr  r   r   r  r  rS   r  r   r   FILEclean_up)r   rU   r]   s   &  r;   
setUpClassSinglephaseInitTests.setUpClass
  s    ~~''1$++&

 ? CJdkkI-s33q77<<GGOOCNN3FFHNN$ 43 CJ{{CH 	 43s   A-D00E 	c                &    V P                  4        R # r?   )r  r   s   &r;   r   SinglephaseInitTests.tearDown
  s    r=   c                B   V P                   pV\        P                  9   d^   \        \        P                  V,          R 4      '       d&   \        P                  V,          P	                  4        \        P                  V \
        P                  ! WP                  4       R# )rc   N)r  rS   rT   r   rc   re   rf   r  )r   r\   s   & r;   r  SinglephaseInitTests.clean_up
  sc    xx3;;s{{4(*:;; D!002D!))$

;r=   c                :   a a VV 3R  lpS P                  V4       R# )c                  J   < \         P                  ! S SP                  4       R # r?   )re   rf   r  )r\   rj   s   r;   r  9SinglephaseInitTests.add_module_cleanup.<locals>.clean_up
  s    --dDKK@r=   N)r  )rj   r\   r  s   ff r;   add_module_cleanup'SinglephaseInitTests.add_module_cleanup
  s    	A 	!r=   c                    ^ RI Hp V P                  W4      p\        P                  P                  WVR7      pV! V4      # )z
Load an extension module.
)_load)r0   )importlib._bootstrapr  r  rN   rO   spec_from_file_location)rj   r\   r   r  r0   rU   s   &&&   r;   _load_dynamic"SinglephaseInitTests._load_dynamic
  s@    
 	/T( ~~55d=C 6 ET{r=   c                "    V P                   pV P                  WP                  4      pV P	                  W2P                  4       4       W2V&   \        P                  ! VV\        P                  V4      R 7      #   \         d    / ;q n          Li ; ir\   r5   snapshot)
already_loadedr  r  r  r	  valuesr   r   r  r   )rj   r\   r  r   s   &&  r;   r  SinglephaseInitTests.load
  s    	6!00N   {{33356"t$$,88=
 	
  	6355N0	6s   A8 8BBc                    V P                  WP                  4      p\        P                  ! VV\        P                  V4      R 7      # r  )r  r  r   r   r  r   )rj   r\   r   reloadeds   &&& r;   re_loadSinglephaseInitTests.re_load
  s?     %%dKK8$$,88B
 	
r=   c                   a a \         P                  ! R 4      oV3R lpS P                  V4       \         P                  ! S\        P
                  ! R4      4       VV 3R lpS P                  V4       S# )legacyc                  n   <  \         P                  ! S 4       R #   \         P                   d     R # i ; ir?   )rs   r  InterpreterNotFoundErrorr  s   r;   ensure_destroyedASinglephaseInitTests.add_subinterpreter.<locals>.ensure_destroyed
  s.    %%h/ 99 s    44zI
            import sys
            import _testinternalcapi
            c            
         < \         P                  ! S \        P                  ! R SP                  : RSP
                  : R24      4       \         P                  ! S 4       R# )z
                name = z
                if name in sys.modules:
                    sys.modules.pop(name)._clear_globals()
                _testinternalcapi.clear_extension(name, r%  N)rs   r  r   r   r  r  r  )r   rj   s   r;   r  9SinglephaseInitTests.add_subinterpreter.<locals>.clean_up
  sW    x >		} %9 :> H	: *  !!(+r=   )rs   r  r  r  r   r   )rj   r  r  r   s   f  @r;   add_subinterpreter'SinglephaseInitTests.add_subinterpreter
  s_     ''1	
 	()8X__ 6 & 		, 	!r=   Nr   r   Fc          	        V P                   pV'       d   Vf   RMRpRV RV P                  : R2p V P                  p\        P                  VVVRVVR7      p	\        P                  ! VR V	R7      #   \         dc    \        P
                  ! 4       ;w  rx;q`n        T P                  \        P                  T4       T P                  \        P                  T4        Li ; i)	Nzimport _testinternalcapir   z
                z^
                mod._clear_globals()
                _testinternalcapi.clear_extension(name, r%  T)r   r   r   r   r  )r  r  _piper  r   r   r  r   r  r   r   r   )
rj   r   r   r   r\   import_r   r   r   r  s
   &&$$      r;   import_in_subinterp(SinglephaseInitTests.import_in_subinterp
  s     yy4<4D0"G	 99= HK	)::D +99!# : 
 $$
 	
  	)')wwy0DA04*OOBHHa(OOBHHa(	)s   A2 2A*CCc                2   R pVP                   pV'       g   RpVP                  P                   pV P                  VP                  P                  VP                  4       V P                  VP
                  V P                  4       V P                  VP                  P                  V P                  4       V'       g!   V P                  VP                  \        4       V P                  VP                  R4       V P                  VP                  R4       V P                  VP                  \         4       V P#                  VP                  ^ 4       VP                  pV P                  VP$                  ^4       VP&                  e=   V P                  VP&                  \         4       V P#                  VP&                  ^ 4       V'       d   V P                  VP(                  VP*                  4       V P                  VP,                  VP*                  4       V P/                  \0        4      ;_uu_ 4        VP2                   RRR4       R# V P5                  VP6                  V4       V P5                  VP8                  V4       R#   + '       g   i     R# ; i)FTi  zsomething differentN)r5   r  r   r/   r\   r   r  rd   r  assertIsSubclassr  r4   	int_const	str_constassertIsInstance_module_initializedfloatassertGreaterr  r  r  rx   r|   r   r  r  rE  r  r{   )rj   loadedr.  r   snaps   &&   r;   check_common!SinglephaseInitTests.check_common  s   mmH//((C**FKK8tyy1,,dkk:!!#))Y7-(=>c55u=322A6a(!!-!!$"8"8%@t55q9 T--tww7T^^TWW5"">22		 32 MM$---MM$++s+	 322s   4JJ	c                    V P                  VP                  P                  VP                  4       V P	                  VP
                  P                  VP                  4       R # r?   )r   r5   r   r\   rE  r  r  rj   r  s   &&r;   check_direct!SinglephaseInitTests.check_direct<  s<    //=foo..>r=   c                    V P                  VP                  P                  VP                  4       V P	                  VP
                  P                  VP                  4       R # r?   )r  r5   r   r\   rE  r  r  )rj   r  origs   &&&r;   check_indirect#SinglephaseInitTests.check_indirectA  s>     	FMM22FKK@foo..>r=   c                   VP                   pV P                  VP                  R 4       V P                  VP                  \
        4       V P                  VP                  ^ 4       V P                  VP                  V4       R # r?   )r  r  r  r  r  intr  r   )rj   r  expected_init_countr  s   &&& r;   check_basic SinglephaseInitTests.check_basicH  s`     //6doos34??A.*=>r=   c                    R # r?   r}   r  s   &&r;   check_with_reinit&SinglephaseInitTests.check_with_reinitQ  s     	r=   c                    VP                   pV P                  VP                  ^4       V P                  VP                  P                  VP
                  4       R# )zE
The module had not been loaded before (at least since fully reset).
N)r  r   r  r5   r  r  )rj   r  r  s   && r;   check_fresh SinglephaseInitTests.check_freshV  sH     
 	!, 	88//	1r=   c                l   VP                   pV P                  VP                  VP                   P                  4       V P                  VP                  VP                   P                  4       V P                  VP                  VP                   P                  ^,           4       V P                  VP
                  P                  VP                  4       V P                  VP                  VP                   P                  4       V P                  VP                  VP                   P                  4       R# )zX
The module had been loaded before and then reset
(but the module global state wasn't).
Nr  r  rx   r   r  r5   r  r  )rj   r  rZ  prevr  s   &&&& r;   check_semi_fresh%SinglephaseInitTests.check_semi_freshe  s    
 
 	DGGT]]%5%56DGGT]]%5%56$--*B*BQ*FG 	88//	1D22 MM;;	=D22 MM;;	=r=   c                   VP                   pV P                  VP                  VP                   P                  4       V P                  VP                  VP                   P                  4       V P                  VP
                  P                  VP                  4       V P                  VP                  VP                   P                  4       R# )z4
The module had been loaded before and never reset.
Nr  )rj   r  rZ  r  s   &&& r;   check_copied!SinglephaseInitTests.check_copied{  s     
 	DGGT]]%5%56$--*B*BC 	88//	1//88	:r=   c                H   V P                  V P                  4      pVP                  pVP                  ! 4       pVP                  ! 4        VP                  ! 4       pVP
                  ! 4       pV P                  V^ 4       V P                  V^ 4       V P                  VR4       R# )r   Nr0  )r  r  r5   r  rc   r  r  r   )rj   r  ra   init_before
init_afterr  s   &     r;   test_cleared_globals)SinglephaseInitTests.test_cleared_globals  s    499%!==&88:'')%779
%779
;*Q'R(r=   c                >	   R V n         V P                  p^pV P                  V4      ;_uu_ 4        V P                  V4      pV P	                  V4       V P                  V4       V P                  W24       R R R 4       XP                  pV P                   R2pV P                  V4       V^,          pV P                  V4      ;_uu_ 4        V P                  V4      pV P	                  V4       V P                  W44       V P                  W24       V P                  VP                  4       VP                  4       V P                  VP                  4       V4       R R R 4       VP                  pV P                   R2pV P                  V4       V^,          pV P                  V4      ;_uu_ 4        V P                  V4      pV P	                  V4       V P                  V4       V P                  W24       V P                  VP                  4       V4       V P                  VP                  4       V4       R R R 4       V P                   R2pV P                  V4       V P                  V4      ;_uu_ 4        V P                  V4      pV P	                  V4       V P                  VP                  P                  R 4       V P                  V4       V P!                  V4       V P                  VP                  4       V4       V P                  VP                  4       V4       R R R 4       V P                   R2pV P                  V4       V P                  V4      ;_uu_ 4        V P                  V4      pV P#                  VP                  P$                  4       V P	                  V4       V P'                  VP                  P                  R 4       V P                  V4       V P!                  V4       V P                  VP                  4       V4       V P                  VP                  4       V4       R R R 4       R #   + '       g   i     EL; i  + '       g   i     EL; i  + '       g   i     EL8; i  + '       g   i     EL`; i  + '       g   i     R # ; i)N_basic_wrapper_basic_copy_with_reinit_with_state)maxDiffr  r  r  r  r  r  r5   r  r  rE  r  r   r  r  r  r  r  _clear_module_stater  )rj   r\   r  r  basicbasic_lookedups   &     r;   test_variants"SinglephaseInitTests.test_variants  s    yy\\$YYt_Ff%f%V9    ))N+%q \\$YYt_Ff%.V9 MM%,,.>U4468KL     ))K(%q \\$YYt_Ff%f%V9 MM%,,.?U4468KL   ))L)%\\$YYt_Ff%MM&//;;TBf%""6* MM%,,.?U4468KL   ))K(%\\$YYt_FOOFMM==>f%V__>>Ef%""6* MM%,,.?U4468KL      &       s@   AP;
BQ/BQ#5B+Q7!CR;Q	Q 	#Q4	7R	R	c                *   R V n         V P                  V P                   R2V P                   R23 EF  pV P                  V4       V P                  V4      ;_uu_ 4        V P	                  V4      pV P                  WP                  4      pV P                  V4       V P                  V4       V P                  \        VP                  P                  4      VP                  P                  4       V P                  VP                  P                  P                  VP                  P                  4       V P                  VP                  P                  P                  VP                  4       V P                  VP                  P                   VP                  P                  P                   4       V P#                  VP                  VP                  4       V P#                  VP                  P                  VP                  P                  4       V P#                  VP                  P$                  VP                  P$                  4       V P                  VP                  P&                  VP                  P&                  4       V P                  VP                  P(                  VP                  P(                  4       V P#                  VP                  P*                  VP                  4       R R R 4       EK  	  R #   + '       g   i     EK  ; i)Nr  r  )r  r  r  r  r  r  r5   r  r   rx   r   r  rz   ry   r/   r\   r   rE  r  r  r  r{   )rj   r\   r  r  s   &   r;   test_basic_reloaded(SinglephaseInitTests.test_basic_reloaded  s1     IIyyk(yyk%
D
 ##D)d##4<<mm<!!&)!!(+   FMM$:$:!;!'!6!68  !3!3!<!<!'!7!79   !9!9!>!>N  !9!9!)!2!2!5!5!>!>@ hoov}}=hoo668N8NO h//88$oo668  !2!2!D!D!'!B!BD  !2!2!=!=!'!;!;= h//66H; $#
 $##s   JL  Lc                   R V n         V P                  V P                  4      pV P                   R2R3V P                   R2R33 EF   w  r#V P                  V4       V P	                  W#R7      ;_uu_ 4        V P                  V4      pV'       d&   V P                  VP                  P                  4       V P                  W$P                  4      pV'       d&   V P                  VP                  P                  4       V P                  V4       V P                  V4       V P                  \        VP                  P                  4      VP                  P                  4       V P                  VP                  P                  P                  VP                  P                  4       V P                  VP                  P                   P"                  VP"                  4       V P                  VP                  P$                  VP                  P                  P$                  4       V P'                  VP                  VP                  4       V P)                  VP                  P                  VP                  P                  4       V P+                  VP                  P,                  VP                  4       VP                  P.                  f(   V P+                  VP                  P.                  R 4       M:V P1                  VP                  P.                  VP                  P.                  4       V P+                  VP                  P2                  VP                  4       R R R 4       EK#  	  R #   + '       g   i     EK9  ; i)Nr  Fr  T)r\   	has_state)r  r  r  r  r  r  r5   r  r  r  r   rx   r   r  rz   ry   r/   r\   r   r  r  rE  r  r  r  r{   )rj   r  r\   r  r  r  s   &     r;   test_with_reinit_reloaded.SinglephaseInitTests.test_with_reinit_reloaded  sz    		$))$ 		{,'/		{+&- 
OD ##D)4==4OOFMM$E$EF<<mm<OOHOO$G$GH!!&)!!(+   FMM$:$:!;!'!6!68  !3!3!<!<!'!7!79   !9!9!>!>N  !9!9!)!2!2!5!5!>!>@   &--@##HOO$<$<$*MM$:$:<h//88(//J??44<MM("3"3"E"EtL&&x'8'8'J'J'-'H'HJ h//66HA >= 

 >==s   6K'M,,M>rP  c                   R F  pV P                    V R2pV P                  V4      ;_uu_ 4        V P                  W P                  4      pV P	                  VP
                  V4       \        P                  P                  VR4       \        P                  ! W P                  4       RRR4       K  	  R#   + '       g   i     K  ; i)r   _check_cache_firstN)r   r  r  )r  r  r  r  r   r   rS   rT   rb   re   rf   )rj   variantr\   r   s   &   r;   test_check_state_first+SinglephaseInitTests.test_check_state_firstJ  s    :Gii[	);<Dd##(({{;  t4d+!11$D	 $# ;###s   A8B66Cc                   V P                  V P                  4      pVP                  pR Vn        V P	                  V4       V P                  V4       V P                  4       pV P                  4       pV P                  4       pV P	                  V4       V P                  WQ4       V P                  V4      pV P	                  V4       V P                  WQ4       V P                  V4      pV P	                  V4       V P                  WQ4       R# )z&spam, spam, spam, spam, eggs, and spamN)	r  r  r5   r  r  r  r  r  r  )rj   main_loadedra   	interpid1	interpid2r  s   &     r;   .test_basic_multiple_interpreters_main_no_resetCSinglephaseInitTests.test_basic_multiple_interpreters_main_no_resetZ  s     ii		*&-- H+&%++-	++-	 ))+&!&. )))4&!&. )))4&!&.r=   zArerun not possible; module state is never cleared (see gh-102251))reasonc                ~   \         '       d   \        P                  ! R 4      hV P                  4       pV P                  4       pV P	                  V P
                  4      pVP                  P                  4        \        P                  ! V P
                  V P                  4       V P                  RR7      pV P                  V4       V P                  V4       V P                  V4      pV P                  V4       V P                  WT4       V P                  V4      pV P                  V4       V P                  We4       R# )zcrashes on Py_TRACE_REFS buildsz
                # Attrs set after loading are not in m_copy.
                mod.spam = 'spam, spam, mash, spam, eggs, and spam'
                )r   N)r   r2   r3   r  r  r  r5   rc   re   rf   r  r  r  r  r  )rj   r  r  loaded_mainrZ  loaded_interp1loaded_interp2s   &      r;   1test_basic_multiple_interpreters_deleted_no_resetFSinglephaseInitTests.test_basic_multiple_interpreters_deleted_no_reset  s   
 = ##$EFF ++-	++-	 ii		*))+))$))T[[A '' ( 
 	$ 11)<.)./ 11)<.).9r=   c                   V P                  4       pV P                  4       pV P                  R RR7      pV P                  V4       V P                  V4       V P                  VRR7      pV P                  V4       V P                  V4       V P                  VRR7      pV P                  V4       V P                  V4       R# )z
            # Attrs set after loading are not in m_copy.
            mod.spam = 'spam, spam, mash, spam, eggs, and spam'
            T)r   r   )r   N)r  r  r  r  )rj   r  r  r  s   &   r;   +test_basic_multiple_interpreters_reset_each@SinglephaseInitTests.test_basic_multiple_interpreters_reset_each  s     ++-	++-	 ))  * 
 	&!  ))))F&!  ))))F&! r=   )r  r  r  r?   )&r   r   r   r   r  r   r  r   r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r	  r  r  r2   ro   re   r  rt   r  r   r"  r%  r   r   r   s   @r;   r  r  z
  s"     D 2 
< 
<"

."
'+"
(-"
L!,F?
??
1=,:,)RMh(IT,I\ __&$.0LME NE :/ :/F XYA:  ZA:T 0! 0!r=   r  c                   &   a  ] tR tRt o R tRtV tR# )TestMagicNumberi%  c                F   \         P                  P                  ^R4      pV P                  VR,          R4       \        P                  VR,          R4      pR\        P                  P                  ^2,          ,           pV P                  V\        W3^2,           4      4       R# )   littler  s   
:Nr=  NiT  N)r  pyc_magic_number_tokento_bytesr   r  
from_bytesrS   version_infominorr   r1  )rj   magic_number_bytesmagic_numberstarts   &   r;   test_magic_number_endianness,TestMagicNumber.test_magic_number_endianness'  sy    !88AA!XN+B/9~~&8&<hGs''--22lE%$<=r=   r}   N)r   r   r   r   r4  r   r   r   s   @r;   r(  r(  %  s     > >r=   r(  __main__)ir  rs  r  r   importlib.utilrN   importlib._bootstrap_externalr   importlib.machineryr   r   r   r   r   r  r   r2  r  r  ru  r  rS   r   r  r  r   r2   r	   r  rD  r
   r   r   r   r   r   r   r   r   r   r   r   r   r   r   test.support.import_helperr   r   r   r   r   r   r   r    test.support.os_helperr!   r"   r#   r$   r%   r&   test.test_importlib.utilr'   r(   ra   r   ra  rs   r   re   ro   dont_write_bytecoder=  r<   rA   rC   rE   rG   rK   rV   r^   rg   rq   rt   r   rv   TestCaser   rA  rh  r  r  r  r  r<  rR  rf  rw  r  r  r  r  r(  r   r  r}   r=   r;   <module>r?     sW        9   	      
        "    / / /4 4 & ) , 
 'oo46 
8AE A;e ;?4 ?4 46   *:  J=`(U** `(F  E)(## E)  E)P V/(++ V/ V/rVM)) VMr3 "" 3 l^:(++ ^:B(8#4#4 ((_!8$$ _!D+3H$5$5 +3\ <h// < <@ 6** 6 6Bm98,, m9`@(++ @Fc(8,, c(LHn HV `
!8,, `
! `
!T >h'' > > zMMO mg    O  M  sH   K K K( K8 	KK	K%$K%(	K54K58	LL