HEX
Server: Microsoft-IIS/10.0
System: Windows NT ITPWINWEBSVR22 10.0 build 20348 (Windows Server 2022) AMD64
User: www.conferencesearch.co.uk (0)
PHP: 8.3.30
Disabled: NONE
Upload Files
File: D:/Python311/Lib/test/__pycache__/test_cmd_line_script.cpython-311.pyc
�

��Vc<���<�ddlZddlZddlZddlZddlZddlZddlZddlZddlZddl	Z	ddl
Z
ddlZddlm
Z
ddlmZddlmZddlmZmZmZmZmZmZmZmZe
jZgd�ZdZefd�Zed	fd
�ZGd�dej��Z d
�Z!e"dkrej#��dSdS)�N)�support)�
import_helper)�	os_helper)�make_pkg�make_script�make_zip_pkg�make_zip_script�assert_python_ok�assert_python_failure�spawn_python�kill_python)�test1�test2�test3a�# Script may be run with optimisation enabled, so don't rely on assert
# statements being executed
def assertEqual(lhs, rhs):
    if lhs != rhs:
        raise AssertionError('%r != %r' % (lhs, rhs))
def assertIdentical(lhs, rhs):
    if lhs is not rhs:
        raise AssertionError('%r is not %r' % (lhs, rhs))
# Check basic code execution
result = ['Top level assignment']
def f():
    result.append('Lower level reference')
f()
assertEqual(result, ['Top level assignment', 'Lower level reference'])
# Check population of magic variables
assertEqual(__name__, '__main__')
from importlib.machinery import BuiltinImporter
_loader = __loader__ if __loader__ is BuiltinImporter else type(__loader__)
print('__loader__==%a' % _loader)
print('__file__==%a' % __file__)
print('__cached__==%a' % __cached__)
print('__package__==%r' % __package__)
# Check PEP 451 details
import os.path
if __package__ is not None:
    print('__main__ was located through the import system')
    assertIdentical(__spec__.loader, __loader__)
    expected_spec_name = os.path.splitext(os.path.basename(__file__))[0]
    if __package__:
        expected_spec_name = __package__ + "." + expected_spec_name
    assertEqual(__spec__.name, expected_spec_name)
    assertEqual(__spec__.parent, __package__)
    assertIdentical(__spec__.submodule_search_locations, None)
    assertEqual(__spec__.origin, __file__)
    if __spec__.cached is not None:
        assertEqual(__spec__.cached, __cached__)
# Check the sys module
import sys
assertIdentical(globals(), sys.modules[__name__].__dict__)
if __spec__ is not None:
    # XXX: We're not currently making __main__ available under its real name
    pass # assertIdentical(globals(), sys.modules[__spec__.name].__dict__)
from test import test_cmd_line_script
example_args_list = test_cmd_line_script.example_args
assertEqual(sys.argv[1:], example_args_list)
print('sys.argv[0]==%a' % sys.argv[0])
print('sys.path[0]==%a' % sys.path[0])
# Check the working directory
import os
print('cwd==%a' % os.getcwd())
c�N�t|||��}tj��|S�N)r�	importlib�invalidate_caches)�
script_dir�script_basename�source�	to_returns    �-D:\Python311\Lib\test\test_cmd_line_script.py�_make_test_scriptrPs(���J���@�@�I�
��!�!�!����c�T�t||||||��}tj��|Sr)rrr)�zip_dir�zip_basename�pkg_namerr�depthrs       r�_make_test_zip_pkgr"Us3���W�l�H�o�#�U�,�,�I�
��!�!�!��rc��eZdZ	d8d�Zdd�d�Zdd�d�Zd�Zd�Zej	d9d	���Z
d9d
�Zd9d�Zd�Z
d
�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Z d �Z!d!�Z"d"�Z#d#�Z$d$�Z%d%�Z&ej	d&���Z'd'�Z(d(�Z)d)�Z*d*�Z+d+�Z,d,�Z-d-�Z.d.�Z/d/�Z0d0�Z1d1�Z2d2�Z3d3�Z4d4�Z5d5�Z6d6�Z7d7�Z8dS):�CmdLineTestNc
���tdkr.td|z��tt|����|�|d��d|z}
d|z}d|z}d|z}
d|z}|	�t	j��}	d	|	z}tdkrKtd
��t|��t|��t|
��t|��|�|
�d��|��|�|�d��|��|�|�d��|��|�|
�d��|��tj	j
s)|�|�d��|��|�|�d��|��dS)NrzOutput from test script %r:rz__loader__==%az__file__==%az__package__==%rzsys.argv[0]==%azsys.path[0]==%azcwd==%azExpected output:�utf-8)�verbose�print�repr�assertEqual�os�getcwd�assertIn�encode�sys�flags�	safe_path)�self�script_name�	exit_code�data�
expected_file�expected_argv0�expected_path0�expected_package�expected_loader�expected_cwd�printed_loader�printed_file�printed_package�
printed_argv0�
printed_path0�printed_cwds                r�
_check_outputzCmdLineTest._check_output]s����Q�;�	��/�+�=�>�>�>��$�t�*�*��������A�&�&�&�)�O�;��%�
�5��+�.>�>��)�N�:�
�)�N�:�
��	'��9�;�;�L��,�.���Q�;�	��$�%�%�%��,�����/�"�"�"��-� � � ��+�����
�
�n�+�+�G�4�4�d�;�;�;��
�
�l�)�)�'�2�2�D�9�9�9��
�
�o�,�,�W�5�5�t�<�<�<��
�
�m�*�*�7�3�3�T�:�:�:��y�"�	?��M�M�-�.�.�w�7�7��>�>�>��
�
�k�(�(��1�1�4�8�8�8�8�8r��cwdc���t|t��r|g}gtj���|�|�t�}
t|
d|d�|	��\}}}
|�||||
z||||||�	�	dS)NF��
__isolated�__cwd)�
isinstance�strr�!optim_args_from_interpreter_flags�example_argsr
rB)r2�script_exec_argsr6r7r8r9r:rD�cmd_line_switches�env_vars�run_args�rc�out�errs              r�
_check_scriptzCmdLineTest._check_script|s����&��,�,�	2� 0�1��J�W�>�@�@�J�&�J�)9�J�<H�J��'�
�%�s�
�
�6>�
�
���C��	
���+�R��s��M�)�>�+�_�c�	C�	C�	C�	C�	Crc�p�t|t��r|f}nt|��}||z}t|d|d�|��\}}}	tdkrAtd|�����tt
|	����td|z��|�|�d��|	��dS)NFrFrzOutput from test script zExpected output: %rr&)	rIrJ�tuplerr'r(r)r-r.)
r2rM�expected_msgrDrNrOrPrQrRrSs
          r�_check_import_errorzCmdLineTest._check_import_error�s����&��,�,�	7� 0�2���$�%5�6�6��$�'7�7��,�
