
    <ecX                        d dl Zd dlZd dlZd dlZd dlZd dlZd dlZd dlZd dl	Z	d dl
Z
ej        dk    rdZndZd                    e ej                              Zedz   Zej        dk    rd dlZ ej        de          ZdZej        d	k    rn ej                    j        d
k    rUedz   Z	 e                     ej                                eded ej                    d           dZnj# e$ r Y ncw xY wn^ej        dvrU	 d                     ej                               n1# e$ r) ed                     ej                    d          z   ZY nw xY wdZdD ]6Z	  ej         ej        e                    ek    re	 eZ n# e$ r Y 3w xY w ej                     Z!dZ"dD ]DZ	 e                     ej                               &# e$ r  ej        e          ez   Z"Y  nw xY wereez   Z#ndZ#e#peZ$d Z%da&d Z'd Z(da)d Z*d Z+da,d Z-d Z.da/d Z0d Z1d Z2d  Z3ej        4                    d!          rd;d#Z5d$ Z6d% Z7d& Z8d' Z9nej3        Z6ej:        Z7d( Z8d) Z9d* Z:d+ Z;ej<        d<d,            Z=ej<        d;d-            Z>ej<        d=d/            Z?d0 Z@ej<        d1             ZAd2 ZB G d3 d4          ZCd5 ZD eEed6          rej<        d7             ZFnej<        d8             ZF G d9 d:ejG        jH                  ZIdS )>    Njavaz$testz@testz	{}_{}_tmpu   -àòɘŁğdarwinNFDnt   u   -共Ł♡ͣzWARNING: The filename z, CAN be encoded by the filesystem encoding (z.). Unicode filename tests may not be effective>   wasir   
emscripten   s   -surrogateescape )   æu   İu   Łu   φu   Кu   אu   ،u   تu   ก    u   €)s   wr
   s   s   s   c                     	 t          t          d          } 	 |                                 |                                  t	          t                     S # |                                  t	          t                     w xY w)Nwb)openTESTFNfilenocloseunlinkfiles    -/usr/lib/python3.11/test/support/os_helper.pymake_bad_fdr      sb     D{{}}

v 	

vs   A *A>c                     t           t           S t          j                            t                    } | dz   }	 t          j        | |           d}t          j        |           n# t          t          t          f$ r d}Y nw xY w|a |S )Ncan_symlinkTF)
_can_symlinkospathabspathr   symlinkremoveOSErrorNotImplementedErrorAttributeError)srcsymlink_pathcans      r   r   r      s     '//&
!
!C&L 

3%%% 		, (.9    LJs   A% %B Bc                 f    	 t                      }d}|r| n t          j        |          |           S )Nz*Requires functional symlink implementation)r   unittestskiptestokmsgs      r   skip_unless_symlinkr/      s7    B	B
6C344-8=--d333    c                  h   dd l } t          t          S t          t          d          sd}ndd l}|                                 }|                     |          \  }}	 t          t          d          5 }	 t          j	        |dd           t          j	        |dd	           t          j	        |
                                dd           |                                }t          j        d
