
    8\h85                     <   d dl Z d dlZd dlZd dlZd dlmZmZmZ d dlZd dl	Z	d dl
Z	d dlmZ d dlmZ d dlmZ d dlZd dlZd dlZd dlZ ej                    Zde_        de_        dej        v rde_        dej        vrde_        ej        rd ZnN ej                    adt6          _        dt6          _        dt6          _        dt6          _        d	t6          _         d
 Z e             d Z!d)dZ"d)dZ#d)dZ$dZ%ej&        dvrJe'(                                Z)e)e'k    re'*                                Z)e	j        +                    e)          sdZ% e!d          d         Z, e-e j.                   e-e,j.                  dZ.d Z/d*dZ0d Z1ej2        d             Z3ej2        d*ddd            Z4ej2        d             Z5 G d d          Z6 G d de6          Z7 G d  d!e6          Z8d" Z9d# Z:ej2        d$             Z;ej2        d%             Z<d& Z= G d' d(          Z>dS )+    N)	machineryutilinvalidate_caches)support)import_helper)	os_helpererrno	importlibc                  
    d a d S N)
EXTENSIONS     B/opt/python-3.11.14/usr/lib/python3.11/test/test_importlib/util.py_extension_detailsr      s    


r   	_testcapic                  F   t           j        D ]} t          j        D ]}t          j        |z   }t          j                            | |          }t          j                            |          r4| t          _        |t          _	        |t          _
        |t          _          d S d S r   )syspathr   EXTENSION_SUFFIXESr   nameosjoinexistsextfilename	file_path)r   r   r   r   s       r   r   r   *   s    H 		 		D 3  %?S0GLLx88	7>>),, &*JO%(JN*2J'+4J(FFF		 		r   c                 t    	 d| v rdnd}t          j        |           }t          j        | |d          }||dS )N.)r
   r   )_frozen_importlib_frozen_importlib_external)freshblockedFrozenSource)r   import_fresh_module)module_namer"   frozensources       r   import_importlibr+   :   sW    K![00NNbE.{;;F.{%1df f fF///r   c                 j   |t           j        }nt          |t                    s||         }d                    || j                  }| |f}t          j        ||          }| j        |_        | j        |_	        ||_
        |                                D ]\  }}||         }	t          |||	           |S )Nz{}_{})unittestTestCase
isinstancetypeformat__name__types	new_class
__module___NAME_KINDitemssetattr)
clskindbasekwargsr   basesspecializedattrvaluesvalues
             r   specialize_classrC   C   s     | d## Dz>>$--D$KE/$..K ^KKK * *ftT5))))r   c                 F    t          | d|fi |}t          | d|fi |}||fS )Nr%   r&   )rC   )r:   r<   r=   r)   r*   s        r   split_frozenrE   V   s>    c8T<<V<<Fc8T<<V<<F6>r   c                     t          | |fi |S r   )rE   )
test_classr<   r=   s      r   	test_bothrH   \   s    
D33F333r   T)win32cygwinFr&   r$   c                 L    	  t          j        t           d          |           S )Nz&requires a case-insensitive filesystem)r-   skipIfCASE_INSENSITIVE_FS)tests    r   case_insensitive_testsrO   o   s;    F8?22DF FFJL L Lr    c                     t           j                            ||dz             }t          |dd          5 }|                    |           d d d            n# 1 swxY w Y   d                    | |          |fS )N.pywutf-8encodingz{}.{})r   r   r   openwriter1   )parentr   pkg_dircontentr   subfiles         r   	submoduler]   v   s    7<<..D	dC'	*	*	* gg              >>&$''--s   AAAc                     	 t          | d          5 }|                    d           t          j        |          cd d d            S # 1 swxY w Y   d S )Nrb   )rW   seekmarshalload)pyc_pathpyc_fs     r   get_code_from_pycrf   }   s     
h		 #

2|E""# # # # # # # # # # # # # # # # # #s   )AAAc               '   >  K   	 | D ]F}|dv r"t          d                    |                    	 t          j        |= 7# t          $ r Y Cw xY w	 d V  | D ] }	 t          j        |= # t          $ r Y w xY wd S # | D ] }	 t          j        |= # t          $ r Y w xY ww xY w)N)r   rb   impzcannot uncache {0})
ValueErrorr1   r   modulesKeyError)namesr   s     r   uncacherm      s        ,,,$++D113 3 3	D!! 	 	 	D	 	 	DK%%   	 	E 	 	DK%%   	sQ   =
A
	A
A7 A%%
A21A27B=B
B
B	BB	B)pkgc          	   #      K    fdt           j        D             }t          j        d           5 }t	           g|R  5  t          j        |          5  t                       t          j	        
                    |           }|r5t          j	        
                    |d          }t          j                    n	|dz   }|d}|?t          |dd          5 }|                    |           d d d            n# 1 swxY w Y   |V  d d d            n# 1 swxY w Y   d d d            n# 1 swxY w Y   d d d            d S # 1 swxY w Y   d S )Nc                 R    g | ]#}|                     d           d         k    !|$S )r   r   )	partition).0nr   s     r   