�%�s�
�
�6>�
�
���C���Q�;�	8��B�-=�B�B�B�C�C�C��$�s�)�)�����'�,�6�7�7�7��
�
�l�)�)�'�2�2�C�8�8�8�8�8rc��tdd��\}}}ttjj���d��}|�||��dS)N�-czprint(__loader__)r&)r
r)r�	machinery�BuiltinImporterr.r-)r2rQrRrS�expecteds     r�test_dash_c_loaderzCmdLineTest.test_dash_c_loader�sS��'��.A�B�B���C���	�+�;�<�<�C�C�G�L�L���
�
�h��$�$�$�$�$rc�`�t��}	|j�d��|j���t	|��}n#t	|��}wxYwttjj���	d��}|�
||��dS)Nsprint(__loader__)
r&)r�stdin�write�flushr
r)rr[r\r.r-)r2�prRr]s    r�test_stdin_loaderzCmdLineTest.test_stdin_loader�s���
�N�N��	!�
�G�M�M�0�1�1�1�
�G�M�M�O�O�O��a�.�.�C�C��+�a�.�.�C� � � � ��	�+�;�<�<�C�C�G�L�L���
�
�h��$�$�$�$�$s�3A�A$Fc#�K�|r#tdtj���}|j}n"tdtj���}|j}		|�d��}|dkrn|����1|V�t|��|�	��dS#t|��|�	��wxYw)Nz-i)�stderrT�s>>> )
r�
subprocess�PIPErf�STDOUT�stdout�read�readliner
�close)r2�separate_stderrrcrfr5s     r�interactive_pythonzCmdLineTest.interactive_python�s������	��T�*�/�:�:�:�A��X�F�F��T�*�*;�<�<�<�A��X�F�
	�
"��{�{�1�~�~���7�?������!�!�!�	
"�
�G�G�G���N�N�N��L�L�N�N�N�N�N��
��N�N�N��L�L�N�N�N�N���s�6B&�&%Cc�F�|�|��5}|j�d��|j���|�d|j��������ddd��dS#1swxYwYdS)Ns
print('foo')
sfoo)rpr`rarbr*rkrm�strip)r2rorcs   r�check_repl_stdout_flushz#CmdLineTest.check_repl_stdout_flush�s���
�
$�
$�_�
5�
5�	B��
�G�M�M�+�,�,�,�
�G�M�M�O�O�O����V�Q�X�%6�%6�%8�%8�%>�%>�%@�%@�A�A�A�	B�	B�	B�	B�	B�	B�	B�	B�	B�	B�	B�	B����	B�	B�	B�	B�	B�	Bs�A3B�B�Bc���|�|��5}|j�d��|j���|r|jn|j}|�d|�����|�d|�����|�d|�����ddd��dS#1swxYwYdS)Ns1/0
s
Traceback sFile "<stdin>"sZeroDivisionError)rpr`rarbrfrkr-rm)r2rorcrfs    r�check_repl_stderr_flushz#CmdLineTest.check_repl_stderr_flush�s��
�
$�
$�_�
5�
5�	C��
�G�M�M�(�#�#�#�
�G�M�M�O�O�O�!0�>�Q�X�X�a�h�F��M�M�-����):�):�;�;�;��M�M�+�V�_�_�->�->�?�?�?��M�M�.����0A�0A�B�B�B�
	C�	C�	C�	C�	C�	C�	C�	C�	C�	C�	C�	C����	C�	C�	C�	C�	C�	Cs�B<C�C#�&C#c�.�|���dSr�rs�r2s r�test_repl_stdout_flushz"CmdLineTest.test_repl_stdout_flush�����$�$�&�&�&�&�&rc�0�|�d��dS�NTrwrxs r�&test_repl_stdout_flush_separate_stderrz2CmdLineTest.test_repl_stdout_flush_separate_stderr�����$�$�T�*�*�*�*�*rc�.�|���dSr�rurxs r�test_repl_stderr_flushz"CmdLineTest.test_repl_stderr_flush�rzrc�0�|�d��dSr|r�rxs r�&test_repl_stderr_flush_separate_stderrz2CmdLineTest.test_repl_stderr_flush_separate_stderr�r~rc
���tj��5}t|d��}|�||||dtjj|���ddd��dS#1swxYwYdS)N�script)r;�r�temp_dirrrTrr[�SourceFileLoader�r2rr3s   r�test_basic_scriptzCmdLineTest.test_basic_script�s���
�
�
!�
!�	8�Z�+�J��A�A�K����{�K��)�4�(�2�C�,6�
�
8�
8�
8�	8�	8�	8�	8�	8�	8�	8�	8�	8�	8�	8�	8����	8�	8�	8�	8�	8�	8s�<A�A!�$A!c	�t�tj��5}|�tj�|��|��t
|d��}tj�|��}|�||||dtj
j��ddd��dS#1swxYwYdS)Nr�)r�temp_cwd�
assertTruer+�path�isabsr�basenamerTrr[r�)r2rr3�
relative_names    r�test_script_abspathzCmdLineTest.test_script_abspath�s����
�
!�
!�	E�Z��O�O�B�G�M�M�*�5�5�z�B�B�B�+�J��A�A�K��G�,�,�[�9�9�M����}�k�=�)�4�(�2�C�
E�
E�
E�	E�	E�	E�	E�	E�	E�	E�	E�	E�	E�	E�	E����	E�	E�	E�	E�	E�	Es�BB-�-B1�4B1c	�L�tj��5}t|d��}tj|d���tj|��tj|��}|�	||||dtjj��ddd��dS#1swxYwYdS)Nr�T��doraise�
rr�r�
py_compile�compiler+�remover�make_legacy_pycrTrr[�SourcelessFileLoader�r2rr3�pyc_files    r�test_script_compiledz CmdLineTest.test_script_compiled�s���
�
�
!�
!�	I�Z�+�J��A�A�K���{�D�9�9�9�9��I�k�"�"�"�$�4�[�A�A�H����x��'��T�(�2�G�
I�
I�
I�	I�	I�	I�	I�	I�	I�	I�	I�	I�	I�	I�	I����	I�	I�	I�	I�	I�	I��A8B�B� Bc	���tj��5}t|d��}|�||||dtjj��ddd��dS#1swxYwYdS)N�__main__�r�r�s   r�test_directoryzCmdLineTest.test_directory�s���
�
�
!�
!�	E�Z�+�J�
�C�C�K����z�;�
�)�2�(�2�C�
E�
E�
E�	E�	E�	E�	E�	E�	E�	E�	E�	E�	E�	E�	E����	E�	E�	E�	E�	E�	Es�:A�A�"Ac	�L�tj��5}t|d��}tj|d���tj|��tj|��}|�	||||dtjj��ddd��dS#1swxYwYdS)Nr�Tr�r�r�r�s    r�test_directory_compiledz#CmdLineTest.test_directory_compileds���
�
�
!�
!�	I�Z�+�J�
�C�C�K���{�D�9�9�9�9��I�k�"�"�"�$�4�[�A�A�H����z�8�Z�)�2�(�2�G�
I�
I�
I�	I�	I�	I�	I�	I�	I�	I�	I�	I�	I�	I�	I����	I�	I�	I�	I�	I�	Ir�c��tj��5}d|z}|�||��ddd��dS#1swxYwYdS)N�"can't find '__main__' module in %r)rr�rX)r2r�msgs   r�test_directory_errorz CmdLineTest.test_directory_errors���
�
�
!�
!�	6�Z�6��C�C��$�$�Z��5�5�5�	6�	6�	6�	6�	6�	6�	6�	6�	6�	6�	6�	6����	6�	6�	6�	6�	6�	6s�=�A�Ac	���tj��5}t|d��}t|d|��\}}|�||||dt
j��ddd��dS#1swxYwYdS)Nr��test_zipr�)rr�rr	rT�	zipimport�zipimporter)r2rr3�zip_name�run_names     r�test_zipfilezCmdLineTest.test_zipfiles���
�
�
!�
!�	6�Z�+�J�
�C�C�K�!0��Z��!U�!U��H�h����x��8�X�r�(�4�
6�
6�
6�	6�	6�	6�	6�	6�	6�	6�	6�	6�	6�	6�	6����	6�	6�	6�	6�	6�	6s�A	A*�*A.�1A.c	�:�tj��5}t|d��}tj|dtjj���}t|d|��\}}|�||||dtj
��ddd��dS#1swxYwYdS�Nr�T)r��invalidation_moder�r�)rr�rr�r��PycInvalidationMode�	TIMESTAMPr	rTr�r��r2rr3�
compiled_namer�r�s      r�test_zipfile_compiled_timestampz+CmdLineTest.test_zipfile_compiled_timestamps���
�
�
!�
!�	6�Z�+�J�
�C�C�K�&�.��T�",�"@�"J�L�L�L�M�"1��Z��!W�!W��H�h����x��8�X�r�(�4�
6�
6�
6�
	6�	6�	6�	6�	6�	6�	6�	6�	6�	6�	6�	6����	6�	6�	6�	6�	6�	6��A/B�B�Bc	�:�tj��5}t|d��}tj|dtjj���}t|d|��\}}|�||||dtj
��ddd��dS#1swxYwYdSr�)rr�rr�r�r��CHECKED_HASHr	rTr�r�r�s      r�"test_zipfile_compiled_checked_hashz.CmdLineTest.test_zipfile_compiled_checked_hash!s���
�
�
!�
!�	6�Z�+�J�
�C�C�K�&�.��T�",�"@�"M�O�O�O�M�"1��Z��!W�!W��H�h����x��8�X�r�(�4�
6�
6�
6�
	6�	6�	6�	6�	6�	6�	6�	6�	6�	6�	6�	6����	6�	6�	6�	6�	6�	6r�c	�:�tj��5}t|d��}tj|dtjj���}t|d|��\}}|�||||dtj
��ddd��dS#1swxYwYdSr�)rr�rr�r�r��UNCHECKED_HASHr	rTr�r�r�s      r�$test_zipfile_compiled_unchecked_hashz0CmdLineTest.test_zipfile_compiled_unchecked_hash+s���
�
�
!�
!�	6�Z�+�J�
�C�C�K�&�.��T�",�"@�"O�Q�Q�Q�M�"1��Z��!W�!W��H�h����x��8�X�r�(�4�
6�
6�
6�
	6�	6�	6�	6�	6�	6�	6�	6�	6�	6�	6�	6����	6�	6�	6�	6�	6�	6r�c���tj��5}t|d��}t|d|��\}}d|z}|�||��ddd��dS#1swxYwYdS)N�not_mainr�r�)rr�rr	rX)r2rr3r�r�r�s      r�test_zipfile_errorzCmdLineTest.test_zipfile_error5s���
�
�
!�
!�	4�Z�+�J�
�C�C�K�!0��Z��!U�!U��H�h�6��A�C��$�$�X�s�3�3�3�		4�	4�	4�	4�	4�	4�	4�	4�	4�	4�	4�	4����	4�	4�	4�	4�	4�	4s�AA!�!A%�(A%c
�6�tj��5}tj�|d��}t|��t
|d��}|�ddg|||dtj	j
|���ddd��dS#1swxYwYdS)N�test_pkgr��-m�test_pkg.scriptrC�rr�r+r��joinrrrTrr[r��r2r�pkg_dirr3s    r�test_module_in_packagez"CmdLineTest.test_module_in_package<s���
�
�
!�
!�	/�Z��g�l�l�:�z�:�:�G��W����+�G�X�>�>�K�����&7�8�+�{�)�:�(�2�C�#-�
�
/�
/�
/�		/�	/�	/�	/�	/�	/�	/�	/�	/�	/�	/�	/����	/�	/�	/�	/�	/�	/��A-B�B�Bc���tj��5}t|ddd��\}}|�ddg|||dtj||���ddd��dS#1swxYwYdS)Nr�r�r�r�r���
PYTHONPATHrD�rr�r"rTr�r��r2rr�r�s    r�!test_module_in_package_in_zipfilez-CmdLineTest.test_module_in_package_in_zipfileFs���
�
�
!�
!�	D�Z�!3�J�
�J�X`�!a�!a��H�h�����&7�8�(�H�)�:�y�7L�*2�
�
�
D�
D�
D�	D�	D�	D�	D�	D�	D�	D�	D�	D�	D�	D�	D����	D�	D�	D�	D�	D�	Ds�?A � A$�'A$c���tj��5}t|dddd���\}}|�ddg|||dtj||�	��ddd��dS#1swxYwYdS)
Nr�r�r��)r!r�ztest_pkg.test_pkg.scriptztest_pkg.test_pkgr�r�r�s    r�$test_module_in_subpackage_in_zipfilez0CmdLineTest.test_module_in_subpackage_in_zipfileMs���
�
�
!�
!�	D�Z�!3�J�
�J�X`�hi�!j�!j�!j��H�h�����&@�A�8�X�)�+>�(�4�*2�
�
�
D�
D�
D�	D�	D�	D�	D�	D�	D�	D�	D�	D�	D�	D�	D����	D�	D�	D�	D�	D�	Ds�AA"�"A&�)A&c
�6�tj��5}tj�|d��}t|��t
|d��}|�ddg|||dtj	j
|���ddd��dS#1swxYwYdS)Nr�r�r�rCr�r�s    r�test_packagezCmdLineTest.test_packageUs���
�
�
!�
!�	/�Z��g�l�l�:�z�:�:�G��W����+�G�Z�@�@�K�����j�1�;�*�J�
�(�2�C�#-�
�
/�
/�
/�		/�	/�	/�	/�	/�	/�	/�	/�	/�	/�	/�	/����	/�	/�	/�	/�	/�	/r�c
��tj��5}tj�|d��}t|��t
|d��}tj|d���}tj	|��tj|��}|�ddg|||dtjj|���ddd��dS#1swxYwYdS)Nr�r�Tr�r�rC)rr�r+r�r�rrr�r�r�rr�rTrr[r�)r2rr�r3r�r�s      r�test_package_compiledz!CmdLineTest.test_package_compiled_s��
�
�
!�
!�
	/�Z��g�l�l�:�z�:�:�G��W����+�G�Z�@�@�K�&�.�{�D�I�I�I�M��I�k�"�"�"�$�4�[�A�A�H�����j�1�8�'��Z�(�2�G�#-�
�
/�
/�
/�
	/�
	/�
	/�
	/�
	/�
	/�
	/�
	/�
	/�
	/�
	/�
	/����
	/�
	/�
	/�
	/�
	/�
	/s�B+C�C�Cc���tj��5}tj�|d��}t|��d}|�ddg||���ddd��dS#1swxYwYdS)Nr�z7'test_pkg' is a package and cannot be directly executedr�rC�rr�r+r�r�rrX)r2rr�r�s    r�test_package_errorzCmdLineTest.test_package_errorls���
�
�
!�
!�	N�Z��g�l�l�:�z�:�:�G��W����*�C��$�$�d�J�%7��*�$�M�M�M�	N�	N�	N�	N�	N�	N�	N�	N�	N�	N�	N�	N����	N�	N�	N�	N�	N�	Ns�AA-�-A1�4A1c�R�tj��5}tj�|d��}t|��tj�|d��}t|��d}|�ddg||���ddd��dS#1swxYwYdS)Nr�r�z^Cannot use package as __main__ module; 'test_pkg' is a package and cannot be directly executedr�rCr�)r2rr��main_dirr�s     r�test_package_recursionz"CmdLineTest.test_package_recursionts���
�
�
!�
!�	N�Z��g�l�l�:�z�:�:�G��W�����w�|�|�G�Z�8�8�H��X����*�C�
�$�$�d�J�%7��*�$�M�M�M�	N�	N�	N�	N�	N�	N�	N�	N�	N�	N�	N�	N����	N�	N�	N�	N�	N�	Ns�A;B�B �#B c�l�tj��5}tj|���5tj�|d��}t
|d��t|d��}tddgt�Rddi�\}}}td	krtt|����d
dz}|�
|�d��|��|�||||||dt jj��ddd��n#1swxYwYddd��dS#1swxYwYdS)N�r�r�z1import sys; print('init_argv0==%r' % sys.argv[0])r�r�r�rGFrzinit_argv0==%rr&)rr��
change_cwdr+r�r�rrr
rLr'r(r)r-r.rBrr[r�)r2rr�r3rQrRrSr]s        r�test_issue8202zCmdLineTest.test_issue8202s����
�
!�
!�	I�Z��%�:�6�6�6�
I�
I��'�,�,�z�:�>�>����"U�V�V�V�/���B�B��/��6G�i�,�i�i�i�ch�i�i���C���Q�;�%��$�s�)�)�$�$�$�+�d�2���
�
�h�o�o�g�6�6��<�<�<��"�"�;��C�#.��Z��#,�#6�#G�I�I�I�
I�
I�
I�
I�
I�
I�
I�
I�
I�
I�
I����
I�
I�
I�
I�	I�	I�	I�	I�	I�	I�	I�	I�	I�	I�	I�	I����	I�	I�	I�	I�	I�	Is5�D)�CD�D)�D	�D)�D	�D)�)D-�0D-c��tj��5}tj|���5tddd���5}|�d��tddd�	��\}}}td
krtt|����ddz}|�	|�
d��|��ddd��n#1swxYwYddd��n#1swxYwYddd��dS#1swxYwYdS)
Nr�rZ�wr&��encodingr5z2import sys; print("sys.path[0]==%r" % sys.path[0])F)rGrzsys.path[0]==%rr�)rr�r��openrar
r'r(r)r-r.)r2r�frQrRrSr]s       r�"test_issue8202_dash_c_file_ignoredz.CmdLineTest.test_issue8202_dash_c_file_ignored�s����
�
!�
!�
	A�Z��%�:�6�6�6�	
A�	
A��$��g�6�6�6�A�!��G�G�F�O�O�O�#3�D�L�#(�$*�$*�$*�L�B��S���{�)��d�3�i�i�(�(�(�0�2�5�H��M�M�(�/�/�'�":�":�C�@�@�@�A�A�A�A�A�A�A�A�A�A�A����A�A�A�A�	
A�	
A�	
A�	
A�	
A�	
A�	
A�	
A�	
A�	
A�	
A����	
A�	
A�	
A�	
A�
	A�
	A�
	A�
	A�
	A�
	A�
	A�
	A�
	A�
	A�
	A�
	A����
	A�
	A�
	A�
	A�
	A�
	AsX�C9�C!�BC
�>C!�
C�C!�C�C!�C9�!C%	�%C9�(C%	�)C9�9C=�C=c
���tj��5}t|d��}tj|���5t	ddd���5}|�d��t
ddgt�Rdd	i�\}}}|�||||||d
tj
j��ddd��n#1swxYwYddd��n#1swxYwYddd��dS#1swxYwYdS)N�otherr�r�r�r&r�r5rGFr�)rr�rr�r�rar
rLrBrr[r�)r2rr3r�rQrRrSs       r�"test_issue8202_dash_m_file_ignoredz.CmdLineTest.test_issue8202_dash_m_file_ignored�s���
�
!�
!�		L�Z�+�J��@�@�K��%�:�6�6�6�
L�
L��$��g�6�6�6�L�!��G�G�F�O�O�O�#3�D�'�$F�L�$F�$F�$F�?D�$F�$F�L�B��S��&�&�{�B��&1�;�
�B�&/�&9�&J�L�L�L�	L�L�L�L�L�L�L�L�L�L�L����L�L�L�L�
L�
L�
L�
L�
L�
L�
L�
L�
L�
L�
L����
L�
L�
L�
L�		L�		L�		L�		L�		L�		L�		L�		L�		L�		L�		L�		L����		L�		L�		L�		L�		L�		LsY�&C#�C�
AB4�(C�4B8�8C�;B8�<C�?C#�C	�C#�C	�C#�#C'�*C'c��tj��5}tj�|d��}t|ddd���5}|�d��|�d��td��D]}|�d	���|�d��ddd��n#1swxYwYtj|�
��5t|��\}}}ddd��n#1swxYwY|�
d|��|�
d|��ddd��dS#1swxYwYdS)Nz
issue20884.pyr��latin1�
)r��newlinez#coding: iso-8859-1
z"""
�zQxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
r�r)rr�r+r�r�r�ra�ranger�r
r*)r2rr3r��_rQrRrSs        r�test_issue20884zCmdLineTest.test_issue20884�s����
�
!�
!�	'�Z��'�,�,�z�?�C�C�K��k�3��4�H�H�H�
!�A����/�0�0�0����� � � ��r���+�+�A��G�G�M�*�*�*�*����� � � �
!�
!�
!�
!�
!�
!�
!�
!�
!�
!�
!����
!�
!�
!�
!��%�:�6�6�6�
=�
=�/��<�<���C��
=�
=�
=�
=�
=�
=�
=�
=�
=�
=�
=����
=�
=�
=�
=����S�#�&�&�&����S�#�&�&�&�	'�	'�	'�	'�	'�	'�	'�	'�	'�	'�	'�	'����	'�	'�	'�	'�	'�	'sZ�4D?�A'B;�/D?�;B?	�?D?�B?	�D?�C;�/D?�;C?	�?D?�C?	�/D?�?E�Ec'�K�tj��5}tj|���5tj�|d��}t
|g|�R�|V�ddd��n#1swxYwYddd��dS#1swxYwYdS)Nr�r�)rr�r�r+r�r�r)r2�argsrr�s    r�setup_test_pkgzCmdLineTest.setup_test_pkg�s����
�
�
!�
!�	�Z��$�*�5�5�5�	�	��g�l�l�:�z�:�:�G��W�$�t�$�$�$�$��M�M�M�		�	�	�	�	�	�	�	�	�	�	����	�	�	�	�	�	�	�	�	�	�	�	�	�	�	�	����	�	�	�	�	�	s4�B�2A*�B�*A.	�.B�1A.	�2B�B�	Bc��tdg|�Rddi�\}}}tdkrtt|����|�|d��|S)Nr�rGFr)rr'r(r)r*)r2r�rQrRrSs     r�check_dash_m_failurez CmdLineTest.check_dash_m_failure�s`��,�T�K�D�K�K�K�U�K�K���C���Q�;�	��$�s�)�)��������Q�����
rc���|���5}t|dd��}|jdgt�R�}|�d|��ddd��dS#1swxYwYdS)Nr�z+if __name__ == '__main__': raise ValueErrorztest_pkg.others
ValueError)r�rr�rLr-)r2r�r3rSs    r�test_dash_m_error_code_is_onez)CmdLineTest.test_dash_m_error_code_is_one�s����
 �
 �
"�
"�	.�g�+�G�W�,Y�[�[�K�+�$�+�,<�L�|�L�L�L�C��M�M�-��-�-�-�		.�	.�	.�	.�	.�	.�	.�	.�	.�	.�	.�	.����	.�	.�	.�	.�	.�	.s�;A�A!�$A!c� �d}|D]�\}}|�|��5td|��\}}}|�|d��|�||��|�d|��ddd��n#1swxYwY��dS)N))�builtinssNo code object available)z
builtins.xs=Error while finding module specification.*ModuleNotFoundError)zbuiltins.x.ys]Error while finding module specification.*ModuleNotFoundError.*No module named.*not a package)rs=No module named.*is a package and cannot be directly executed)zimportlib.nonexistentsNo module named)z	.unittests#Relative module names not supportedr�r�	Traceback)�subTestrr*�assertRegex�assertNotIn)r2�tests�name�regexrQr�rSs       r�test_dash_m_errorszCmdLineTest.test_dash_m_errors�s���

��!�	4�	4�K�D�%����d�#�#�
4�
4�2�4��>�>�
��A�s�� � ��Q�'�'�'�� � ��e�,�,�,�� � ��s�3�3�3�	
4�
4�
4�
4�
4�
4�
4�
4�
4�
4�
4����
4�
4�
4�
4��	4�	4s�AB�B	�	B	c���tj��5}tj|���5tjd��tdd��5	ddd��n#1swxYwY|�d��}|�|d��|�d|��|�d|��ddd��n#1swxYwYddd��dS#1swxYwYdS)Nr�r�ztest_pkg/__init__.pyc�wbsGError while finding module specification.*ImportError.*bad magic numbersis a packager�)	rr�r�r+�mkdirr�r�rr�r2rrSs   r�test_dash_m_bad_pyczCmdLineTest.test_dash_m_bad_pyc�s���
�
�
!�
!�	0�Z��$�*�5�5�5�	0�	0��H�Z� � � ��-�t�4�4�
�
��
�
�
�
�
�
�
�
�
�
�
����
�
�
�
��+�+�J�7�7�C����S�2�
3�
3�
3�
���_�c�2�2�2����\�3�/�/�/�	0�	0�	0�	0�	0�	0�	0�	0�	0�	0�	0����	0�	0�	0�	0�	0�	0�	0�	0�	0�	0�	0�	0�	0�	0�	0�	0����	0�	0�	0�	0�	0�	0sY�C#�%C�A�C�A!�!C�$A!�%AC�?C#�C	�C#�C	�C#�#C'�*C'c�`�tj��5}tj|���5tdd��5	ddd��n#1swxYwY|�d��}|�d|��ddd��n#1swxYwYddd��dS#1swxYwYdS)Nr�z
asyncio.pyrs>Try using 'asyncio' instead of 'asyncio.py' as the module name)rr�r�r�r�r-r
s   r�*test_hint_when_triying_to_import_a_py_filez6CmdLineTest.test_hint_when_triying_to_import_a_py_file�s���
�
�
!�
!�	F�Z��$�*�5�5�5�	F�	F��l�D�)�)�
�
��
�
�
�
�
�
�
�
�
�
�
����
�
�
�
��+�+�L�9�9�C��M�M�@�AD�
F�
F�
F�
	F�	F�	F�	F�	F�	F�	F�	F�	F�	F�	F����	F�	F�	F�	F�	F�	F�	F�	F�	F�	F�	F�	F�	F�	F�	F�	F����	F�	F�	F�	F�	F�	FsV�B#�B�A	�B�	A