|          }|d u p%t          |                    d                    dk    }n# t           $ r d}Y nw xY wd d d            n# 1 swxY w Y   t#          t                     t#          |           t%          |           n7# t#          t                     t#          |           t%          |           w xY w|a|S )Nr   setxattrFdirr   s	   user.testr0   s   trusted.foos   42z2.6.(\d{1,2})   '   )tempfile
_can_xattrhasattrr   platformmkdtempmkstempr   r   r2   r   releaserematchintgroupr"   r   rmdir)	r7   r'   r:   tmp_dirtmp_fptmp_namefpkernel_versionms	            r   	can_xattrrI      s   OOO2z"" ""$$#+++88	fd##  r  Kc:::K.%@@@K		\3???%-%5%5%7%7N!1>BBAt)<s1771::"'<CC      CCC                               6NNN8'NNNN 6NNN8'NNNNJJsU   E9 3D;5B'DD;D,)D;+D,,D;/E9 ;D??E9 D?E9 94F-c                 f    	 t                      }d}|r| n t          j        |          |           S )Nz(no non-broken extended attribute support)rI   r)   r*   r+   s      r   skip_unless_xattrrK      s7    N	B
4C344-8=--d333r0   c                     t           t           S t          t          d          s	da t           S 	 t          t          d          5 } 	 t          j        t          d           t          j        t                    j        }t          j        t          d           t          j        t                    j        }t          j        |          t          j        |          k    }n# t          $ r}d}Y d }~nd }~ww xY wd d d            n# 1 swxY w Y   t          t                     n# t          t                     w xY w|a |S )NchownFr   i  i  )
_can_chmodr9   r   r   r   chmodstatst_modeS_IMODEr"   r   )fmode1mode2r'   es        r   	can_chmodrW      sg   2w 
&$ 		A1A'''/'''/ l5))T\%-@-@@    		A 		A 		A 		A 		A 		A 		A 		A 		A 		A 		A 		A 		A 		A 		A 	vvJJsZ   D% DA0C 5+D 
C6*C1,D1C66D9D% D		D% D	D% %D;c                 f    	 t                      }d}|r| n t          j        |          |           S )Nzrequires working os.chmod())rW   r)   r*   r+   s      r   skip_unless_working_chmodrY   
  s;     
B
'C344-8=--d333r0   c                     t                      sdat          t          S 	 t          t          d          5 } t	          j        t          d           	 t          t          d          5  	 d d d            n# 1 swxY w Y   dan# t          $ r daY nw xY wd d d            n# 1 swxY w Y   t          t                     n# t          t                     w xY wt          S )NFr      T)rW   _can_dac_overrider   r   r   rO   r"   r   )rS   s    r   can_dac_overrider]     sa    ;; "!$  &$ 	)1HVU###)&$''                
 %)!!  * * *$)!!!*	) 	) 	) 	) 	) 	) 	) 	) 	) 	) 	) 	) 	) 	) 	) 	vvsv   C  B B&A4(B4A8	8B;A8	<B?B BB BB C   B$$C  'B$(C   Cc                 f    t                       }d}|r| n t          j        |          |           S )Nz"incompatible with CAP_DAC_OVERRIDEr]   r)   r*   r+   s      r   skip_if_dac_overrider`   2  s9    	B
.C344-8=--d333r0   c                 d    t                      }d}|r| n t          j        |          |           S )Nzrequires CAP_DAC_OVERRIDEr_   r+   s      r   skip_unless_dac_overriderb   8  s6    			B
%C344-8=--d333r0   c                 V    	 t          |            d S # t          t          f$ r Y d S w xY wN)_unlinkFileNotFoundErrorNotADirectoryErrorfilenames    r   r   r   >  sC    12   s    ((winFc                 <    | |           |r|}n&t           j                            |          \  }}|pd}d}|dk     r>t          j        |          }|r|sn||v sd S t	          j        |           |dz  }|dk     >t          j        d|z   t          d           d S )N.gMbP?g      ?r   z)tests may fail, delete still pending for    
stacklevel)	r   r   splitlistdirtimesleepwarningswarnRuntimeWarning)funcpathnamewaitalldirnamenametimeoutLs          r   _waitforr~   F  s    X 	%GGGMM(33MGTnG mm 
7##A  A  daiiJwqLG mm 	AHL$	4 	4 	4 	4 	4 	4r0   c                 :    t          t          j        |            d S rd   )r~   r   r   rh   s    r   re   re   g  s    H%%%%%r0   c                 :    t          t          j        |            d S rd   )r~   r   rB   rz   s    r   _rmdirr   j  s    7#####r0   c                 l    ddl m fdt          | d           t          fd|            d S )Nr   
_force_runc                     | t           j        |           D ]}t           j                            | |          }	 t          j        |          j        }n:# t          $ r-}t          d|d|t          j	                   d}Y d }~nd }~ww xY wt          j        |          r*t          |d            |t           j        |            |t           j        |           d S )Nzsupport.rmtree(): os.lstat(z) failed with r   r   Try   )r   rq   r   joinlstatrQ   r"   printsys
__stderr__rP   S_ISDIRr~   rB   r   )r   r{   fullnamemodeexcr   _rmtree_inners        r   r   z_rmtree.<locals>._rmtree_innerp  s   "
4T:: > >7<<d338H--5DD   E%XXss,"~/ / / / DDDDDD	
 <%% >]HdCCCCJx8<<<<JxH====> >s   A
