Ë
    òT•jÉ-  ã                   óÆ  — 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m	Z	 d dl
mZ d dlmZ dad„ Z G d„ d e j                   dd«      «      Z ej$                  «       d	„ «       Z ej$                  «       d
„ «       Zd„ Zd„ Z ej$                  «       ej.                  ej0                  dœd„«       Zd„ Zdd„Zdd„Zdd„Z	 dd„Z ej$                  «       d„ «       Zy)é    N)Úsource_from_cache)Úsupport)Úmake_legacy_pycc                  ó
  — t         €Xdt        j                  v rda yt        j                  sda y	 t        j                  t        j                  dddg«       da t         S t         S # t
        j                  $ r
 da Y t         S w xY w)a   
    Returns True if our sys.executable interpreter requires environment
    variables in order to be able to run at all.

    This is designed to be used with @unittest.skipIf() to annotate tests
    that need to use an assert_python*() function to launch an isolated
    mode (-I) or no environment mode (-E) sub-interpreter process.

    A normal build & test does not run into this situation but it can happen
    when trying to run the standard library test suite from an interpreter that
    doesn't have an obvious home with Python's current home finding logic.

    Setting PYTHONHOME is one way to get most of the testsuite to run in that
    situation.  PYTHONPATH or PYTHONUSERSITE are other common environment
    variables that might impact whether or not the interpreter can start.
    Ú
PYTHONHOMETFú-Ez-czimport sys; sys.exit(0))
Ú$__cached_interp_requires_environmentÚosÚenvironr   Úhas_subprocess_supportÚ
subprocessÚ
check_callÚsysÚ
executableÚCalledProcessError© ó    ú1/usr/lib/python3.12/test/support/script_helper.pyÚ interpreter_requires_environmentr      s’   € ô$ ,Ð3àœ2Ÿ:™:Ñ%Ø37Ð0Øä×-Ò-Ø38Ð0Øð	9Ü×!Ñ!¤3§>¡>°4Ø#'Ð)Bð#Dô Eð
 49Ð0ä/Ð/Ô/Ð/øô ×,Ñ,ò 	8Ø37Ñ0ô 0Ð/ð	8ús   °'A% Á%BÂBc                   ó   — e Zd ZdZd„ Zy)Ú_PythonRunResultz2Helper for reporting Python subprocess run resultsc                 óJ  — d}| j                   | j                  }}t        |«      |kD  r	d|| d z   }t        |«      |kD  r	d|| d z   }|j                  dd«      j	                  «       }|j                  dd«      j	                  «       }t        d| j                  |||fz  «      ‚)z4Provide helpful details about failed subcommand runsi0u  s   (... truncated stdout ...)Ns   (... truncated stderr ...)ÚasciiÚreplacezRProcess return code is %d
command line: %r

stdout:
---
%s
---

stderr:
---
%s
---)ÚoutÚerrÚlenÚdecodeÚrstripÚAssertionErrorÚrc)ÚselfÚcmd_lineÚmaxlenr   r   s        r   Úfailz_PythonRunResult.failA   sµ   € ð ˆØ—8‘8˜TŸX™XˆSˆÜˆs‹8�fÒØ/°#°v°g°h°-Ñ?ˆCÜˆs‹8�fÒØ/°#°v°g°h°-Ñ?ˆCØ�j‰j˜ )Ó,×3Ñ3Ó5ˆØ�j‰j˜ )Ó,×3Ñ3Ó5ˆÜð #ð !%§¡¨Ø #Ø #ð %ñ%ó &ð 	&r   N)Ú__name__Ú
__module__Ú__qualname__Ú__doc__r%   r   r   r   r   r   >   s
   „ á<ó&r   r   )r!   r   r   c                  ó®  — t        «       }|j                  dd «      }d|v r|j                  d«      }n| xr | }t        j                  ddg}|r|j	                  d«       n|s|s|j	                  d«       |j                  dd «      r,i }t        j
                  dk(  r5t        j                  d	   |d	<   nt        j                  j                  «       }d