�
B�A
�.B�?B#�B	�B#�B	�B#�#B'�*B'c��ttttf}|D]�}|j}d�|��}|�|��5|�|��5}|�d��}|�	|�
d��|��|�	d|��|�	d|��ddd��n#1swxYwYddd��n#1swxYwY��dS)Nz%raise {0}('Exception in __init__.py')r��asciisException in __init__.pyr�)�ImportError�AttributeError�	TypeError�
ValueError�__name__�formatrr�r�r-r.)r2�
exceptions�	exception�initr�rSs      r�test_dash_m_init_tracebackz&CmdLineTest.test_dash_m_init_tracebackss��"�>�9�j�I�
�#�	1�	1�I�!�*�I�:�A�A�)�L�L�D����i�(�(�
1�
1��'�'��-�-�
1�18��/�/�
�;�;���
�
�i�.�.�w�7�7��=�=�=��
�
�9�3�?�?�?��
�
�l�C�0�0�0�
1�
1�
1�
1�
1�
1�
1�
1�
1�
1�
1����
1�
1�
1�
1�
1�
1�
1�
1�
1�
1�
1�
1�
1�
1�
1����
1�
1�
1�
1��	1�	1s7�C4�&A+C�C4�C!�!C4�$C!�%C4�4C8	�;C8	c�4�|���5}d}t|d|��|�d��}|�d|��|�d|��|�d|��ddd��dS#1swxYwYdS)Nz1raise ImportError('Exception in __main__ module')r�r�sImportErrorsException in __main__ moduler�)r�rr�r-)r2r��mainrSs    r�test_dash_m_main_tracebackz&CmdLineTest.test_dash_m_main_tracebacks���
�
 �
 �
"�
"�	-�g�F�D��g�z�4�8�8�8��+�+�J�7�7�C��M�M�.�#�.�.�.��M�M�9�3�?�?�?��M�M�,��,�,�,�
	-�	-�	-�	-�	-�	-�	-�	-�	-�	-�	-�	-����	-�	-�	-�	-�	-�	-s�A+B
�
B�Bc�x�tjd��}tj��5}t	|d|��}t|��\}}}|�d���d��}|�t|��d��|�
|d�d����|�
|d�d	����|�
|d
�d����ddd��dS#1swxYwYdS)Nz|            try:
                raise ValueError
            except:
                raise NameError from None
            r�rr��r�	Tracebackrz  File ��	NameError)�textwrap�dedentrr�rr�decode�splitr*�lenr��
startswith�r2r�rr3�exitcoderkrf�texts        r�test_pep_409_verbiagez!CmdLineTest.test_pep_409_verbiagesX����"�����
�
!�
!�	=�Z�+�J��&�I�I�K�'<�[�'I�'I�$�H�f�f��=�=��)�)�/�/��5�5�D����S��Y�Y��*�*�*��O�O�D��G�.�.�{�;�;�<�<�<��O�O�D��G�.�.�y�9�9�:�:�:��O�O�D��G�.�.�{�;�;�<�<�<�	=�	=�	=�	=�	=�	=�	=�	=�	=�	=�	=�	=����	=�	=�	=�	=�	=�	=s�C:D/�/D3�6D3c�L�tjr-tjdvrt	jtj��}n.tjr
tj}n|�d��d}tt	j	��||��}|�
tj|��t|��\}}}|�
t|��|����d��d|�d|����|�
d|��dS)N)�win32�darwin�
emscripten�wasizneed os_helper.TESTFN_NONASCIIzprint(ascii(__file__))
rzstdout=z stderr=r)r�TESTFN_UNDECODABLEr/�platformr+�fsdecode�TESTFN_NONASCII�skipTestrr,�
addCleanup�unlinkr
r*r�rstripr$)r2rrr3rQrkrfs       r�test_non_asciizCmdLineTest.test_non_ascii-s��

�(�	<��L� I�I�	<��;�y�;�<�<�D�D�
�
&�	<��,�D�D��M�M�:�;�;�;�,��'��	���T�6�B�B�����	�(�+�6�6�6�-�k�:�:���F�F�����+����M�M�O�O�"�"�7�+�+�+�%+�V�V�V�V�4�	6�	6�	6�	
����B�����rc�H�tjd��}tj��5}t	|d|��}t|��\}}}|�d��}|�|���d��ddd��dS#1swxYwYdS)Nz�            import sys
            error = None
            try:
                raise ValueError('some text')
            except ValueError as err:
                error = err

            if error:
                sys.exit(error)
            r�rz	some text)	r"r#rr�rrr$r*r8r(s        r�)test_issue20500_exit_with_exception_valuez5CmdLineTest.test_issue20500_exit_with_exception_valueEs�����
"�
�
���
�
!�
!�	9�Z�+�J��&�I�I�K�'<�[�'I�'I�$�H�f�f��=�=��)�)�D����T�[�[�]�]�K�8�8�8�		9�	9�	9�	9�	9�	9�	9�	9�	9�	9�	9�	9����	9�	9�	9�	9�	9�	9s�A"B�B�Bc�H�d}tj��5}t|d|��}t|��\}}}t	jt	j|��d�����}|�d|��ddd��dS#1swxYwYdS)Nz
1 + 1 = 2
r�rz
    ^^^^^
)	rr�rr�io�
TextIOWrapper�BytesIOrlr-r(s        r�*test_syntaxerror_unindented_caret_positionz6CmdLineTest.test_syntaxerror_unindented_caret_positionWs�����
�
�
!�
!�	1�Z�+�J��&�I�I�K�'<�[�'I�'I�$�H�f�f��#�B�J�v�$6�$6��@�@�E�E�G�G�D��M�M�/�4�0�0�0�	1�	1�	1�	1�	1�	1�	1�	1�	1�	1�	1�	1����	1�	1�	1�	1�	1�	1s�A4B�B�Bc��tjd��}tj��5}t	|d|��}t|��\}}}t
jt
j|��d���	��}|�
d|��d}t	|d|��}t|��\}}}t
jt
j|��d���	��}|�d|��|�
d|��ddd��dS#1swxYwYdS)Nz;            if True:
                1 + 1 = 2
            r�rz
    1 + 1 = 2
    ^^^^^
