HEX
Server: Apache
System: Linux bd12.noc223.com 4.18.0-553.121.1.lve.el8.x86_64 #1 SMP Thu Apr 30 16:40:41 UTC 2026 x86_64
User: handcraf (1693)
PHP: 8.1.28
Disabled: NONE
Upload Files
File: //opt/alt/python312/lib64/python3.12/test/__pycache__/test_cmd_line.cpython-312.opt-1.pyc
�

�h�e"����ddlZddlZddlZddlZddlZddlZddlmZddlm	Z	ddl
mZmZm
Z
mZmZej sej"d��d�ZGd�dej&�Zej*e�d	�Gd
�dej&��ZGd�d
ej&�Zd�Zedk(rej4�yy)�N)�support)�	os_helper)�spawn_python�kill_python�assert_python_ok�assert_python_failure� interpreter_requires_environmentztest module requires subprocessc�@�t|�}|j�}||fS�N)r�wait)�p�data�
returncodes   �9/opt/alt/python312/lib64/python3.12/test/test_cmd_line.py�_kill_python_and_exit_coders!���q�>�D�����J�����c�f�eZdZd�Zd�Zd�Zd�Zd�Zd�Zd�Z	d�Z
d	�Zd
�Ze
je�d�d��Zd
�Zd�Zd�Zd�Zd�Zd�Ze
j.ej2d�d��Ze
j.ej2d�d��Ze
jej:dk(d�d��Ze
jej:dk(d�d��Ze
j.ej:dk(xse jBd�d��Z"d�Z#d�Z$d�Z%d �Z&e
jejNjPd!�d"��Z)d#�Z*d$�Z+d%�Z,d&�Z-d'�Z.d(�Z/d)�Z0d*�Z1e
je2jfd+k7d,�e
jej:d-k(d.�d/���Z4d0�Z5d1�Z6d2�Z7d3�Z8d4�Z9d5�Z:d6�Z;e
je�d7�d8��Z<d9�Z=d:�Z>d;d;d<�d=�Z?d>�Z@dId?�ZAd@�ZBdA�ZCdB�ZDdC�ZEe
j.ej:dk(dD�dE��ZFdF�ZGdG�ZHyH)J�CmdLineTestc�0�td�td�y)N�.z< .)r��selfs r�test_directorieszCmdLineTest.test_directoriess���c�"��e�$rc��t|�\}}}|j|dk(xs|jd��|jd|�|jd|�|S)Nr�
s	Traceback)r�
assertTrue�endswith�assertNotIn)r�cmd_line�rc�out�errs     r�verify_valid_flagzCmdLineTest.verify_valid_flag"sU��'��1���C������s�
�9�c�l�l�5�&9�:�����s�+�����s�+��
rc�2�|jd�|jd�|jd�}|j�}|jd|d�|jd|�|jd|�|j	t|�d�y)	Nz-hz-?z--help�usager�
PYTHONHOME�-X dev�2)r#�
splitlines�assertInr�
assertLess�len�rr!�liness   r�	test_helpzCmdLineTest.test_help)s~�����t�$����t�$��$�$�X�.����� ���
�
�h��a��)������,�����C�(�����E�
�B�'rc�J�|jd�}|jd|�y)Nz
--help-envr&�r#r*�rr!s  r�
test_help_envzCmdLineTest.test_help_env3s ���$�$�\�2���
�
�m�S�)rc�J�|jd�}|jd|�y)Nz--help-xoptionsr'r1r2s  r�test_help_xoptionszCmdLineTest.test_help_xoptions7s!���$�$�%6�7���
�
�i��%rc��|jd�}|j�}|jd|d�|jd|�|jd|�dj|dd�j	d�y)	Nz
--help-allr%rr&r'r��ascii)r#r)r*�join�decoder-s   r�
test_help_allzCmdLineTest.test_help_all;sk���$�$�\�2����� ���
�
�h��a��)��
�
�m�S�)��
�
�i��%�	����q�r���"�"�7�+rc�H�|jd�|jd�y)Nz-Oz-OO�r#rs r�
test_optimizezCmdLineTest.test_optimizeFs�����t�$����u�%rc�&�|jd�y)N�-Sr=rs r�test_site_flagzCmdLineTest.test_site_flagJs�����t�$rc��dtjddzjd�}dD]Q}t|�\}}}|j	|j|��|j
|j|���Sy)NzPython %d.%d�r8)z-Vz	--versionz-VV)�sys�version_info�encoder�assertFalse�
startswithr)r�version�switchr r!r"s      r�test_versionzCmdLineTest.test_versionMso��!�C�$4�$4�R�a�$8�8�@�@��I��.�	5�F�+�F�3�L�B��S����S�^�^�G�4�5��O�O�C�N�N�7�3�4�	5rc��td�\}}}|jd|�td�\}}}|jd|�y)Nz-vsstack overflowz-vv)rr�rr r!r"s    r�test_verbosezCmdLineTest.test_verboseTsF��(��-���C�����*�C�0�'��.���C�����*�C�0rz6Cannot run -E tests when PYTHON env vars are required.c�x�d�}|�}|j|i�|dd�}|j|ddd��y)Nc��tjdf|z}|dz
}tj|�}t	|j�d�}|S)N�-E)�-c� import sys; print(sys._xoptions)r)rD�
executable�
subprocess�check_output�evalr))�argsr!�optss   r�get_xoptionsz/CmdLineTest.test_xoptions.<locals>.get_xoptions`sM���N�N�D�)�D�0�D��>�>�D��)�)�$�/�C�����(��+�,�D��Krz-Xaz	-Xb=c,d=eTzc,d=e)�a�b)�assertEqual)rrZrYs   r�
test_xoptionszCmdLineTest.test_xoptions]sA��	��~������r�"��E�;�/������T��8�9rc�\���fd�}d}|d|�\}}}�j|j�d��j|d�|dddd|�\}}}�j|j�d	�tjr�j	|d
�y�j|d�y)Nc�l��tjg}|j|�tj}tj
|||��}|j
�\}}|jj�|jj�|j}�j|d�|||fS)N��stdout�stderrr)rDrT�extendrU�PIPE�Popen�communicaterb�closercrr])rX�cmdrer
r!r"r rs       �r�
run_pythonz1CmdLineTest.test_showrefcount.<locals>.run_pythonps�����>�>�"�C��J�J�t���?�?�D�� � ��T�$�?�A��}�}��H�C��
�H�H�N�N��
�H�H�N�N�����B����R��#��s�C�<�rrSrRs{}r�-I�-X�showrefcounts{'showrefcount': True}s^\[-?\d+ refs, \d+ blocks\])r]�rstripr�Py_DEBUG�assertRegex)rrj�coder r!r"s`     r�test_showrefcountzCmdLineTest.test_showrefcountos����
	 �2��!�$��-���C���������u�-�����c�"�!�$��n�d�D�I���C���������'@�A����
���S�"A�B����S�#�&rc���hd�}|D][\}}dd|��ddg}|j|�5t|�}|j|jj	d�|�ddd��]y#1swY�hxYw)N>�z=on�FrozenImporter�z=off�SourceFileLoader��ru��=rurl�frozen_modulesrRz,import os; print(os.__spec__.loader, end="")�utf-8)�subTestrrpr!r:)r�tests�raw�expectedri�ress      r�test_xoption_frozen_modulesz'CmdLineTest.test_xoption_frozen_modules�s���
��#�	D�M�C���>�#��/��G�I�C����c�"�
D�&��,��� � �������!8�(�C�
D�
D�	D�
D�
D�s�4A&�&A/	c�h�td�tdd�tddd�tdddd�y)N�-m�
fnord43520xyz�runpy�timeit�-n�1�rrrs r�test_run_modulezCmdLineTest.test_run_module�s2��	�d�#��d�O�4�	�d�G�_�=���x��s�3rc�0�tddddd�}|jjd�|jjd�t|�}|j	|jd�d	k7�|j	|jd
�d	k7�y)N�-ir�r�r�r�sTimer
�exit()
s1 loop���s__main__.Timer)r�stdin�writerr�find)rr
rs   r�test_run_module_bug1764407z&CmdLineTest.test_run_module_bug1764407�st��
��t�X�t�S�9��	���
�
�j�!�	���
�
�k�"��1�~������	�	�)�,��2�3�����	�	�"3�4��:�;rc���tjjt�j	d�}tj|�5tddd�tddd�ddd�y#1swYyxYw)N�testr��unittestztest/test_longexp.pyz./test/test_longexp.py)�os�path�dirname�__file__�removesuffixr�
change_cwdr)r�projectlibpaths  r�test_relativedir_bug46421z%CmdLineTest.test_relativedir_bug46421�sb��������2�?�?��G��
�
!�
!�.�
1�	I��T�:�/E�F��T�:�/G�H�	I�	I�	I�s�A,�,A5c�J�td�tdd�tdd�y)NrRzraise Exception�passr�rs r�
test_run_codezCmdLineTest.test_run_code�s!��	�d�#��d�$5�6���v�&rzneed os_helper.FS_NONASCIIc�x�dtj�dttj��d�}td|�y)Nzassert(ord(z) == �)rR)r�FS_NONASCII�ordr)r�commands  r�test_non_asciizCmdLineTest.test_non_ascii�s,�� �+�+�S��1F�1F�-G�I����w�'rc���tj}d|�d�}td|�}|j|jj�t
|�jd��y)Nz# coding: latin1
print(ascii('z'))rRr8)rr�rr]r!rnr8rF)r�chrir�s    r�test_codingzCmdLineTest.test_coding�sS���
"�
"��/��t�3�7���t�S�)����������)�5��9�+;�+;�G�+D�Er�win32z Windows has a native unicode APIc���d}tjj�}d|d<d|d<d|zdz}tjt
jd|gtjtj|�	�}|j�\}}|jd
k(rd}n-|jdk(rd
}ntd|j�d|����|j|�st|�d|����y)N���C�LC_ALL�0�PYTHONCOERCECLOCALEsimport locale; print(ascii("s"), locale.getencoding())rR)rbrc�envr7s3Unable to decode the command from the command line:rs'\xff' zUnknown exit code: z	, output=z doesn't start with )
r��environ�copyrUrfrDrTre�STDOUTrgr�AssertionErrorrH)r�undecodabler�rqr
rbrc�patterns        r�test_undecodable_codez!CmdLineTest.test_undecodable_code�s������j�j�o�o�����H�
�%(��!�"�
�*�
+�.)�
)�	
�
���
�^�^�T�4�(��?�?�:�+<�+<��
����������<�<�1��
M�G�
�\�\�Q�
�"�G�!�q�|�|�U[�!\�]�]�� � ��)� �v�w�!O�P�P�*rc	�>�
�d�
�
fd�}�
fd�}�
fd�}djd�}d}||g}|||fD]`}|j|��5|D]=}||�}	|j|	jj	�t|���?	ddd��by#1swY�mxYw)	Nz;import sys, os; s=os.fsencode(sys.argv[1]); print(ascii(s))c�x��tjd�|g}tj|tjd��S)NrRT�rb�text�rDrTrU�runre��argrirqs  �r�run_defaultz6CmdLineTest.test_invalid_utf8_arg.<locals>.run_defaults,����>�>�4��s�3�C��>�>�#�j�o�o�D�I�Irc���tjd�|g}ttj�}d|d<tj|t
jd|��S)NrRr�r�T)rbr�r�)rDrT�dictr�r�rUr�re)r�rir�rqs   �r�run_c_localez7CmdLineTest.test_invalid_utf8_arg.<locals>.run_c_localesJ����>�>�4��s�3�C��r�z�z�"�C��C��M��>�>�#�j�o�o�'+��6�
6rc�|��tjddd�|g}tj|tjd��S)Nrl�utf8rRTr�r�r�s  �r�
run_utf8_modez8CmdLineTest.test_invalid_utf8_arg.<locals>.run_utf8_modes0����>�>�4���t�S�A�C��>�>�#�j�o�o�D�I�Ir�e:é, euro:€, non-bmp:􏿿r}s��é�������)�run_cmd)rFr~r]rbrnr8)rr�r�r��
valid_utf8�invalid_utf8�	test_argsr�r��procrqs          @r�test_invalid_utf8_argz!CmdLineTest.test_invalid_utf8_arg�s����M��	J�	6�	J�?�E�E�g�N�
�
(�	� ��.�	�#�\�=�A�	G�G����g��.�
G�$�G�C�"�3�<�D��$�$�T�[�[�%7�%7�%9�5��:�F�G�
G�
G�	G�
G�
G�s
�AB�B	�darwinz%test specific to Mac OS X and Androidc��djd�}d}|jdd�}t|�jd�dz}tjj�}d|d<t
jtjd	||ftj|�
�}|j�\}}|j||�|j|jd�y)Nr�r}z%import sys; print(ascii(sys.argv[1]))�surrogateescaper8rr�r�rR)rbr�r)rFr:r8r�r�r�rUrfrDrTrergr]r)	rr�rq�decodedr�r�r
rbrcs	         r�test_osx_android_utf8z!CmdLineTest.test_osx_android_utf8(s���9�?�?��H��6���+�+�g�'8�9����>�(�(��1�E�9���j�j�o�o�����H�
����
�^�^�T�4��.��?�?��
��������������*�������q�)rc��tjd�}tjd|g}t	j
|tjtjdd��}|j|jd�y)Nz�
            import sys
            out = sys.stdout
            print(out.isatty(), out.write_through, out.line_buffering)
            err = sys.stderr
            print(err.isatty(), err.write_through, err.line_buffering)
        rRT)rbrcr��checkz#False False False
False False True
)	�textwrap�dedentrDrTrUr�rer]rb)rrqrXr�s    r�%test_non_interactive_output_bufferingz1CmdLineTest.test_non_interactive_output_buffering>sb����� �
������d�+���~�~�d�:�?�?�%/�_�_�4�t�M��������.�	/rc���dD]l}d|z}tdd|�\}}}|dk(r|n|}|j|dd|z�d|z}tdd|�\}}}|dk(r|n|}|j|dd	|z��ny)
Nraz6import os, sys; sys.%s.buffer.write(b'x'); os._exit(0)�-urRrc�xzbinary %s not unbufferedz.import os, sys; sys.%s.write('x'); os._exit(0)ztext %s not unbuffered�rr])r�streamrqr r!r"rs       r�test_unbuffered_outputz"CmdLineTest.test_unbuffered_outputMs���*�	L�F�L���D�+�D�$��=�L�B��S� �H�,�3�#�D����T�4�)C�f�)L�M�D���D�+�D�$��=�L�B��S� �H�,�3�#�D����T�4�)A�F�)J�K�	Lrc��d}tdd|�}|jjd�|jj�t	|�\}}|j|d�|j
|jd�|�y)Nz/import sys; sys.stdout.write(sys.stdin.read(1))r�rRr�r)rr�r��flushrr]rrH)rrqr
rr s     r�test_unbuffered_inputz!CmdLineTest.test_unbuffered_input]sg��A����t�T�*��	���
�
�d��	���
�
��-�a�0���b�����Q���������-�t�4rc���d}d}|tjz|z}d}tdd||��\}}}|j|j	d�|�|j|j	d�|�y)N��ABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDE��FGHIJFGHIJFGHIJFGHIJFGHIJFGHIJFGHIJFGHIJFGHIJFGHIJFGHIJFGHIJFGHIJFGHIJFGHIJFGHIJFGHIJFGHIJFGHIJFGHIJFGHIJFGHIJFGHIJFGHIJFGHIJFGHIJFGHIJFGHIJFGHIJFGHIJFGHIJFGHIJFGHIJFGHIJFGHIJFGHIJFGHIJFGHIJFGHIJFGHIJFGHIJFGHIJFGHIJFGHIJFGHIJFGHIJFGHIJFGHIJFGHIJFGHIJFGHIJFGHIJFGHIJFGHIJFGHIJFGHIJFGHIJFGHIJFGHIJFGHIJFGHIJFGHIJFGHIJFGHIJFGHIJFGHIJFGHIJFGHIJFGHIJFGHIJFGHIJFGHIJFGHIJFGHIJFGHIJFGHIJFGHIJFGHIJFGHIJFGHIJFGHIJFGHIJFGHIJFGHIJFGHIJFGHIJFGHIJFGHIJFGHIJFGHIJFGHIJFGHIJFGHIJFGHIJFGHIJFGHIJFGHIJFGHIJFGHIJFGHIJ��if 1:
            import sys
            path = ":".join(sys.path)
            path = path.encode("ascii", "backslashreplace")
            sys.stdout.buffer.write(path)r@rR��
PYTHONPATHr8)r��pathseprr*rF)r�path1�path2r�rqr r!r"s        r�test_large_PYTHONPATHz!CmdLineTest.test_large_PYTHONPATHgso�������r�z�z�!�E�)��-��
(��d�D�37�9���C���
�
�e�l�l�7�+�S�1��
�
�e�l�l�7�+�S�1rz'PYTHONSAFEPATH changes default sys.pathc�t�d}td|d��\}}}td|d��\}}}|j||�y)Nr�rRryr�F)�
__isolatedr�)rrq�rc1�out1�err1�rc2�out2�err2s        r� test_empty_PYTHONPATH_issue16309z,CmdLineTest.test_empty_PYTHONPATH_issue16309vsE��-��
+�4��"�E���T�4�*�4��%�H���T�4�	
����t�$rc��dD�]}tjj�}||d<tjt
jdgtjtjtj|��}d}|jjt|�jd�dz�|jjd�t|�}t|�j|d	�}|j||���y)
N)r8zlatin-1r}�PYTHONIOENCODINGr�)r�rbrcr�ua=é b=� c=𐀀 d=􏿿r8rr��backslashreplace)r�r�r�rUrfrDrTrer�r�r�r8rFr�reprr*)r�encodingr�r
r�r�escapeds       r�test_displayhook_unencodablez(CmdLineTest.test_displayhook_unencodable�s���5�	)�H��*�*�/�/�#�C�&.�C�"�#�� � �����&� �o�o�!���!�(�(���A�?�D�
�G�G�M�M�%��+�,�,�W�5��=�>�
�G�G�M�M�+�&��q�>�D��4�j�'�'��2D�E�G��M�M�'�4�(�	)rc��tjd�5}tjj	d�}|j|j
d��|j�|jd�tjtjd|f|tj��5}|j�\}}ddd�ddd�|jj!�|�y#1swY�2xYw#1swY�6xYw)Nzwb+�ASCII)sabcsdefrrR)r�rb)�tempfile�NamedTemporaryFiler��lineseprFr�r9r��seekrUrfrDrTrergr]rn)rrqr�r��sepr�rbrcs        r�check_inputzCmdLineTest.check_input�s���
�
(�
(��
/�	4�5��*�*�#�#�G�,�C��K�K����!1�2�3��K�K�M��J�J�q�M��!�!�����t�,��J�O�O�5�
4�8<�!%�!1�!1�!3����
4�	4�	
�������(�3�	
4�
4��	4�	4�s$�BC?�.C3�C?�3C<	�8C?�?Dc�(�|jdd�y)Nz-import sys; print(repr(sys.stdin.readline()))s'abc\n'�rrs r�test_stdin_readlinezCmdLineTest.test_stdin_readline�s��	
���;��	rc�(�|jdd�y)Nzprint(repr(input()))s'abc'rrs r�test_builtin_inputzCmdLineTest.test_builtin_input�s�����"��	rc���d}td|�\}}}tjdk(r%|jd|�|jd|�y|jd|�|jd|�y)Nz�if 1:
            import sys
            print(1)
            print(2)
            print(3, file=sys.stderr)
            print(4, file=sys.stderr)rRr�s1
2
s3
4
s1
2
s3
4
)rrD�platformr]�rrqr r!r"s     r�test_output_newlinezCmdLineTest.test_output_newline�si��)��(��d�3���C���<�<�7�"����]�C�0����]�C�0����Y��,����Y��,rc��tdd�\}}}|j|jdd�d�|jd|�y)NrR�'r8�ignore�SyntaxErrorr)rrpr:r]rMs    r�test_unmached_quotezCmdLineTest.test_unmached_quote�sA��-�T�3�7���C��������G�X�6�
�F�����c�"rc��d}td|�\}}}|jd|�|jd|�|j|jdd�d�y)Nz�if 1:
            import os, sys, test.support
            test.support.SuppressCrashReport().__enter__()
            sys.stdout.write('x')
            os.close(sys.stdout.fileno())rRr�xr8rz"Exception ignored in.*
OSError: .*)rr]rpr:r
s     r�test_stdout_flush_at_shutdownz)CmdLineTest.test_stdout_flush_at_shutdown�s\��-��
-�T�4�8���C������c�"�����b�!�������G�X�6�>�	@rc�L�d}td|�\}}}|jd|�y)Nzimport sys; sys.stdout.close()rRrr�r
s     r�test_closed_stdoutzCmdLineTest.test_closed_stdout�s+��0��'��d�3���C������c�"r�posixztest needs POSIX semantics�vxworksz.test needs preexec support in subprocess.Popenc�b��dj���}�fd�}tjtjdd|gtj
tj
tj
|��}|j
�\}}|j|d�|j|jd�y)	Nz�if 1:
            import os, sys
            for i, s in enumerate({streams}):
                if getattr(sys, s) is not None:
                    os._exit(i + 1)
            os._exit(42)��streamsc���d�vrtjd�d�vrtjd�d�vrtjd�yy)Nr�rrbr7rcrC)r�rhrs�r�preexecz+CmdLineTest._test_no_stdio.<locals>.preexec�sA����'�!�������7�"�������7�"������#rrQrR)r�rbrc�
preexec_fnr�*)	�formatrUrfrDrTrergr]r)rrrqrr
r!r"s `     r�_test_no_stdiozCmdLineTest._test_no_stdio�s�����
#�F�7�F�3�	
�	�
���
�^�^�T�4��.��/�/��?�?��?�?��
 ���=�=�?���S�����c�"�������r�*rc�(�|jdg�y)Nr��r#rs r�
test_no_stdinzCmdLineTest.test_no_stdin�s�����W�I�&rc�(�|jdg�y)Nrbr%rs r�test_no_stdoutzCmdLineTest.test_no_stdout������X�J�'rc�(�|jdg�y)Nrcr%rs r�test_no_stderrzCmdLineTest.test_no_stderrr)rc�*�|jgd��y)N)r�rbrcr%rs r�test_no_std_streamszCmdLineTest.test_no_std_streamss�����9�:rc���|jd�g}tjjdd�dk7r"t	tj�}|d=d|d<ni}td�D]8}d}t
d|fi|��\}}}|j|d	�|j|��:tt|��}|jt|�d
dj|���d
}t
d|d��\}}}|jd|�t
d|d��\}}}|jd|�t
d|d��\}}}|jd|�t
dd|d��\}}}|jd|�y)Nz-R�PYTHONHASHSEED�randomr��
__cleanenv�zprint(hash("spam"))rRrr7z83 runs produced an identical random hash  for "spam": {})�msgz<import sys; print("random is", sys.flags.hash_randomization)ry�r/srandom is 1r�srandom is 0)r#r�r��getr��rangerr]�append�sorted�set�
assertGreaterr,r"r*)r�hashesr��irqr r!r"s        r�test_hash_randomizationz#CmdLineTest.test_hash_randomization
sl�����t�$���
�:�:�>�>�*�H�5��A��r�z�z�"�C��$�%� #�C����C��q��	�A�(�D�+�D�$�>�#�>�L�B��S����R��#��M�M�#��		�
��F��$�����3�v�;�� 1�17����	�	A�
N��'��d�2�F���C���
�
�n�c�*�'��d�8�L���C���
�
�n�c�*�'��d�3�G���C���
�
�n�c�*�'��d�D��M���C���
�
�n�c�*rc���tj}|jtj|�t	|dd��5}td|��td|��ddd�t
|�y#1swY�xYw)N�wr}�r�z
import sys)�filezdel sys.modules['__main__'])r�TESTFN�
addCleanup�unlink�open�printr)r�filename�scripts   r�test_del___main__zCmdLineTest.test_del___main__/se���#�#�����	�(�(�(�3�
�(�C�'�
2�	>�f��,�V�,��/�f�=�	>�	��"�	>�	>�s�A.�.A7c��tdd�\}}}|jd|�|j|j�j	d�d�|jd|�tdd��\}}}|jd|�|j|j�j	d�d�|jd|�tddd��\}}}|jd|�|jd|�|j|j�j	d�d�|jd|�y)	NrQz-zsUnknown option: -zr7r)�withoutz-asUnknown option: -a)rr*r]r)�countrrMs    r�test_unknown_optionsz CmdLineTest.test_unknown_options:s��,�T�4�8���C���
�
�+�S�1�������)�/�/�0E�F��J�����c�"�-�T�4�@���C���
�
�+�S�1�������)�/�/�0E�F��J�����c�"�,�T�4��F���C���
�
�+�S�1����.��4�������)�/�/�0E�F��J�����c�"r�6Cannot run -I tests when PYTHON env vars are required.c��|jd�|jd�tdddd��\}}}|j|j�d�t	j
�5}tjj|d�}tjj|d	�}t|d
d��5}|jd
�ddd�t|d
d��5}|jd�|jd�ddd�|jtjtjtj d|g|tj"��tjtj d|g|��}|j|j�d�ddd�y#1swY��xYw#1swY��xYw#1swYyxYw)Nrkz-IEPsrRz`from sys import flags as f; print(f.no_user_site, f.ignore_environment, f.isolated, f.safe_path)ry)�dummyvars
1 1 1 Truezuuid.pyzmain.pyr?r}r@z)raise RuntimeError('isolated mode test')
zimport uuid
zprint('ok')
rQ)�cwdrc)rQsok)r#rr]�stripr�temp_cwdr�r�r9rEr��assertRaisesrU�CalledProcessErrorrVrDrT�DEVNULL)rr r!r"�tmpdir�fake�main�fs        r�test_isolatedmodezCmdLineTest.test_isolatedmodeLs���	
���t�$����w�'�'��d�
S��	���C��
	
