hcXddlZddlZddlZddlZddlZddlZddlZddlZddl Z ddl Z ej dkrdZ ndZ d e ejZ e dzZejdkrddlZejdeZdZej d krnejjd krUe d zZ eejed ed ejddZnj#e$rYncwxYwn^ejdvrU dejn1#e$r)e dejdzZYnwxYwdZdD]6Z ejejeekre eZn #e$rY3wxYwej Z!dZ"dD]DZ e ej&#e$reje e zZ"YnwxYwere ezZ#ndZ#e#pe Z$dZ%da&dZ'dZ(da)dZ*dZ+da,dZ-dZ.da/dZ0dZ1dZ2d Z3ej4d!rd;d#Z5d$Z6d%Z7d&Z8d'Z9nej3Z6ej:Z7d(Z8d)Z9d*Z:d+Z;ej<dej<d=d/Z?d0Z@ej<d1ZAd2ZBGd3d4ZCd5ZDeEed6rej<d7ZFnej<d8ZFGd9d:ejGjHZIdS)>Njavaz$testz@testz {}_{}_tmpu -àòɘŁğdarwinNFDntu-共Ł♡ͣzWARNING: The filename z, CAN be encoded by the filesystem encoding (z.). Unicode filename tests may not be effective>wasir emscriptens-surrogateescape) æuİuŁuφuКuאu،uتuก u€)swr ssscttd} ||t tS#|t twxYw)z` Create an invalid file descriptor by opening and closing a file and return its fd. wb)openTESTFNfilenocloseunlinkfiles -/usr/lib/python3.11/test/support/os_helper.py make_bad_fdrs]   D{{}} v vs A*A=cttStjt}|dz} tj||d}tj|n#tttf$rd}YnwxYw|a|S)N can_symlinkTF) _can_symlinkospathabspathrsymlinkremoveOSErrorNotImplementedErrorAttributeError)src symlink_pathcans rrrs '//& ! !C&L  3 %%% , (. 9L JsA%%BBcdt}d}|r|ntj||S)z8Skip decorator for tests that require functional symlinkz*Requires functional symlink implementation)runittestskiptestokmsgs rskip_unless_symlinkr/s4 B 6C 344-8=--d333chddl}ttSttdsd}nddl}|}||\}} ttd5} tj |ddtj |dd tj | dd| }tj d |}|dup%t|d d k}n#t $rd}YnwxYwdddn #1swxYwYt#tt#|t%|n7#t#tt#|t%|wxYw|a|S) NrsetxattrFdirrs user.testr0s trusted.foos42z 2.6.(\d{1,2})')tempfile _can_xattrhasattrrplatformmkdtempmkstemprrr2rreleaserematchintgroupr"rrmdir) r7r'r:tmp_dirtmp_fptmp_namefpkernel_versionms r can_xattrrIsOOO 2z " """$$#+++88 fd## r  K c:::K.%@@@K \3???%-%5%5%7%7N!1>BBAt)sC  1 2     s ((winFc<|||r|}n&tj|\}}|pd}d}|dkr>tj|}|r|sn||vsdSt j||dz}|dk>t jd|ztddS)N.gMbP?g?rz)tests may fail, delete still pending for  stacklevel) rrsplitlistdirtimesleepwarningswarnRuntimeWarning)funcpathnamewaitalldirnamenametimeoutLs r_waitforr~Fs X  %GGGMM(33MGTnGmm 7##A  A  daii Jw    qLGmm  AHL$ 4 4 4 4 4 4r0c:ttj|dSrd)r~rrrhs rreregsH%%%%%r0c:ttj|dSrd)r~rrBrzs r_rmdirrjs7#####r0clddlmfdt|dtfd|dS)Nr _force_runc|tj|D]}tj||} tj|j}n:#t $r-}td|d|tj d}Yd}~nd}~wwxYwtj |r*t|d|tj ||tj|dS)Nzsupport.rmtree(): os.lstat(z) failed with rrTry)rrqrjoinlstatrQr"printsys __stderr__rPS_ISDIRr~rBr)rr{fullnamemodeexcr _rmtree_inners rrz_rmtree.._rmtree_innerps" 4T:: > >7<<d338H--5DDE%XXss,"~////DDDDDD  <%%>]HdCCCCJx8<<<<JxH==== > >sA B  #BB Trc2|tj|Srd)rrB)prs rz_rmtree..s::a155r0) test.supportrr~)rrrs @@r_rmtreermsk++++++ > > > > > > d33335555t<<<<._rmtree_inners / / / / / /" 4T:: : :7<<d338H--5DDDDD<%%:!M(+++JtRXx8888JtRY9999 : :sA A+*A+)shutilrmtreer"rrB)rrrs @rrrs   MM$    F    D  : : : : :  d s  ++c|Srdrs rrr r0cH t|dS#t$rYdSwxYwrd)rrfrs rrBrBs8 w       !!cH t|dS#t$rYdSwxYwrd)rrfrs rrrs8       rc#Kddl}d}|6|}d}tj|}nT tj|d}n<#t $r/}|stjd|d|tdYd}~nd}~wwxYw|rtj } |V|r(|tj krt|dSdSdS#|r'|tj krt|wwwxYw) aReturn a context manager that creates a temporary directory. Arguments: path: the directory to create temporarily. If omitted or None, defaults to creating a temporary directory using tempfile.mkdtemp. quiet: if False (the default), the context manager raises an exception on error. Otherwise, if the path is specified and cannot be created, only a warning is issued. rNFTz5tests may fail, unable to create temporary directory : rn) r7r;rrrealpathmkdirr"rtrurvgetpidr)rquietr7 dir_createdrpids rtemp_dirrsrOOOK |!! w%% 8 HTNNNKK 8 8 8  MA15AA;>AA(Q 8 8 8 8 8 8 8 8 8 8 ikk   3")++-- 4LLLLL  --; 3")++-- 4LLLL -s$A B#%B  B+C,D c#Ktj} tjtj|n<#t $r/}|st jd|d|tdYd}~nd}~wwxYw tjVtj|dS#tj|wxYw)agReturn a context manager that changes the current working directory. Arguments: path: the directory to use as the temporary current working directory. quiet: if False (the default), the context manager raises an exception on error. Otherwise, it issues only a warning and keeps the current working directory the same. zBtests may fail, unable to change the current working directory to rrrnN) rgetcwdchdirrrr"rtrurv)rr saved_dirrs r change_cwdrs I4 !!$''(((( 444   6&*660366$ 4 4 4 4 4 4 4 4 44 ikk s#1A B%A==BB11Ctempcwdc#Kt||5}t||5}|Vdddn #1swxYwYddddS#1swxYwYdS)a Context manager that temporarily creates and changes the CWD. The function temporarily changes the current working directory after creating a temporary directory in the current directory with name *name*. If *name* is None, the temporary directory is created using tempfile.mkdtemp. If *quiet* is False (default) and it is not possible to create or change the CWD, an error is raised. If *quiet* is True, only a warning is raised and the original CWD is used. )rr)rN)rr)r{r temp_pathcwd_dirs rtemp_cwdrs t5 ) ) )Y   / / / 7MMM               s,A7 A; A; AAActj|tjtjztjz}tj|dS)z>Create an empty file. If the file already exists, truncate it.N)rrO_WRONLYO_CREATO_TRUNCr)rifds rcreate_empty_filers4 2;3bj@ A ABHRLLLLLr0c#:Ktj|sJtj}t tdr|tjz}tj||} |Vtj|dS#tj|wxYw)z&Open a file descriptor to a directory. O_DIRECTORYN)rrisdirO_RDONLYr9rrr)rflagsdir_fds r open_dir_fdrs 7==   KEr=!!   WT5 ! !F  s *BBcNddl}||5}|j}|}||kr|} t j||cdddS#t$rYddddSwxYw#1swxYwYdS)zODetects if the file system for the specified directory is case-insensitive.rNr3F) r7NamedTemporaryFiler{upperlowerrrsamefilerf) directoryr7base base_path case_paths rfs_is_case_insensitiver*sOOO  $ $ $ 3 3tI OO%%  ! !!))I 7##Iy99 !    s/6BA>> BBBBB!Bc$eZdZdZdZdZdZdS)FakePathz.Simple implementing of the path protocol. c||_dSrdr)selfrs r__init__zFakePath.__init__<s  r0cd|jdS)Nz rrs r__repr__zFakePath.__repr__?s*DI****r0ct|jts4t|jtr!t |jtr|j|jSrd) isinstancer BaseExceptiontype issubclassrs r __fspath__zFakePath.__fspath__BsO ty- 0 0  ty$ ' ' 49m44 )O9 r0N)__name__ __module__ __qualname____doc__rrrrr0rrr9sK+++r0rctjdr7 tjd}t |dz S#t $rYnwxYwd}ttdr& tjd}n#t$rYnwxYwd}tjdkrV d dl }|j i}|j |j |jfD]}| |d ||<n#tt f$rYnwxYw d }t#|D]]} tj|}tj||dz }1#t$r }|jt(jkrYd}~Vd}~wwxYw |3|j |j |jfD]}| |||n;#|3|j |j |jfD]}| |||wwxYw|S) z/Count the number of open file descriptors. )linuxfreebsdr z /proc/self/fdr5r[sysconf SC_OPEN_MAXNwin32r)rr: startswithrrqrrfr9rr"msvcrtCrtSetReportModeCRT_WARN CRT_ERROR CRT_ASSERTr$rrangeduprerrnoEBADF) namesMAXFD old_modesr report_typecountrfd2rVs rfd_countrKs |ABB J//Eu::> !     D  Er9 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{5KLLLL  & & 0 & 1 3 M M '' Y{5KLLLL ! M Lsk%A AA/B BB' C%%C98C9=F#D?%F#? E) E$F#$E))F##8Gumaskc#Ktj|} dVtj|dS#tj|wxYw)z8Context manager that temporarily sets the process umask.N)rr)roldmasks r temp_umaskrsO(5//  EEE HW     BHW    s 2Ac#KdVdS)z"no-op on platforms without umask()Nr)rs rrrs r0cZeZdZdZdZdZdZdZdZdZ dZ d Z d Z d Z d Zd ZdS)EnvironmentVarGuardz_Class to help protect the environment variable properly. Can be used as a context manager.c6tj|_i|_dSrd)renviron_environ_changedrs rrzEnvironmentVarGuard.__init__s   r0c|j|Srd)r renvvars r __getitem__zEnvironmentVarGuard.__getitem__s}V$$r0cp||jvr"|j||j|<||j|<dSrdr r getrrvalues r __setitem__zEnvironmentVarGuard.__setitem__s=  & &$(M$5$5f$=$=DM& ! % fr0c||jvr"|j||j|<||jvr |j|=dSdSrdrrs r __delitem__zEnvironmentVarGuard.__delitem__sP  & &$(M$5$5f$=$=DM& ! T] " " f%%% # "r0c4|jSrd)r keysrs rrzEnvironmentVarGuard.keyss}!!###r0c*t|jSrd)iterr rs r__iter__zEnvironmentVarGuard.__iter__sDM"""r0c*t|jSrd)rr rs r__len__zEnvironmentVarGuard.__len__s4=!!!r0c|||<dSrdrrs rsetzEnvironmentVarGuard.setsV r0c ||=dSrdrrs runsetzEnvironmentVarGuard.unsets LLLr0c t|Srd)dictrs rcopyzEnvironmentVarGuard.copysDzzr0c|Srdrrs r __enter__zEnvironmentVarGuard.__enter__rr0c|jD]#\}}|||jvr|j|=||j|<$|jt_dSrd)r itemsr rr )r ignore_exckvs r__exit__zEnvironmentVarGuard.__exit__s\m))++ % %FQy %% a(#$ a  ] r0N)rrrrrrrrrrrr!r#r&r(r.rr0rrrs%%%&&& &&&$$$###"""#####r0r)F)NF)rF)Jcollections.abc collections contextlibrrr>rPrrrr)rtr{ TESTFN_ASCIIformatrTESTFN_UNICODEr: unicodedata normalizeTESTFN_UNENCODABLEgetwindowsversionencodegetfilesystemencodingrUnicodeEncodeErrordecodeUnicodeDecodeError FS_NONASCII characterfsdecodefsencode UnicodeErrorrSAVEDCWDTESTFN_UNDECODABLETESTFN_NONASCIIrrrrr/r8rIrKrNrWrYr\r]r`rbrrr~rerrrrBrcontextmanagerrrrrrrrrr9rabcMutableMappingrrr0rrIsM 7fLLL!!,  <<  ==<8*[*5.AAN 7d??s'1,,*,MM &  % %&?c&?&A&A B B B EE''')B)B)D)D)D)DF G G G"&   "    D  - \999  0s022333  NNN)oo7c799;LMMNN  ++IB  2;{r{9-- . .) ; ;  <          29;; D" -C-//0000 (R[66= "[0OOO  (L    (444 B444 04440444 444    <5!!g4444B&&&$$$===*    iG XF0       %%%%P 6 &        $999x 72w  6#6#6#6#6#+/86#6#6#6#6#sH,"C00C87C8"D))+EE!$F  FF+"GG*)G*