zif True:
    1 + 1 = 2
�)r"r#rr�rrr=r>r?rlr-rr(s        r�(test_syntaxerror_indented_caret_positionz4CmdLineTest.test_syntaxerror_indented_caret_position`s�����"�����
�
!�
!�	@�Z�+�J��&�I�I�K�'<�[�'I�'I�$�H�f�f��#�B�J�v�$6�$6��@�@�E�E�G�G�D��M�M�8�$�?�?�?�$�
�,�J��&�I�I�K�'<�[�'I�'I�$�H�f�f��#�B�J�v�$6�$6��@�@�E�E�G�G�D����T�4�(�(�(��M�M�8�$�?�?�?�!	@�	@�	@�	@�	@�	@�	@�	@�	@�	@�	@�	@����	@�	@�	@�	@�	@�	@s�C?D4�4D8�;D8c��d}tj��5}t|d|��}t|��\}}}|�|���dd�gd���ddd��dS#1swxYwYdS)Nzfoo = f"""{}
foo"""
r����)s
    foo"""s          ^s3SyntaxError: f-string: empty expression not allowed�rr�rrr*�
splitlines�r2r�rr3r)rkrfs       r�#test_syntaxerror_multi_line_fstringz/CmdLineTest.test_syntaxerror_multi_line_fstringws���)��
�
�
!�
!�
	�Z�+�J��&�I�I�K�'<�[�'I�'I�$�H�f�f�����!�!�#�#�B�C�C�(����
�
�
�
	�
	�
	�
	�
	�
	�
	�
	�
	�
	�
	�
	����
	�
	�
	�
	�
	�
	s�AA:�:A>�A>c��d}tj��5}t|d|��}td|��\}}}|�|���dd�gd���ddd��dS#1swxYwYdS)Nzfoo = """\q"""