�������m�4�
�
�
�
!�	1�V��7�7�<�<��	�2�D��7�7�<�<��	�2�D��d�C�'�2�
F�a����D�E�
F��d�C�'�2�
)�a�����(�����(�
)�
���j�;�;�(�5�5�"�~�~�t�T�:��%/�%7�%7�
�
9��)�)�3�>�>�4��*F�.4�6�C����S�Y�Y�[�%�0�	1�	1�
F�
F��
)�
)��	1�	1�s>�*AG�9F.�G�!#F:�B!G�.F7	�3G�:G	�?G�Gc���dD]Y\}}t||||��}tt|��}d|�d|�d�}|j|��5t	d|fi|��ddd��[y#1swY�fxYw)N))ryr)r�r7)r�r7)�2rC)�PYTHONDEBUG�PYTHONOPTIMIZE�PYTHONDONTWRITEBYTECODE�
PYTHONVERBOSEz�import sys; sys.stderr.write(str(sys.flags)); sys.exit(not (
                    sys.flags.debug == sys.flags.optimize ==
                    sys.flags.verbose ==
                    z:
                    and sys.flags.dont_write_bytecode == z
                )))�envar_valuerR)r��int�boolr~r)r�valuer��env_vars�dont_write_bytecoderqs      r�test_sys_flags_setzCmdLineTest.test_sys_flags_seths���I�	9�O�E�8��!�$�(-�#�	�H�#&�d�5�k�"2���
�J�:�:M�9N�O�
�
����%��0�
9� ��t�8�x�8�
9�
9�%	9�$
9�
9�s�A � A)	c�d�t�}dddddd|dfg}|D]~\}}}|�dnd|�d	�}d
|�d�}d|g}|�ind
|i}	||urddg|ddn|�
dd|��g|dd|j||��5tj�5t	|i|	��ddd�ddd���y#1swY�xYw#1swY��xYw)N)NNN)�fooNrj)N�barrk)rjrkrk)rjryNrjzis Nonez== "�"z,import sys; sys.exit(not sys.pycache_prefix r�rR�PYTHONPYCACHEPREFIXrl�pycache_prefixrzpycache_prefix=)�envval�opt)�objectr~rrSr)
r�NO_VALUE�casesrorpr��
exp_clauserqrXr�s
          r�test_set_pycache_prefixz#CmdLineTest.test_set_pycache_prefixs���8��
� � �!��
�H�d�#�
��&+�	3�!�F�C��&.�&6��d�8�*�A�<N�J�A�*��Q�O�D��$�<�D���"�-B�F�,K�C��h�� �"2�3��R�a���� �O�C�5�"9�:��R�a�����V���5�
3��'�'�)�3�$�d�2�c�2�3�
3�
3�	3�3�3��
3�
3�s$�&B&�;B�B&�B#�B&�&B/	T)�check_exitcode�xdevc���ttj�}|jdd�|jdd�|jdd�|rtj
ddg|��}ntj
g|��}t
j|tjtjd|��}|r|j|jd|�|jj�S)	N�PYTHONWARNINGS�
PYTHONDEVMODE�PYTHONMALLOCrl�devT�rbrc�universal_newlinesr�r)r�r�r��poprDrTrUr�rer�r]rrbrn)rrvrwrXr�r�s      r�run_xdevzCmdLineTest.run_xdev�s����2�:�:������ �$�'������&������%���N�N�D�%�7�$�7�D��N�N�*�T�*�D��~�~�d�%/�_�_�%/�%6�%6�15�"%�	'��
����T�_�_�a��6��{�{�!�!�#�#rc�r�d}|jd|d��}|j|d�|jd|�}|j|d�d}tjrd}nd	}|jd|�}|j||�|jd
d|�}|j|d|���|jdd|�}|j|d
|���|jdd|�}|j|d|���	ddl}d}tj
�5|jd|d��}ddd�tj�rd}nd}|j||�	ddl}d}|jd|�}|j|d�y#1swY�`xYw#t$rY�CwxYw#t$rYywxYw)N�%import sys; print(sys.flags.dev_mode)rRF)rw�False�Truez\import warnings; print(' '.join('%s::%s' % (f[0], f[2].__name__) for f in warnings.filters))zdefault::Warningz�default::Warning default::DeprecationWarning ignore::DeprecationWarning ignore::PendingDeprecationWarning ignore::ImportWarning ignore::ResourceWarningz-bzdefault::BytesWarning �-bbzerror::BytesWarning z-Werrorzerror::Warning r�<import _testcapi; print(_testcapi.pymem_getallocatorsname()))rv�pymalloc_debug�malloc_debugz5import faulthandler; print(faulthandler.is_enabled()))	r�r]rro�	_testcapi�SuppressCrashReport�
with_pymalloc�ImportError�faulthandler)rrqr!�expected_filtersr��
alloc_namer�s       r�	test_xdevzCmdLineTest.test_xdev�s���6���m�m�D�$�U�m�3������g�&��m�m�D�$�'������f�%�>�����1��!:���m�m�D�$�'������.�/��m�m�D�$��-������ 6�7G�6H�I�J��m�m�E�4��.������ 4�5E�4F�G�H��m�m�I�t�T�2�������0@�/A�B�C�	.��R�D��,�,�.�
F��m�m�D�$�u�m�E��
F��$�$�&�-�
�+�
����S�*�-�	*��K�D��-�-��d�+�C����S�&�)�!
F�
F��	�	��	���	��	�s0�F�F�$F*�F�	F'�&F'�*	F6�5F6c��|rd}nd}|dz
}tjd|dd|f}ttj�}|jdd�||d<t
j|tjtjd	|�
�}|j|jd|�|jj�S)Nz�import sys; from test.support.import_helper import import_fresh_module; warnings = import_fresh_module('warnings', blocked=['_warnings']); zimport sys, warnings; zKprint(' '.join('%s::%s' % (f[0], f[2].__name__) for f in warnings.filters))z-Wr�rRrzryTr}r)rDrTr�r�r�rrUr�rer�r]rrbrn)r�cmdline_option�envvar�
use_pywarningrqrXr�r�s        r�check_warnings_filtersz"CmdLineTest.check_warnings_filters�s����Z�D�,�D��>�	?������n�e�T�4�H���2�:�:��������&� &�����~�~�d�%/�_�_�%/�%6�%6�15�"%�	'��
	