|vrd|d
<   |j                  |«       |j                  | «       t        j                  |t        j                  t        j                  t        j                  ||¬«      }|5  	 |j                  «       \  }}	|j                  «        t        j                   «        	 d d d «       |j"                  }
t%        |
	«      |fS # |j                  «        t        j                   «        w xY w# 1 sw Y   ŒMxY w)NÚ__cwdÚ
__isolatedú-XÚfaulthandlerz-Ir   Ú
__cleanenvÚwin32Ú
SYSTEMROOTÚTERMÚ )ÚstdinÚstdoutÚstderrÚenvÚcwd)r   Úpopr   r   ÚappendÚplatformr
   r   ÚcopyÚupdateÚextendr   ÚPopenÚPIPEÚcommunicateÚkillÚ_cleanupÚ
returncoder   )ÚargsÚenv_varsÚenv_requiredr8   Úisolatedr#   r7   Úprocr   r   r!   s              r   Úrun_python_until_endrJ   ^   sŒ  € ä3Ó5€LØ
�,‰,�w Ó
%€CØ�xÑØ—<‘< Ó-‰à�<Ò4¨Ð$4ˆÜ—‘  nÐ5€HÙð 	�‰˜ÕÙ™là�‰˜Ôð ‡|�|�L $Ô'ØˆÜ�<‰<˜7Ò"ô !#§
¡
¨<Ñ 8ˆC�Òô �j‰j�o‰oÓˆð �XÑØˆˆF‰à‡J�JˆxÔØ‡O�O�DÔÜ×Ñ˜H¬J¯O©OÜ *§¡¼
¿¹Ø  cô+€Dð 
ñ "ð	"Ø×'Ñ'Ó)‰HˆC�à�I‰IŒKÜ×ÑÕ!÷"ð 
�‰€BÜ˜B  SÓ)¨8Ð3Ð3øð �I‰IŒKÜ×ÑÕ!ú÷"ð "ús$   ÅGÅF"Å$GÆ"&GÇGÇGc                ó|   — t        |i |¤Ž\  }}|j                  r| s|j                  s| s|j                  |«       |S ©N)rJ   r!   r%   )Úexpected_successrE   rF   Úresr#   s        r   Ú_assert_pythonrO   “   s9   € ä(¨$Ð;°(Ñ;�M€CˆØ�ŠÑ#¨S¯VªVÑ<LØ�‰�ÔØ€Jr   c                  ó    — t        dg| ¢­i |¤ŽS )a|  
    Assert that running the interpreter with `args` and optional environment
    variables `env_vars` succeeds (rc == 0) and return a (return code, stdout,
    stderr) tuple.

    If the __cleanenv keyword is set, env_vars is used as a fresh environment.

    Python is started in isolated mode (command line option -I),
    except if the __isolated keyword is set to False.
    T©rO   ©rE   rF   s     r   Úassert_python_okrS   ›   s   € ô ˜$Ð2 Ò2¨Ñ2Ð2r   c                  ó    — t        dg| ¢­i |¤ŽS )zß
    Assert that running the interpreter with `args` and optional environment
    variables `env_vars` fails (rc != 0) and return a (return code, stdout,
    stderr) tuple.

    See assert_python_ok() for more options.
    FrQ   rR   s     r   Úassert_python_failurerU   ©   s   € ô ˜%Ð3 $Ò3¨(Ñ3Ð3r   )r5   r6   c                 ó(  — t         j                  g}t        «       s|j                  d«       |j	                  |«       |j                  dt        t        j                  «      «      }d|d<   t        j                  |ft        j                  | |dœ|¤ŽS )z�Run a Python subprocess with the given arguments.

    kw is extra keyword args to pass to subprocess.Popen. Returns a Popen
    object.
    r   r7   Úvt100r2   )r4   r5   r6   )r   r   r   r:   r>   Ú
setdefaultÚdictr
   r   r   r?   r@   )r5   r6   rE   Úkwr#   r7   s         r   Úspawn_pythonr[   ´   s   € ô —‘Ð€HÜ+Ô-Ø�‰˜ÔØ‡O�O�DÔð �-‰-˜œt¤B§J¡JÓ/Ó
