HEX
Server: Apache
System: Linux zacp120.webway.host 4.18.0-553.50.1.lve.el8.x86_64 #1 SMP Thu Apr 17 19:10:24 UTC 2025 x86_64
User: govancoz (1003)
PHP: 8.3.26
Disabled: exec,system,passthru,shell_exec,proc_close,proc_open,dl,popen,show_source,posix_kill,posix_mkfifo,posix_getpwuid,posix_setpgid,posix_setsid,posix_setuid,posix_setgid,posix_seteuid,posix_setegid,posix_uname
Upload Files
File: //usr/local/lib/python3.10/test/support/__pycache__/script_helper.cpython-310.opt-1.pyc
o

�i�,�@s�ddlZddlZddlZddlZddlZddlZddlZddlZddlm	Z	ddl
mZddlm
Z
dadd�ZGdd�de�dd	��Zd
d�Zdd
�Zdd�Zdd�Zejejd�dd�Zdd�Zd$dd�Zd%dd�Zd&dd�Z	d'd d!�Zd"d#�ZdS)(�N)�source_from_cache)�support)�make_legacy_pyccCsVtdur)dtjvr
dadSzt�tjdddg�Wn
tjy&daYtSwdatS)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.
    NZ
PYTHONHOMET�-Ez-czimport sys; sys.exit(0)F)�$__cached_interp_requires_environment�os�environ�
subprocess�
check_call�sys�
executable�CalledProcessError�rr�7/usr/local/lib/python3.10/test/support/script_helper.py� interpreter_requires_environments


��rc@seZdZdZdd�ZdS)�_PythonRunResultz2Helper for reporting Python subprocess run resultscCs�d}|j|j}}t|�|krd||d�}t|�|kr'd||d�}|�dd���}|�dd���}td|j|||f��)z4Provide helpful details about failed subcommand runsi@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�maxlenrrrrr�fail=s��z_PythonRunResult.failN)�__name__�
__module__�__qualname__�__doc__rrrrrr:sr)rrrc	OsBt�}|�dd�}d|vr|�d�}n|o|}tjddg}|r'|�d�n	|s0|s0|�d�|�dd�rEi}tjdkrDtjd	|d	<ntj��}d
|vrRd|d
<|�	|�|�
|�tj|tj
tj
tj
||d�}|�"z|��\}}	W|��t��n	|��t��wWd�n1s�wY|j}
t|
||	�|fS)
NZ__cwdZ
__isolated�-X�faulthandlerz-IrZ
__cleanenv�win32Z
SYSTEMROOT�TERM�)�stdin�stdout�stderr�env�cwd)r�poprr�append�platformrr�copy�update�extendr	�Popen�PIPE�communicate�kill�_cleanup�
returncoder)�args�env_varsZenv_requiredr,�isolatedrr+�procrrrrrr�run_python_until_endZsD

�



�
��r=cOs4t|i|��\}}|jr|s|js|s|�|�|S�N)r=rr)Zexpected_successr9r:�resrrrr�_assert_python�s
r@cO�tdg|�Ri|��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�r@�r9r:rrr�assert_python_ok�srDcOrA)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.
    FrBrCrrr�assert_python_failure�srE)r)r*cOsXtjg}t�s|�d�|�|�|�dttj��}d|d<t	j
|ft	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.
    rr+Zvt100r&)r(r)r*)rrrr.r2�
setdefault�dictrrr	r3r4)r)r*r9�kwrr+rrr�spawn_python�s

��rIcCs2|j��|j��}|j��|��t��|S)z?Run the given Popen process until completion and return stdout.)r(�closer)�read�waitr	r7)�p�datarrr�kill_python�s


rOFcCsh|}|s|tjd7}tj�||�}t|ddd��
}|�|�Wd�n1s)wYt��|S)N�py�wzutf-8)�encoding)r�extsep�path�join�open�write�	importlib�invalidate_caches)Z
script_dir�script_basename�sourceZomit_suffixZscript_filename�script_nameZscript_filerrr�make_script�s�r]c	Cs�|tjd}tj�||�}t�|d��9}|dur@|�tj�}t|�dkr:|ddkr:t	t
|��}tj�|�}|}ntj�|�}|�||�Wd�n1sPwY|tj�||�fS)N�ziprQ�����__pycache__)
rrSrTrU�zipfile�ZipFile�split�seprrr�basenamerW)	�zip_dir�zip_basenamer\Zname_in_zip�zip_filename�zip_name�zip_file�partsZ
legacy_pycrrr�make_zip_script�s�rmr'cCst�|�t|d|�dS)N�__init__)r�mkdirr])Zpkg_dirZinit_sourcerrr�make_pkg�s
rp�cs>g}t|dd�}|�|�tj�|�}	t|||�}
|�|
�|r5tj|dd�}tj|
dd�}
|�||
f��fdd�td|d�D�}tj�	|dtj�|
��}|tj
d	}
tj�	||
�}t�|d
�� }|D]}tj�	||	�}|�
||�qg|�
|
|�Wd�n1s�wY|D]}t�|�q�|tj�	||�fS)Nrnr'T)�doraisecsg|]}tj��g|��qSr)rrerU)�.0�i��pkg_namerr�
<listcomp>sz make_zip_pkg.<locals>.<listcomp>rq���r^rQ)r]r.rrTrf�
py_compile�compiler2�rangerUrSrbrcrW�unlink)rgrhrvrZr[�depthZcompiledr|Z	init_nameZ
init_basenamer\Z	pkg_namesZscript_name_in_ziprirjrk�nameZinit_name_in_ziprrur�make_zip_pkg�s.

�rcCs�tjrDdd�}dtj�|���}t�t||�dd�tjdddd	|d
g}t�	|�}t||�d|j
���dd�|j
rBt|�d���dStd	|d
�dS)
NcSsd|�d�S)Nz===== z ======r)�textrrr�titleszrun_test_script.<locals>.titlezscript T)�flushrr#r$z-uz-vz completed: exit code z failed)
r�verboserrTrf�printrrr	�runr8rrD)Zscriptr�r~r9r<rrr�run_test_scripts
��r�)Fr>)r')rqF)�collectionsrXrrZos.pathr	ryrb�importlib.utilr�testrZtest.support.import_helperrrr�
namedtuplerr=r@rDrEr4�STDOUTrIrOr]rmrprr�rrrr�<module>s8$� 4