B #BBTr   c                 2     | t           j        |           S rd   )r   rB   )pr   s    r   <lambda>z_rmtree.<locals>.<lambda>  s    ::a155 r0   )test.supportr   r~   )r   r   r   s    @@r   _rmtreer   m  sk    ++++++	> 	> 	> 	> 	> 	> 	d33335555t<<<<<r0   c                     	 dd l }|                    t          |           dz            }|j        j                            | |t          |                    }|r
|d |         S n# t          $ r Y nw xY w| S )Nr   r   )ctypescreate_unicode_bufferlenwindllkernel32GetLongPathNameWImportError)r   r   bufferlengths       r   	_longpathr     s    
	'MMM
 11#d))a-@@F]+<<T6=@[[J JF 'gvg&'  	 	 	D	 s   A& &
A32A3c                     dd l }	 |                    |            d S # t          $ r Y nw xY wfd |            t          j        |            d S )Nr   c                 ~   ddl m}  || t          j        |           D ]}t          j                            | |          }	 t          j        |          j        }n# t          $ r d}Y nw xY wt          j
        |          r# |            || t          j        |            || t          j        |           d S )Nr   r   )r   r   r   rq   r   r   r   rQ   r"   rP   r   rB   r   )r   r   r{   r   r   r   s        r   r   z_rmtree.<locals>._rmtree_inner  s    //////"
4T:: 
: 
:7<<d338H--5DD   DDD<%% :!M(+++JtRXx8888JtRY9999
: 
:s   AA+*A+)shutilrmtreer"   r   rB   )r   r   r   s     @r   r   r     s    	MM$F 	 	 	D		: 	: 	: 	: 	: 	d
s    
++c                     | S rd    r   s    r   r   r         r0   c                 H    	 t          |            d S # t          $ r Y d S w xY wrd   )r   rf   r   s    r   rB   rB     s8    w       
!!c                 H    	 t          |            d S # t          $ r Y d S w xY wrd   )r   rf   r   s    r   r   r     s8       r   c              #     K   	 dd l }d}| 6|                                } d}t          j                            |           } nT	 t          j        |            d}n<# t          $ r/}|s t          j        d| d| t          d           Y d }~nd }~ww xY w|rt          j
                    }	 | V  |r(|t          j
                    k    rt          |            d S d S d S # |r'|t          j
                    k    rt          |            w w w xY w)Nr   FTz5tests may fail, unable to create temporary directory :    rn   )r7   r;   r   r   realpathmkdirr"   rt   ru   rv   getpidr   )r   quietr7   dir_createdr   pids         r   temp_dirr     sw      OOOK|!!w%%	8HTNNNKK 	8 	8 	8 M A15A A;>A A(Q8 8 8 8 8 8 8 8 8	8  ikk


  	3")++--4LLLLL	 	--; 	3")++--4LLLL	-s$   A 
B$%BB,C ,D
c              #     K   	 t          j                    }	 t          j        t           j                            |                      n<# t
          $ r/}|s t          j        d| d| t          d           Y d }~nd }~ww xY w	 t          j                    V  t          j        |           d S # t          j        |           w xY w)NzBtests may fail, unable to change the current working directory to r   r   rn   )	r   getcwdchdirr   r   r"   rt   ru   rv   )r   r   	saved_dirr   s       r   
change_cwdr     s     
 	I4