������!�T�2��{�{�!�!�#�#rc���d}tjs|dz
}|jdd�}|j||�|jddd��}|j||�y)Nz9error::BytesWarning once::UserWarning always::UserWarningz� default::DeprecationWarning ignore::DeprecationWarning ignore::PendingDeprecationWarning ignore::ImportWarning ignore::ResourceWarningzonce::UserWarningzalways::UserWarningT)r�)rror�r])rr�r!s   r�test_warnings_filter_precedencez+CmdLineTest.test_warnings_filter_precedence�s���2������";�
<���)�)�*=�*?�A������.�/��)�)�*=�*?�8<�*�>��	
����.�/rc��d}ttj�}|jdd�|�||d<n|jdd�tj
d|f}t
j|tjtjd|��}|j|jj�|�|j|jd�y)Nr�rzr{rRTr}r)r�r�r�rrDrTrUr�rer�r]rbrnr)r�env_var�namerqr�rXr�s       r�check_pythonmalloczCmdLineTest.check_pythonmallocs���M���2�:�:��������&���")�C����G�G�N�D�)�����d�+���~�~�d�%/�_�_�%/�%6�%6�15�"%�	'��
	
������+�+�-�t�4�������!�,rc�L�tj�}|rtjrdnd}d}ntjrdnd}d}d|fd|fddg}|r|jd�|D]3\}}|j	||�	�5|j||�ddd��5y#1swY�@xYw)
Nr��pymallocr��malloc�debug)r�r�)r�r�))r�r�)r�r�)r�r�)rr�rordr~r�)rr��default_name�default_name_debugrr�r�s       r�test_pythonmalloczCmdLineTest.test_pythonmalloc"s����(�(�*���/6�/?�/?�+�Z�L�!1��-4�-=�-=�>�8�L�!/���<� �
�(�)� �,�	
����L�L��
�
#�	7�M�G�T����g�D��9�
7��'�'���6�
7�
7�	7�
7�
7�s�<B�B#	c�F�d}ttj�}|jdd�tj
d|f}t
j|tjd|��}|j|jj�d�|j|jd|�d|d<t
j|tjd|��}|j|jj�d	�|j|jd|�y)
Nr�rzrRT)rbr~r�r�rr�r�)
r�r�r�rrDrTrUr�rer]rbrnr)rrqr�rXr�s     r�test_pythondevmode_envz"CmdLineTest.test_pythondevmode_env<s���6���2�:�:��������&�����d�+���~�~�d�:�?�?�15�3�@��������+�+�-�w�7�������!�T�2�"��O���~�~�d�:�?�?�15�3�@��������+�+�-�v�6�������!�T�2rz!bpo-32457 only applies on Windowsc�t�tjddf}tjj	tj�\}}|dz|z}tj|t
j|��}|j|jd|�|j|jj�d�y)NrRzprint(0)z\.\.\.\)rbrTr�0)rDrTr�r��splitrUr�rer]rrbrR)rrX�prefix�exerTr�s      r�test_argv0_normalizationz$CmdLineTest.test_argv0_normalizationNs����~�~�t�Z�/���g�g�m�m�C�N�N�3�����m�+�c�1�
��~�~�d�:�?�?�)3�5��������!�T�2�������*�*�,�d�3rc�:�tjddg}tj|tjtjd��}d}|j|jj|�|j�|j|jd�y)Nrkz--unknown-optionT)rbrcr�z'unknown option --unknown-option
usage: r)
rDrTrUr�rerrcrH�assertNotEqualr)rrXr��err_msgs    r�test_parsing_errorzCmdLineTest.test_parsing_errorZsp������&8�9���~�~�d�%/�_�_�%/�_�_�#'�)��=��������.�.�w�7����E����D�O�O�Q�/rc��d}tddd|�tddd|�tddd|�tddd|d��td|d	��td|d
��d�}td|�}tj�}|j	||�||f�tddd|�}|j	||�d
�tddd|�}|j	||�d�tddd|�}|j	||�d�td|d��}|j	||�d
�td|d��}|j	||�d�tddd|d��}|j	||�d�y)NzMimport sys; print(sys.flags.int_max_str_digits, sys.get_int_max_str_digits())rl�int_max_str_digitsrRzint_max_str_digits=foozint_max_str_digits=100�4000)�PYTHONINTMAXSTRDIGITSrj�100c��|jj�jd�}td�|j	�D��S)Nr}c3�2K�|]}t|����y�wr)rc)�.0r<s  r�	<genexpr>zGCmdLineTest.test_int_max_str_digits.<locals>.res2int.<locals>.<genexpr>rs����5�A��Q��5�s�)r!rRr:�tupler�)r�r!s  r�res2intz4CmdLineTest.test_int_max_str_digits.<locals>.res2intps3���'�'�-�-�/�(�(��1�C��5�����5�5�5rzint_max_str_digits=0)rrzint_max_str_digits=4000)�r�zint_max_str_digits=100000)順r�r�zint_max_str_digits=6000)�pr�)rrrD�get_int_max_str_digitsr])rrqr�r��current_maxs     r�test_int_max_str_digitsz#CmdLineTest.test_int_max_str_digitsds}��^���d�$8�$��E��d�$<�d�D�I��d�$<�d�D�I��d�$8�$��4:�	<�	�d�D��F��d�D��F�	6��t�T�*���0�0�2���������[�'A�B��t�%;�T�4�H��������v�.��t�%>��d�K��������|�4��t�%@�$��M��������'7�8��t�T��E��������v�.��t�T��H��������|�4���+�T�4�"(�
��	
������|�4rN)F)I�__name__�
__module__�__qualname__rr#r/r3r5r;r>rArKrNr��skipIfr	r^rrr�r�r�r�r��
skipUnlessrr�r�r�rDrr�r�r�
is_androidr�r�r�r�r��flags�	safe_pathr�r�rrr
rrrrr�r�r#r&r(r+r-r=rIrMr[rhrur�r�r�r�r�r�r�r�r�r��rrrrs���%��(�*�&�	,�&�%�5�1��X�_�_�5�7�M�O�:�O�:� '�>D�
4�	<�I�'��X����.�.�0L�M�(�N�(��X����.�.�0L�M�F�N�F��X�_�_�S�\�\�W�,�7�9�Q�9�Q�B�X�_�_�S�\�\�W�,�7�9�(G�9�(G�T�X���#�,�,�(�2�#��"�"�%L�N�*�N�*�(
/�L� 5�
2��X�_�_�S�Y�Y�(�(�>�@�%�@�%�")�$
4���-�"#�@�#��X�_�_�R�W�W��'�)E�F��X�_�_�S�\�\�Y�.�I�K�+�K�G�+�0'�(�(�;�#+�J	#�#�$�X�_�_�5�7�M�O�1�O�1�49�.3�4.2��$�&9*�v$�*0�*-�"7�43�$�X�������0�<�>�4�>�4�0�"5rrrNc�$�eZdZd�Zd�Zd�Zd�Zy)�IgnoreEnvironmentTestc�@�dj|�}tdd|fi|��S)Nz@import sys; sys.stderr.write(str(sys.flags)); sys.exit(not ({}))rQrR)r"r)r�	predicaterfrqs    r�run_ignoring_varsz'IgnoreEnvironmentTest.run_ignoring_vars�s*��
R�X�X�Yb�c����d�D�=�H�=�=rc�L�d}|jdj|�|��y)N�should_be_ignoredz'{}' not in sys.pathr�)r�r")rr�s  r�test_ignore_PYTHONPATHz,IgnoreEnvironmentTest.test_ignore_PYTHONPATH�s+��"�����5�<�<�T�B�*.�	�	0rc�*�|jdd��y)Nz!sys.flags.hash_randomization == 1r�r4�r�rs r�test_ignore_PYTHONHASHSEEDz0IgnoreEnvironmentTest.test_ignore_PYTHONHASHSEED�s�����B�.1�	�	3rc�6�d}|j|ddddd��y)Nz�
            (sys.flags.debug == sys.flags.optimize ==
             sys.flags.dont_write_bytecode ==
             sys.flags.verbose == sys.flags.safe_path == 0)
        r�)r^r_r`ra�PYTHONSAFEPATHr�)r�expected_outcomes  r�test_sys_flags_not_setz,IgnoreEnvironmentTest.test_sys_flags_not_set�s1����
	
������$'���
	�	
rN)r�r�r�r�r�r�r�r�rrr�r��s��>�0�
3�
rr�c��eZdZd�Zd�Zd�Zy)�SyntaxErrorTestsc�6�tjtjdg|tjtj��}|j|jd�|j|jd�|jd|j�y)N�-)�inputrbrcrs
SyntaxError)	rUr�rDrTrer�rrcr*)rrqr�s   r�check_stringzSyntaxErrorTests.check_string�sf���~�~�s�~�~�s�3�4�%/�_�_�Z�_�_�N�����D�O�O�Q�/����D�K�K��.��
�
�&����4rc�&�|jd�y)Ns(1+2+3�r�rs r�test_tokenizer_error_with_stdinz0SyntaxErrorTests.test_tokenizer_error_with_stdin�s�����)�$rc�&�|jd�y)Ns'\u1f'r�rs r�*test_decoding_error_at_the_end_of_the_linez;SyntaxErrorTests.test_decoding_error_at_the_end_of_the_line�s�����*�%rN)r�r�r�r�r�r�r�rrr�r��s��5�%�&rr�c�,�tj�yr)r�
reap_childrenr�rr�tearDownModuler��s�����r�__main__)r�rUrDrr�r�r�r�test.supportr�test.support.script_helperrrrrr	�has_subprocess_support�SkipTestr�TestCaserr�r�r�r�r�rYr�rr�<module>r�s���

��
�����"���
�%�%�
�(�
�
�=�
>�>��i
5�(�#�#�i
5�X����1�3�I�K�!
�H�-�-�!
�K�!
�H&�x�(�(�&���z���H�M�M�O�r