<listcomp>ztemp_module.<locals>.<listcomp>   s4    GGGq1;;s+;+;A+>$+F+F+F+F+Fr   z__init__.pyrR   rP   rS   rT   rU   )r   rj   r   temp_cwdrm   r   DirsOnSysPathr   r   r   r   mkdirrW   rX   )r   r[   rn   	conflictscwdlocationmodpathmodfiles   `       r   temp_moduler}      sN     GGGGCKGGGI		D	!	! ST&I&&& 	 	,S11  !###7<<T22 % gll8]CCGHTNNNN&.G"$&gsW=== /g.../ / / / / / / / / / / / / / /!              	 	 	 	 	 	 	 	 	 	 	 	 	 	 	                 s}   ED*BDC8	,D8C<<D?C< DD*DD*DD*E*D.	.E1D.	2EE	Ec               +     K   	 i }	 dg fdg fdg fdi ffD ]E\  }}t          t          |          ||<   || v r| |         }| |= n|}t          t          ||           Ft          |           r4t	          d                    |                                                     d V  |                                D ]\  }}t          t          ||           d S # |                                D ]\  }}t          t          ||           w xY w)N	meta_pathr   
path_hookspath_importer_cachezunrecognized arguments: {0})getattrr   r9   lenri   r1   keysr8   )r=   	originalsr@   default	new_valuerB   s         r   import_stater      sP      I&*B/&"+R04b9; 		* 		*MD' &c400IdOv~~"4L	4LL#	Cy))))v;; 	I188GGI I I$??,, 	& 	&KD%Cu%%%%	& 	&9??,, 	& 	&KD%Cu%%%%	&s   BC 2Dc                   .    e Zd Z	 i ddZd Zd Zd ZdS )_ImporterMock)module_codec                   i | _         i | _        |D ]}|                    d          s|}n|d t          d                    }d|vrd }n%||k    r|                    dd          d         }n|}t          j        |          }| |_        d|_        ||_	        ||_
        ||k    rdg|_        || j         |<   ||v r||         | j        |<   d S )N	.__init__r      r   z<mock __file__>z<mock __path__>)rj   r   endswithr   rsplitr3   
ModuleType
__loader____file____package__r@   __path__)selfr   rl   r   import_namepackagemodules          r   __init__z_ImporterMock.__init__   s    	I 	ID==-- 7""#5S%5%5$5#56$$$++c1--a0%%k22F $F/FO!(FFKd""#4"5(.DL%k))0;K0H -)	I 	Ir   c                     | j         |         S r   rj   )r   r   s     r   __getitem__z_ImporterMock.__getitem__   s    |D!!r   c                     t          | j                                         | _        | j                                         | S r   )rm   rj   r   _uncache	__enter__)r   s    r   r   z_ImporterMock.__enter__   s5    !2!2!4!45!!!r   c                 >    | j                             d d d            d S r   )r   __exit__)r   exc_infos     r   r   z_ImporterMock.__exit__   s"    tT400000r   N)r2   r5   __qualname__r   r   r   r   r   r   r   r   r      se        :+- I I I I I2" " "  
1 1 1 1 1r   r   c                       e Zd Z	 ddZd ZdS )mock_modulesNc                     || j         vrd S | S r   r   )r   fullnamer   s      r   find_modulezmock_modules.find_module  s    4<''4Kr   c                     || j         vrt          | j         |         t          j         |<   || j        v r3	  | j        |                      n# t          $ r t          j         |=  w xY w| j         |         S r   )rj   ImportErrorr   r   	Exception)r   r   s     r   load_modulezmock_modules.load_module  s    4<''$(L$:CK!4+++.D$X.0000    H- <))s   A A$r   )r2   r5   r   r   r   r   r   r   r   r     s:        +   * * * * *r   r   c                   $    e Zd Z	 ddZd Zd ZdS )	mock_specNc           
          	 | j         |         }n# t          $ r Y d S w xY wt          j        ||j        | t          |dd                     }|S )Nr   )loadersubmodule_search_locations)rj   rk   r   spec_from_file_locationr   r   )r   r   r   rY   r   specs         r   	find_speczmock_spec.find_spec  sp    	\(+FF 	 	 	44	+&/$+26:t+L+LN N N s    
c                 P    |j         | j        vrt          | j        |j                  S r   )r   rj   r   )r   r   s     r   create_modulezmock_spec.create_module'  s&    9DL((|DI&&r   c                 h    	  | j         |j        j                              d S # t          $ r Y d S w xY wr   )r   __spec__r   rk   )r   r   s     r   exec_modulezmock_spec.exec_module,  sJ    	2DV_1244444 	 	 	DD	s   # 
11)NN)r2   r5   r   r   r   r   r   r   r   r   r     sI        +   ' ' '
    r   r   c                      	 t           j        r t          j        d                     S t	          j                    fd            }|S )Nzrelies on writing bytecodec                      t           j        }dt           _        	  | i |}|t           _        n# |t           _        w xY w|S )NF)r   dont_write_bytecode)argsr=   original	to_returnfxns       r   wrapperz&writes_bytecode_files.<locals>.wrapper8  sQ    *"'	/T,V,,I&.C##hC#....s   0 >)r   r   r-   skip	functoolswraps)r   r   s   ` r   writes_bytecode_filesr   3  sd    1
 @:x}9::3???_S     Nr   c                     	 	 t          j        t           j                            |                      d S # t          $ r!}|j        t
          j        k    r Y d }~d S d }~ww xY wr   )r   rw   r   dirnameOSErrorr	   EEXIST)bytecode_patherrors     r   ensure_bytecode_pathr   D  su    