!!$''(((( 4 4 4 	 6&*6 6036 6$	4 	4 	4 	4 	4 	4 	4 	4 	44ikk
s#   1A
 

B%A>>BB2 2Ctempcwdc              #      K   	 t          | |          5 }t          ||          5 }|V  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 )N)r   r   )r   )r   r   )r{   r   	temp_pathcwd_dirs       r   temp_cwdr     s       
t5	)	)	) Y	/// 	7MMM	 	 	 	 	 	 	 	 	 	 	 	 	 	 	                 s-   A8A<	A<	 AAAc                     	 t          j        | t           j        t           j        z  t           j        z            }t          j        |           d S rd   )r   r   O_WRONLYO_CREATO_TRUNCr   )ri   fds     r   create_empty_filer     s7    H	2;3bj@	A	ABHRLLLLLr0   c              #      K   	 t           j        }t          t           d          r|t           j        z  }t          j        | |          }	 |V  t          j        |           d S # t          j        |           w xY w)NO_DIRECTORY)r   O_RDONLYr9   r   r   r   )r   flagsdir_fds      r   open_dir_fdr     sy      0KEr=!!  WT5!!F
s   
A$ $A:c                 P   	 dd l }|                    |           5 }|j        }|                                }||k    r|                                }	 t
          j                            ||          cd d d            S # t          $ r Y d d d            dS w xY w# 1 swxY w Y   d S )Nr   r3   F)	r7   NamedTemporaryFiler{   upperlowerr   r   samefilerf   )	directoryr7   base	base_path	case_paths        r   fs_is_case_insensitiver   *  s   OOO		$	$	$	3	3 tI	OO%%		!!!))I	7##Iy99        ! 	 	 	       	         s/   6BA??
B	BBBB"Bc                   "    e Zd Z	 d Zd Zd ZdS )FakePathc                     || _         d S rd   r   )selfr   s     r   __init__zFakePath.__init__<  s    			r0   c                     d| j         dS )Nz
<FakePath >r   r   s    r   __repr__zFakePath.__repr__?  s    *DI****r0   c                     t          | j        t                    s4t          | j        t                    r!t	          | j        t                    r| j        | j        S rd   )
isinstancer   BaseExceptiontype
issubclassr   s    r   
__fspath__zFakePath.__fspath__B  sO    ty-00 	ty$''	49m44	 )O9r0   N)__name__
__module____qualname__r   r   r   r   r0   r   r   r   9  sF          + + +    r0   r   c                     	 t           j                            d          r7	 t          j        d          } t          |           dz
  S # t          $ r Y nw xY wd}t          t          d          r&	 t          j        d          }n# t          $ r Y nw xY wd }t           j        dk    rV	 dd l
}|j         i }|j        |j        |j        fD ]}|                    |d          ||<   n# t          t           f$ r Y nw xY w	 d}t#          |          D ]]}	 t          j        |          }t          j        |           |dz  }1# t          $ r }|j        t(          j        k    r Y d }~Vd }~ww xY w	 |3|j        |j        |j        fD ]}|                    |||                    n;# |3|j        |j        |j        fD ]}|                    |||                    w w xY w|S )	N)linuxfreebsdr	   z/proc/self/fdr5   r[   sysconfSC_OPEN_MAXwin32r   )r   r:   
startswithr   rq   r   rf   r9   r   r"   msvcrtCrtSetReportModeCRT_WARN	CRT_ERROR
CRT_ASSERTr$   r   rangedupr   errnoEBADF)	namesMAXFD	old_modesr   report_typecountr   fd2rV   s	            r   fd_countr   K  s   
|ABB 	J//E u::>!  	 	 	D	 Er9 	J}--EE 	 	 	D	 I
|w	DMMM##
 I & & 0 & 1 3 D D *0)@)@AB*D *D	+&&D , 	 	 	D	M,, 
	 
	B	 fRjj
 
    7ek)) *))))
	   & & 0 & 1 3 M M ''Y{5KLLLL	   & & 0 & 1 3 M M ''Y{5KLLLL	 !M
 Lsk   %A 
AA0B 
BB(C& &C:9C:>F$ E &F$  
E*
E% F$ %E**F$ $8Gumaskc              #      K   	 t          j        |           }	 d V  t          j        |           d S # t          j        |           w xY wrd   )r   r   )r   oldmasks     r   
temp_umaskr    sP      F(5//	EEEHWBHWs	   3 A	c              #      K   	 d V  d S rd   r   )r   s    r   r  r    s      0r0   c                   X    e Zd Z	 d Zd Zd Zd Zd Zd Zd Z	d Z
d	 Zd
 Zd Zd ZdS )EnvironmentVarGuardc                 6    t           j        | _        i | _        d S rd   )r   environ_environ_changedr   s    r   r   zEnvironmentVarGuard.__init__  s    
r0   c                     | j         |         S rd   )r	  r   envvars     r   __getitem__zEnvironmentVarGuard.__getitem__  s    }V$$r0   c                 p    || j         vr"| j                            |          | j         |<   || j        |<   d S rd   r
  r	  getr   r  values      r   __setitem__zEnvironmentVarGuard.__setitem__  s=    &&$(M$5$5f$=$=DM&! %fr0   c                     || j         vr"| j                            |          | j         |<   || j        v r
| j        |= d S d S rd   r  r  s     r   __delitem__zEnvironmentVarGuard.__delitem__  sP    &&$(M$5$5f$=$=DM&!T]""f%%% #"r0   c                 4    | j                                         S rd   )r	  keysr   s    r   r  zEnvironmentVarGuard.keys  s    }!!###r0   c                 *    t          | j                  S rd   )iterr	  r   s    r   __iter__zEnvironmentVarGuard.__iter__  s    DM"""r0   c                 *    t          | j                  S rd   )r   r	  r   s    r   __len__zEnvironmentVarGuard.__len__  s    4=!!!r0   c                     || |<   d S rd   r   r  s      r   setzEnvironmentVarGuard.set  s    Vr0   c                     | |= d S rd   r   r  s     r   unsetzEnvironmentVarGuard.unset  s    LLLr0   c                      t          |           S rd   )dictr   s    r   copyzEnvironmentVarGuard.copy  s    Dzzr0   c                     | S rd   r   r   s    r   	__enter__zEnvironmentVarGuard.__enter__  r   r0   c                     | j                                         D ]#\  }}||| j        v r| j        |= || j        |<   $| j        t          _        d S rd   )r
  itemsr	  r   r  )r   