0€CØ€Cˆ�KÜ×Ñ˜Hð "¬J¯O©OØ#)°&ñ"à ñ"ð "r   c                 óê   — | j                   j                  «        | j                  j                  «       }| j                  j                  «        | j	                  «        t        j                  «        |S )z?Run the given Popen process until completion and return stdout.)r4   Úcloser5   ÚreadÚwaitr   rC   )ÚpÚdatas     r   Úkill_pythonrb   Ì   sH   € à‡G�G‡M�M„OØ�8‰8�=‰=‹?€DØ‡H�H‡N�NÔð ‡F�F„HÜ×ÑÔØ€Kr   c                 ó
  — |}|s|t         j                  dz   z  }t         j                  j                  | |«      }t	        |dd¬«      5 }|j                  |«       d d d «       t        j                  «        |S # 1 sw Y   ŒxY w)NÚpyÚwzutf-8)Úencoding)r
   ÚextsepÚpathÚjoinÚopenÚwriteÚ	importlibÚinvalidate_caches)Ú
script_dirÚscript_basenameÚsourceÚomit_suffixÚscript_filenameÚscript_nameÚscript_files          r   Úmake_scriptru   Ø   st   € Ø%€OÙØœ2Ÿ9™9 tÑ+Ñ+ˆÜ—'‘'—,‘,˜z¨?Ó;€Kä	ˆk˜3¨Ô	1ð "°[Ø×Ñ˜&Ô!÷"ä×ÑÔ!ØÐ÷"ð "ús   Á	A9Á9Bc                 óD  — |t         j                  z   dz   }t         j                  j                  | |«      }t	        j
                  |d«      5 }|€Š|j                  t         j                  «      }t        |«      dk\  r>|d   dk(  r6t        t        |«      «      }t         j                  j                  |«      }|}nt         j                  j                  |«      }|j                  ||«       d d d «       |t         j                  j                  ||«      fS # 1 sw Y   Œ+xY w)NÚzipre   é   éþÿÿÿÚ__pycache__)r
   rg   rh   ri   ÚzipfileÚZipFileÚsplitÚsepr   r   r   Úbasenamerk   )	Úzip_dirÚzip_basenamers   Úname_in_zipÚzip_filenameÚzip_nameÚzip_fileÚpartsÚ
legacy_pycs	            r   Úmake_zip_scriptrˆ   ä   så   € Ø¤§	¡	Ñ)¨%Ñ/€LÜ�w‰w�|‰|˜G \Ó2€HÜ	�‰˜ 3Ó	'ð 	1¨8ØÐØ×%Ñ%¤b§f¡fÓ-ˆEÜ�5‹z˜QŠ 5¨¡9°Ò#=Ü,Ô->¸{Ó-KÓL�
Ü Ÿg™g×.Ñ.¨zÓ:�Ø(‘ä Ÿg™g×.Ñ.¨{Ó;�Ø�‰�{ KÔ0÷	1ð ”R—W‘W—\‘\ (¨KÓ8Ð8Ð8÷	1ð 	1ús   ÁBDÄDc                 óH   — t        j                  | «       t        | d|«       y )NÚ__init__)r
   Úmkdirru   )Úpkg_dirÚinit_sources     r   Úmake_pkgrŽ   ø   s   € Ü‡H�HˆWÔÜ�˜ [Õ1r   c                 ó  — g }t        | dd«      }|j                  |«       t        j                  j	                  |«      }	t        | ||«      }
|j                  |
«       |rAt        j                  |d¬«      }t        j                  |
d¬«      }
|j                  ||
f«       t        d|dz   «      D �cg c]%  }t        j                  j                  |g|z  «      ‘Œ' }}t        j                  j                  |d   t        j                  j	                  |
«      «      }|t        j                  z   dz   }t        j                  j                  | |«      }t        j                  |d«      5 }|D ]4  }t        j                  j                  ||	«      }|j                  ||«       Œ6 |j                  |
|«       d d d «       |D ]  }t        j                  |«       Œ |t        j                  j                  ||«      fS c c}w # 1 sw Y   ŒLxY w)	NrŠ   r3   T)Údoraiseé   éÿÿÿÿrw   re   )ru   r:   r
   rh   r   Ú