r�z-WerrorrE)s    foo = """\q"""s          ^^^^^^^^s)SyntaxError: invalid escape sequence '\q'rFrHs       r�3test_syntaxerror_invalid_escape_sequence_multi_linez?CmdLineTest.test_syntaxerror_invalid_escape_sequence_multi_line�s���$��
�
�
!�
!�	�Z�+�J��&�I�I�K�'<��;�(�(�$�H�f�f�
����!�!�#�#�B�C�C�(����
�
�
�	�	�	�	�	�	�	�	�	�	�	�	����	�	�	�	�	�	s�AA;�;A?�A?c�h�tjd��}d|_tj��5}tj��5}t|d|��}t
d||���}t|������	��}|�
|d|��|�||��t
d||���}t|������	��}|�
||��t
d||���}t|������	��}|�
|||��ddd��n#1swxYwYddd��dS#1swxYwYdS)N�c            import sys
            for entry in sys.path:
                print(entry)
            r�z-EsrCrz-I)r"r#�maxDiffrr�rrr
r$rGr*r)	r2r��work_dirrr3rc�out_by_name�
out_by_dir�out_by_dir_isolateds	         r�-test_consistent_sys_path_for_direct_executionz9CmdLineTest.test_consistent_sys_path_for_direct_execution�s.����"�������
�
�
!�
!�	K�X�y�/A�/C�/C�	K�z�+�J�
�F�K�K�K��U�K�X�>�>�>�A�%�a�.�.�/�/�1�1�<�<�>�>�K����[��^�Z�8�8�8����X�{�3�3�3��U�J�H�=�=�=�A�$�Q���.�.�0�0�;�;�=�=�J����Z��5�5�5��T�:�8�<�<�<�A�"-�a�.�.�"7�"7�"9�"9�"D�"D�"F�"F�����0�*�k�J�J�J�	K�	K�	K�	K�	K�	K�	K�	K�	K�	K�	K����	K�	K�	K�	K�	K�	K�	K�	K�	K�	K�	K�	K�	K�	K�	K�	K����	K�	K�	K�	K�	K�	Ks6�F'�EF�F'�F	�F'�F	�F'�'F+�.F+c�r�tjd��}d|_tj��5}t
j�|d��}tj|��t|d|��}tdd|���}t|������
��}|�|d|��|�||��tdd|���}t|������
��}|�||��t!dd|���\}}	}
|
����
��}|�d	|d
��ddd��dS#1swxYwYdS)NrM�
script_pkgr�z-smzscript_pkg.__main__rCrz-ImzNo module named script_pkg���)r"r#rNrr�r+r�r�r	rrr
r$rGr*rrr-)r2r�rOrr3rc�
out_by_module�out_by_packager)rkrf�traceback_liness            r�-test_consistent_sys_path_for_module_executionz9CmdLineTest.test_consistent_sys_path_for_module_execution�s�����"�������
�
�
!�
!�	M�X�����h��=�=�J��H�Z� � � �+�J�
�F�K�K�K��U�$9�x�H�H�H�A�'��N�N�1�1�3�3�>�>�@�@�M����]�1�-�x�8�8�8����Z��7�7�7��U�L�h�?�?�?�A�(��^�^�2�2�4�4�?�?�A�A�N����^�]�;�;�;�'<��|��(�(�(�$�H�f�f�%�m�m�o�o�8�8�:�:�O��M�M�6���8K�L�L�L�)	M�	M�	M�	M�	M�	M�	M�	M�	M�	M�	M�	M����	M�	M�	M�	M�	M�	Ms�E0F,�,F0�3F0c�L�d}|�tj�|����t	|dt
jt
j���}|���\}}|�d|��|�	|j
d��dS)Nznonexistingscript.pyT)r*rkrfz: can't open file r)�assertFalser+r��existsrrhri�communicater-�assertNotEqual�
returncode)r2r��procrRrSs     r�test_nonexisting_scriptz#CmdLineTest.test_nonexisting_script�s���
(����������/�/�0�0�0��F��#-�?�#-�?�4�4�4���#�#�%�%���S��
�
�*�C�0�0�0����D�O�Q�/�/�/�/�/rr)F)9r�
__module__�__qualname__rBrTrXr^rd�
contextlib�contextmanagerrprsruryr}r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�rrr
rrr+r9r;r@rCrIrKrSrZrb�rrr$r$\s�������<@�9�9�9�9�D59�
C�
C�
C�
C�
C� 59�9�9�9�9�9� %�%�%�
%�%�%���������&B�B�B�B�C�C�C�C�'�'�'�+�+�+�'�'�'�+�+�+�8�8�8�
E�
E�
E�I�I�I�E�E�E�I�I�I�6�6�6�
6�6�6�6�6�6�6�6�6�6�6�6�4�4�4�/�/�/�D�D�D�D�D�D�/�/�/�/�/�/�N�N�N�	N�	N�	N�I�I�I�"
A�
A�
A�L�L�L�'�'�'�"����������.�.�.�4�4�4�(0�0�0�F�F�F�1�1�1�-�-�-�=�=�=�$ � � �09�9�9�$1�1�1�@�@�@�.���
�
�
�K�K�K�>#M�#M�#M�J
0�
0�
0�
0�
0rr$c�,�tj��dSr)r�
reap_childrenrgrr�tearDownModulerj�s��������rr�)$rer�importlib.machineryr��unittestr/r+�os.pathr�rhr=r"�testr�test.supportrr�test.support.script_helperrrrr	r
rrr
r'rL�test_sourcerr"�TestCaser$rjrrrgrr�<module>rss�����������������������
�
�
�
�	�	�	�	�������������	�	�	�	�����������&�&�&�&�&�&�"�"�"�"�"�"�H�H�H�H�H�H�H�H�H�H�H�H�H�H�H�H�H�H�H�H��/��*�*�*��3��j;F�����*������I
0�I
0�I
0�I
0�I
0�(�#�I
0�I
0�I
0�X����z����H�M�O�O�O�O�O��r