%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /lib/python3.12/test/support/__pycache__/
Upload File :
Create Path :
Current File : //lib/python3.12/test/support/__pycache__/script_helper.cpython-312.pyc

�

���f�-����ddlZddlZddlZddlZddlZddlZddlZddlZddlm	Z	ddl
mZddlm
Z
dad�ZGd�dej dd��Zej$�d	��Zej$�d
��Zd�Zd�Zej$�ej.ej0d
�d��Zd�Zdd�Zdd�Zdd�Z	dd�Zej$�d��Zy)�N)�source_from_cache)�support)�make_legacy_pycc�
�t�Xdtjvrdaytjsday	tjtjdddg�datStS#t
j$r
daYtSwxYw)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-czimport 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_environmentrs���$,�3��2�:�:�%�37�0���-�-�38�0��	9��!�!�3�>�>�4�#'�)B�#D�
E�
49�0�/�/�/�/���,�,�	8�37�0�0�/�	8�s�'A%�%B�Bc��eZdZdZd�Zy)�_PythonRunResultz2Helper for reporting Python subprocess run resultsc�J�d}|j|j}}t|�|kDr	d||dz}t|�|kDr	d||dz}|jdd�j	�}|jdd�j	�}td|j|||fz��)z4Provide helpful details about failed subcommand runsi0us(... 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�maxlenrrs     r�failz_PythonRunResult.failAs������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���#�!%���� #� #� %�%�&�	&rN)�__name__�
__module__�__qualname__�__doc__r%rrrrr>s
��<�&rr)r!rrc��t�}|jdd�}d|vr|jd�}n|xr|}tjddg}|r|j	d�n|s|s|j	d�|jdd�r,i}tj
dk(r5tjd	|d	<ntjj�}d
|vrd|d
<|j|�|j|�tj|tjtjtj||��}|5	|j�\}}	|j�tj �	ddd�|j"}
t%|
	�|fS#|j�tj �wxYw#1swY�MxYw)
N�__cwd�
__isolated�-X�faulthandlerz-Ir�
__cleanenv�win32�
SYSTEMROOT�TERM�)�stdin�stdout�stderr�env�cwd)r�poprr�append�platformr
r�copy�update�extendr
�Popen�PIPE�communicate�kill�_cleanup�
returncoder)�args�env_vars�env_requiredr8�isolatedr#r7�procrrr!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�Gc�|�t|i|��\}}|jr|s|js|s|j|�|S�N)rJr!r%)�expected_successrErF�resr#s     r�_assert_pythonrO�s9��(�$�;�(�;�M�C�����#�S�V�V�<L�������Jrc� �tdg|��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�rErFs  r�assert_python_okrS�s���$�2��2��2�2rc� �tdg|��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.
    FrQrRs  r�assert_python_failurerU�s���%�3�$�3�(�3�3r)r5r6c�(�tjg}t�s|jd�|j	|�|jdt
tj��}d|d<tj|ftj||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.
    rr7�vt100r2)r4r5r6)rrrr:r>�
setdefault�dictr
rr
r?r@)r5r6rE�kwr#r7s      r�spawn_pythonr[�s������H�+�-�������O�O�D��
�-�-��t�B�J�J�/�
0�C��C��K����H�"�J�O�O�#)�&�"� �"�"rc���|jj�|jj�}|jj�|j	�tj�|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������Krc�
�|}|s|tjdzz
}tjj||�}t	|dd��5}|j|�ddd�t
j�|S#1swY�xYw)N�py�wzutf-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�9Bc�D�|tjzdz}tjj||�}t	j
|d�5}|��|j
tj�}t|�dk\r>|ddk(r6tt|��}tjj|�}|}ntjj|�}|j||�ddd�|tjj||�fS#1swY�+xYw)N�zipre�����__pycache__)
r
rgrhri�zipfile�ZipFile�split�seprrr�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
�
BD�Dc�H�tj|�t|d|�y)N�__init__)r
�mkdirru)�pkg_dir�init_sources  r�make_pkgr��s���H�H�W�����[�1rc��g}t|dd�}|j|�tjj	|�}	t|||�}
|j|
�|rAtj|d��}tj|
d��}
|j||
f�td|dz�D�cgc]%}tjj|g|z���'}}tjj|dtjj	|
��}
|tjzdz}tjj||�}tj|d�5}|D]4}tjj||	�}|j||��6|j|
|
�ddd�|D]}tj|��|tjj||
�fScc}w#1swY�LxYw)	Nr�r3T)�doraise����rwre)rur:r
rhr�
py_compile�compiler>�ranger~rirgr{r|rk�unlink)r�r��pkg_namerorp�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��tjr�d�}dtjj	|���}t�t||�d��tjdddd|d	g}tj|�}t||�d
|j���d��|jrt|�d���ytd|d	�y)Nc��d|�d�S)Nz===== z ======r)�texts r�titlezrun_test_script.<locals>.titles���D�6��)�)rzscript T)�flushrr-r.z-uz-vz completed: exit code z failed)
r�verboser
rhr�printrrr
�runrDr rS)�scriptr�r�rErIs     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) �collectionsrlrr
�os.pathr
r�r{�importlib.utilr�testr�test.support.import_helperrr	r�
namedtupler�requires_subprocessrJrOrSrUr@�STDOUTr[rbrur�r�r�r�rrr�<module>r�s
����
�	�����,��6�(,�$�%0�P&�-�{�-�-�.@�*>�@�&�@�����14��14�h��������3�4������)���z�7H�7H�"��"�.	�	�9�(2�,1�@�<�����-��-r

Zerion Mini Shell 1.0