py_compileÚcompiler>   Úranger~   ri   rg   r{   r|   rk   Úunlink)r€   r�   Úpkg_namero   rp   ÚdepthÚcompiledr–   Ú	init_nameÚinit_basenamers   ÚiÚ	pkg_namesÚscript_name_in_ziprƒ   r„   r…   ÚnameÚinit_name_in_zips                      r   Úmake_zip_pkgr¡   ý   s¯  € à€FÜ˜G Z°Ó4€IØ
‡M�M�)ÔÜ—G‘G×$Ñ$ YÓ/€MÜ˜g ¸Ó?€KØ
‡M�M�+ÔÙÜ×&Ñ& y¸$Ô?ˆ	Ü ×(Ñ(¨¸dÔCˆØ�‰�y +Ð.Ô/Ü49¸!¸UÀ1¹WÓ4EÖF¨q”—‘—‘˜h˜Z¨™\Õ*ÐF€IÐFÜŸ™Ÿ™ i°¡m´R·W±W×5EÑ5EÀkÓ5RÓSÐØ¤§	¡	Ñ)¨%Ñ/€LÜ�w‰w�|‰|˜G \Ó2€HÜ	�‰˜ 3Ó	'ð 8¨8Øò 	8ˆDÜ!Ÿw™wŸ|™|¨D°-Ó@ÐØ�N‰N˜9Ð&6Õ7ð	8ð 	�‰�{Ð$6Ô7÷	8ð
 ò ˆÜ
�	‰	�$�ðð ”R—W‘W—\‘\ (Ð,>Ó?Ð?Ð?ùò G÷8ð 8ús   Â2*G<Å*AHÈH
c                 ó”  — t         j                  r«d„ }dt        j                  j	                  | «      › �}t        «        t         ||«      d¬«       t        j                  dddd| d	g}t        j                  |«      }t         ||› d
|j                  › �«      d¬«       |j                  rt        |› d�«      ‚y t        d| d	«       y )Nc                 ó   — d| › d�S )Nz===== z ======r   )Útexts    r   Útitlezrun_test_script.<locals>.title  s   € Ø˜D˜6 Ð)Ð)r   zscript T)Úflushr   r-   r.   z-uz-vz completed: exit code z failed)r   Úverboser
   rh   r   Úprintr   r   r   ÚrunrD   r    rS   )Úscriptr¥   rŸ   rE   rI   s        r   Úrun_test_scriptr«     s¸   € ô ‡‚ò	*ð œŸ™×)Ñ)¨&Ó1Ð2Ð3ˆÜŒÜ‰e�D‹k Õ&ô —‘  d¨N¸DÀ&È$ÐOˆÜ�~‰~˜dÓ#ˆÜ‰e�t�fÐ2°4·?±?Ð2CÐDÓEØõ	à�?Š?Ü  D 6¨Ð!1Ó2Ð2ð ô 	˜˜v tÕ,r   )FrL   )r3   )r‘   F) Úcollectionsrl   r   r
   Úos.pathr   r“   r{   Úimportlib.utilr   Útestr   Útest.support.import_helperr   r	   r   Ú
namedtupler   Úrequires_subprocessrJ   rO   rS   rU   r@   ÚSTDOUTr[   rb   ru   rˆ   rŽ   r¡   r«   r   r   r   ú<module>r´      s  ðó Û Û 
Û 	Û Û Û Û å ,Ý Ý 6ð (,Ð $ò%0ôP&Ð-�{×-Ñ-Ð.@Ø*>ó@ô &ð@ €×ÑÓñ14ó ð14ðh €×ÑÓñó ðò3ò4ð €×ÑÓØ)Ÿ™°z×7HÑ7Hó "ó ð"ò.	ó	ó9ó(2ð ,1ó@ð< €×ÑÓñ-ó ñ-r   