//00000   ;%,&& '&&&&&s   16 
A! AA!c              #      K   	 t           j        }| t           _        	 d V  |t           _        d S # |t           _        w xY wr   )r   pycache_prefix)prefix_orig_prefixs     r   temporary_pycache_prefixr   P  sI      0%LC*)\))))s   / =c               '   ,  K   	 d}g }i }d }d }	 t          j                    }||d<   t                      }| D ]}|                    d          s|}	n|d t	          d                    }	|                    |	           |	t          j        v rt          j        |	= |                    d          }
|}|
d d         D ]j}t          j
                            ||          }t          j
                            |          s)t          j        |           |                    |           kt          j
                            ||
d         dz             }t          |dd	
          5 }|                    |                    |                     d d d            n# 1 swxY w Y   |                    |           |||<   t%          | }|                                 t)          |g          }|                                 |V  ||                    d d d            ||                    d d d            t-          j        |           d S # ||                    d d d            ||                    d d d            t-          j        |           w xY w)Nzattr = {0!r}z.rootr   r   r   rR   rS   rT   rU   )r   )tempfilemkdtempsetr   r   addr   rj   splitr   r   r   r   rw   appendrW   rX   r1   rm   r   r   r   r   rmtree)rl   r*   created_pathsmappingstate_manageruncache_managertemp_dirimport_namesr   r   
name_partsr   	directoryfiles                 r   create_modulesr   [  s      FMGMO"##%%#uu 	& 	&D==,, 7""#5S%5%5$5#56[)))ck))K,CJ I'_ 4 4	GLLI>>	w~~i00 4HY'''!((333Y
20FGGIiw777 04

6==..///0 0 0 0 0 0 0 0 0 0 0 0 0 0 0  +++%GDMM!<0!!###$8*555!!!$""4t444&$$T4666"""""	 $""4t444&$$T4666""""s2   EI !)F
I F	I F	A%I AJc                      	  fd}|S )Nc                     | vrt           S r   )r   )entryentriesimporters    r   hookzmock_path_hook.<locals>.hook  s    r   r   )r   r   r   s   `` r   mock_path_hookr     s,    &      Kr   c                       e Zd Zd ZdS )CASEOKTestBasec                x     d}t           fd|D                       |k    r                     d           d S d S )N)s   PYTHONCASEOKPYTHONCASEOKc              3   H   K   | ]}|j         j        j        j        v V  d S r   )r
   _bootstrap_external_osenviron)rr   xr   s     r   	<genexpr>z4CASEOKTestBase.caseok_env_changed.<locals>.<genexpr>  sG       , , DN6:BB , , , , , ,r   z/os.environ changes not reflected in _os.environ)anyskipTest)r   should_existpossibilitiess   `  r   caseok_env_changedz!CASEOKTestBase.caseok_env_changed  sk    7 , , , ,*, , , , ,/;< <MMKLLLLL< <r   N)r2   r5   r   r   r   r   r   r   r     s(        M M M M Mr   r   r   )rP   )?builtins
contextlibr	   r   r
   r   r   r   rb   r   os.pathrN   r   test.supportr   r   r-   r   r   r3   SimpleNamespaceBUILTINS	good_namebad_namebuiltin_module_namesis_wasir   r   r   r   r   r   r   r+   rC   rE   rH   rM   platformr   upperchanged_namelowerr   source_importlibstaticmethod
__import__rO   r]   rf   contextmanagerrm   r}   r   r   r   r   r   r   r   r   r   r   r   r   r   <module>r     s:             8 8 8 8 8 8 8 8 8 8  				        & & & & & & " " " " " "  



   !5 ""  
c&&& Hc...#H
? 
    '&((JJOJNJJ!JO       0 0 0   &   4 4 4 4   <***>>##Lx~~''7>>,'' $###K00: $X%899$%5%@AAC C
L L L. . . .# # #   2      . & & &<&1 &1 &1 &1 &1 &1 &1 &1R* * * * *= * * *0       4  "	 	 	 * * * 6# 6# 6#r  M M M M M M M M M Mr   