ignore_exckvs       r   __exit__zEnvironmentVarGuard.__exit__  s\    m))++ 	% 	%FQy%%a(#$a  ]


r0   N)r   r   r   r   r  r  r  r  r  r  r  r!  r$  r&  r,  r   r0   r   r  r    s          % % %& & && & &$ $ $# # #" " "        # # # # #r0   r  )F)NF)r   F)Jcollections.abccollections
contextlibr   r   r>   rP   r   rr   r)   rt   r{   TESTFN_ASCIIformatr   TESTFN_UNICODEr:   unicodedata	normalizeTESTFN_UNENCODABLEgetwindowsversionencodegetfilesystemencodingr   UnicodeEncodeErrordecodeUnicodeDecodeErrorFS_NONASCII	characterfsdecodefsencodeUnicodeErrorr   SAVEDCWDTESTFN_UNDECODABLETESTFN_NONASCIIr   r   r   r   r/   r8   rI   rK   rN   rW   rY   r\   r]   r`   rb   r   r   r~   re   r   r   r   rB   r   contextmanagerr   r   r   r   r   r   r   r   r9   r  abcMutableMappingr  r   r0   r   <module>rG     sM            				 				  



    7fLLL !!,		<<  ==<8 *[*5.AAN
  7d??s'1,, *,MM	&%%&?c&?&A&ABBB EE''')B)B)D)D)D)DF G G G "& " 	 	 	D	 - 	\999
0s022333 	  N N N)oo7c799;LMMNN   + +IB
 2;{r{9--..);; <
  	     29;;    D"-C-//0000   (R[66=  "[0OOO		(L
 
 
   (4 4 4 
  B4 4 4 
  04 4 4    04 4 44 4 4   <5!! g4 4 4 4B& & &$ $ $= = =*    iGXF  0       % % % %P    6    &   
 
 
         $9 9 9x 72w       
6# 6# 6# 6# 6#+/8 6# 6# 6# 6# 6#sH   ,"C0 0C87C8"D) )+EE!$F

FF+"GG*)G*