Your IP : 216.73.216.213


Current Path : /opt/alt/python311/lib64/python3.11/test/__pycache__/
Upload File :
Current File : //opt/alt/python311/lib64/python3.11/test/__pycache__/test_c_locale_coercion.cpython-311.opt-1.pyc

�

�0�i�S��(�ddlZddlZddlZddlZddlZddlZddlmZddlm	Z	ddl
mZddgZdZ
dZdZgd	�Zej�d
��r"e	jrdZ
dZn`e�d��nJej�d
��rdZ
dZn+ejdkrdZnejdkrdZnejdkrdZ
dZd	Zeejdvoeed��oeed����Zd�ZdZede��ZGd�de��ZdZdZdada da!d�Z"Gd�dej#��Z$Gd�d e$��Z%e	j&ej'ej(d!��d"��Gd#�d$e$������Z)d%�Z*e+d&krej,��dSdS)'�N)�
namedtuple)�support)�run_python_until_end�Cz
invalid.ascii�asciiT)zC.UTF-8zC.utf8�UTF-8�linux�utf-8�POSIX�aixz	iso8859-1�darwin�cygwinF�vxworks)r
r	�nl_langinfo�CODESETc��d}tr|dz
}|�|��}td|d���\}}|jdkS)Nz=import locale; print(locale.setlocale(locale.LC_CTYPE, '{}'))z>; import sys; sys.exit(not locale.nl_langinfo(locale.CODESET))�-c���PYTHONCOERCECLOCALEr)�_check_nl_langinfo_CODESET�formatr�rc)�locale_name�cmd_fmt�cmd�result�py_cmds     �B/opt/alt/python311/lib64/python3.11/test/test_c_locale_coercion.py�_set_locale_in_subprocessr WsP��M�G�!�T��S�S��
�.�.��
%�
%�C�)�$���L�L�L�N�F�F��9��>��zBfsencoding stdin_info stdout_info stderr_info lang lc_ctype lc_all�EncodingDetailsc�h�eZdZd�gd���Zed���Zed���ZdS)r"�;)zimport sys, osz"print(sys.getfilesystemencoding())z2print(sys.stdin.encoding + ':' + sys.stdin.errors)z4print(sys.stdout.encoding + ':' + sys.stdout.errors)z4print(sys.stderr.encoding + ':' + sys.stderr.errors)z(print(os.environ.get('LANG', 'not set'))z,print(os.environ.get('LC_CTYPE', 'not set'))z*print(os.environ.get('LC_ALL', 'not set'))c��|dz}|�d}|�|��gdz}|�|�d����|�dd��}|rt}	n|�dd��}	|�d	d��}
||	|
f}t	||g|�|�R������S)
z;Returns expected child process details for a given encodingz:{}N�surrogateescape��backslashreplace�LANGznot set�LC_CTYPE�LC_ALL)r�append�get�CLI_COERCION_TARGET�dict�_asdict)�cls�coercion_expected�fs_encoding�stream_encoding�
stream_errors�env_vars�_stream�stream_info�
expected_lang�expected_lc_ctype�expected_lc_all�env_infos            r�get_expected_detailsz$EncodingDetails.get_expected_detailsrs���"�E�)��� �.�M��~�~�m�4�4�5��9��	���7�>�>�*<�=�=�>�>�>� ���V�Y�7�7�
��	D� 3��� (���Z�� C� C��"�,�,�x��;�;�� �"3�_�D���C�C��=�k�=�H�=�=�=�E�E�G�G�H�H�Hr!c��tddd|jfi|��\}}|jdks|�|��|j�d�����}t||������}|j	�d���
�����}||fS)ajRetrieves fsencoding and standard stream details from a child process

        Returns (encoding_details, stderr_lines):

        - encoding_details: EncodingDetails for eager decoding
        - stderr_lines: result of calling splitlines() on the stderr output

        The child is run in isolated mode if the current interpreter supports
        that.
        z-Xzutf8=0rrr)r�CHILD_PROCESS_SCRIPTr�fail�out�decode�
splitlinesr/r0�err�rstrip)r1r6rr�stdout_lines�child_encoding_details�stderr_liness       r�get_child_detailsz!EncodingDetails.get_child_details�s���.��(�D�#�":�
�
��
�
�����y�A�~�~��K�K������z�(�(��1�1�<�<�>�>��!%�c�c�<�&8�&@�&@�&B�&B�!C�!C���z�(�(��1�1�8�8�:�:�E�E�G�G��%�|�3�3r!N)�__name__�
__module__�__qualname__�joinr?�classmethodr=rI�r!rr"r"esp�������8�8�	%�	%�	%�	�	���I�I��[�I�*�4�4��[�4�4�4r!z�Python runtime initialized with LC_CTYPE=C (a locale with default ASCII encoding), which may cause Unicode compatibility problems. Using C.UTF-8, C.utf8, or UTF-8 (if available) as alternative Unicode-compatible locales is recommended.z�Python detected LC_CTYPE=C: LC_CTYPE coerced to {} (set another locale or PYTHONCOERCECLOCALE=0 to disable this locale coercion behavior).c�F�t�dSgatD]+}t|��rt�|���,tr,tdat
�t��atj	r�tdt����tdt����tdt����tdt����tdt����tdt����tdt����dSdS)	NrzAVAILABLE_TARGETS = z EXPECTED_C_LOCALE_EQUIVALENTS = z$EXPECTED_C_LOCALE_STREAM_ENCODING = z EXPECTED_C_LOCALE_FS_ENCODING = z$EXPECT_COERCION_IN_DEFAULT_LOCALE = z_C_UTF8_LOCALES = z_check_nl_langinfo_CODESET = )�AVAILABLE_TARGETS�_C_UTF8_LOCALESr r,r.�CLI_COERCION_WARNING_FMTr�CLI_COERCION_WARNINGr�verbose�print�EXPECTED_C_LOCALE_EQUIVALENTS�!EXPECTED_C_LOCALE_STREAM_ENCODING�EXPECTED_C_LOCALE_FS_ENCODING�!EXPECT_COERCION_IN_DEFAULT_LOCALEr)�
target_locales r�setUpModuler\�s8��
�$�����)�4�4�
�$�]�3�3�	4��$�$�]�3�3�3���T�/��2��7�>�>�?R�S�S����N�
�:�%6�:�:�;�;�;�
�R�1N�R�R�S�S�S�
�Z�5V�Z�Z�[�[�[�
�R�1N�R�R�S�S�S�
�Z�5V�Z�Z�[�[�[�
�6�?�6�6�7�7�7�
�L�.H�L�L�M�M�M�M�M�N�Nr!c��eZdZd�ZdS)�_LocaleHandlingTestCasec���t�|��}|\}}	t�|||||��}
|�||
��|�g}|�|	|��dS)a5Check the C locale handling for the given process environment

        Parameters:
            expected_fs_encoding: expected sys.getfilesystemencoding() result
            expected_stream_encoding: expected encoding for standard streams
            expected_warning: stderr output to expect (if any)
        N)r"rIr=�assertEqual)�selfr6�expected_fs_encoding�expected_stream_encoding�expected_stream_errors�expected_warningsr2r�encoding_detailsrH�expected_detailss           r�_check_child_encoding_detailsz5_LocaleHandlingTestCase._check_child_encoding_details�s���!�2�2�8�<�<��)/�&��,�*�?�?�� �$�"��
�
��	
���)�+;�<�<�<��$� "������'8�9�9�9�9�9r!N)rJrKrLrhrOr!rr^r^�s#������:�:�:�:�:r!r^c�0�eZdZed���Zd�Zd�ZdS)�LocaleConfigurationTestsc�<�tstjd���dS)Nz No C-with-UTF-8 locale available)rQ�unittest�SkipTest)r1s r�
setUpClassz#LocaleConfigurationTests.setUpClass�s+��!�	H��#�$F�G�G�G�	H�	Hr!c�*�d|_d}d}dddddd�}dD]|}tD]r}|dkr|dkr�|�||���5|���}|||<|�|||ddd�	��ddd��n#1swxYwY�s�}dS)
Nr
r�r)r*r+r�PYTHONIOENCODING�r)r*r)r��env_var�configured_localeF�rdrer2��maxDiffrQ�subTest�copyrh�rarbrc�
base_var_dictrt�
locale_to_set�var_dicts       r�)test_external_target_locale_configurationzBLocaleConfigurationTests.test_external_target_locale_configuration�sW�����&��#*� ����#%� "�
�
�
�,�	P�	P�G�!2�
P�
P�
��f�$�$��'�)A�)A���\�\�'�4A�"�C�C�	P�	P�,�1�1�3�3�H�(5�H�W�%��6�6�x�7K�7O�NR�IM�IN�7�P�P�P�		P�	P�	P�	P�	P�	P�	P�	P�	P�	P�	P����	P�	P�	P�	P��
P�	P�	P��5B�B
�
B
c�*�d|_d}d}dddddd�}dD]|}tD]r}|dkr|dkr�|�||���5|���}|||<|�|||ddd	�
��ddd��n#1swxYwY�s�}dS)Nr
rrrprrr)rs�strictFrvrwr{s       r�test_with_ioencodingz-LocaleConfigurationTests.test_with_ioencodingsW�����&��#*� ����#%� '�
�
�
�,�	P�	P�G�!2�
P�
P�
��f�$�$��'�)A�)A���\�\�'�4A�"�C�C�	P�	P�,�1�1�3�3�H�(5�H�W�%��6�6�x�7K�7O�NV�IM�IN�7�P�P�P�		P�	P�	P�	P�	P�	P�	P�	P�	P�	P�	P����	P�	P�	P�	P��
P�	P�	Pr�N)rJrKrLrNrnrr�rOr!rrjrj�sY�������H�H��[�H�!P�!P�!P�F P� P� P� P� Pr!rj�PY_COERCE_C_LOCALEz(C locale coercion disabled at build timec�>�eZdZ		d
d�Zd�Zd�Zd�Zd�Zd�Zd	�Z	dS)�LocaleCoercionTestsNTc�j�d|_tst}t}d}|rtg}dddddd�}|�|��|�||d<|�d|���5tr|}|}	nd}d}	tj	r|tgkrd}|�|||d||	��ddd��n#1swxYwYtD]k}
dD]f}|�||
|d�	��5|�
��}|
||<|�|||d||��ddd��n#1swxYwY�g�ldS)
aCheck the C locale handling for various configurations

        Parameters:
            fs_encoding: expected sys.getfilesystemencoding() result
            stream_encoding: expected encoding for standard streams
            coerce_c_locale: setting to use for PYTHONCOERCECLOCALE
              None: don't set the variable at all
              str: the value set in the child's environment
            expected_warnings: expected warning lines on stderr
            extra_vars: additional environment variables to set in subprocess
        NFrrprT)�default_localerrr)rt�nominal_localerrq)rxrQrYrX�LEGACY_LOCALE_WARNING�updateryrZr�
is_androidrTrhrWrz)
rar3r4�coerce_c_localerer2�
extra_varsr|�_expected_warnings�_coercion_expectedr}rtr~s
             r�_check_c_locale_coercionz,LocaleCoercionTests._check_c_locale_coercionGsy��"��� �	<�7�K�?�O� %�� �
<�%:�$;�!����#%� "�
�
�
�	���Z�(�(�(��&�3B�M�/�0��\�\��.=��?�?�	C�	C�0�
+�%6�"�%6�"�"�%)�"�%*�"�
�"�
*�&�+?�*@�@�@�%)�"��.�.�}�/:�/>�/3�/A�/A�
C�
C�
C�	C�	C�	C�	C�	C�	C�	C�	C�	C�	C�	C����	C�	C�	C�	C�.;�	J�	J�M�/�

J�

J���\�\�'�1>�6E�35�"�7�7�J�J� -�1�1�3�3�H�(5�H�W�%��6�6�x�7B�7F�7;�7H�7H�J�J�J�J�J�J�J�J�J�J�J�J�J�J����J�J�J�J��

J�	J�	Js%�$AB5�5B9�<B9�&4D&�&D*�-D*c�6�|�ddd���dS)Nr
�r��r��ras r� test_PYTHONCOERCECLOCALE_not_setz4LocaleCoercionTests.test_PYTHONCOERCECLOCALE_not_set�s#���%�%�g�w��%�M�M�M�M�Mr!c�@�dD]}|�dd|����dS)N)r�1�true�falser
r�r�)ra�settings  r�!test_PYTHONCOERCECLOCALE_not_zeroz5LocaleCoercionTests.test_PYTHONCOERCECLOCALE_not_zero�s?��2�	U�	U�G��)�)�'�7�G�)�T�T�T�T�	U�	Ur!c�D�|�dddtg���dS)Nr
�warn)r�re)r�rTr�s r�$test_PYTHONCOERCECLOCALE_set_to_warnz8LocaleCoercionTests.test_PYTHONCOERCECLOCALE_set_to_warn�s;���%�%�g�w�6<�9M�8N�	&�	P�	P�	P�	P�	Pr!c��|�ttdd���|�ttddd���dS)N�0F)r�r2r�r�r+r2)r�rYrXr�s r�$test_PYTHONCOERCECLOCALE_set_to_zeroz8LocaleCoercionTests.test_PYTHONCOERCECLOCALE_set_to_zero�sc���%�%�&C�&G�69�8=�	&�	?�	?�	?�
	
�%�%�&C�&G�69�-0�8=�		&�	?�	?�	?�	?�	?r!c��|�ttddd���|�ttddtgd���dS)NrFr�r�)r�r+rer2)r�rYrXr�r�s r�test_LC_ALL_set_to_Cz(LocaleCoercionTests.test_LC_ALL_set_to_C�sl���%�%�&C�&G�6:�-0�8=�		&�	?�	?�	?�	
�%�%�&C�&G�6<�-0�9N�8O�8=�	&�	?�	?�	?�	?�	?r!c���tjtjd��}|�tjtj|��	tjtjd��}n>#tj$r,}|�t
|����Yd}~nd}~wwxYw|dkr|�d��|tvr|�d|z��d}ttj
d���}tjtjd|gtj|d	�
��}|�|j���|��dS)Nrrz.test requires LC_CTYPE locale different than Czcoerced LC_CTYPE locale: %sz=import locale; print(locale.setlocale(locale.LC_CTYPE, None))r�rrT)�stdout�env�text)�locale�	setlocaler*�
addCleanup�Error�skipTest�str�TARGET_LOCALESr/�os�environ�
subprocess�run�sys�
executable�PIPEr`r�rE)ra�old_loc�loc�e�coder�rs       r�#test_PYTHONCOERCECLOCALE_set_to_onez7LocaleCoercionTests.test_PYTHONCOERCECLOCALE_set_to_one�sG���"�6�?�D�9�9������(�&�/�7�C�C�C�	"��"�6�?�B�7�7�C�C���|�	"�	"�	"��M�M�#�a�&�&�!�!�!�!�!�!�!�!�����	"�����#�:�:��M�M�J�K�K�K��.� � ��M�M�7�#�=�>�>�>�O���2�:�3�7�7�7���n�c�n�d�D�9�$.�O�!$�"&�(�(�(��	
�����*�*�,�,�c�2�2�2�2�2s�A,�,B'�;"B"�"B')NT)
rJrKrLr�r�r�r�r�r�r�rOr!rr�r�As�������48�37�	LJ�LJ�LJ�LJ�\N�N�N�U�U�U�P�P�P�?�?�?�
?�
?�
?�3�3�3�3�3r!r�c�,�tj��dS)N)r�
reap_childrenrOr!r�tearDownModuler��s��������r!�__main__)-r�r�r�r��	sysconfigrl�collectionsr�testr�test.support.script_helperrrWrXrYrZr��platform�
startswithr�r,rR�bool�hasattrrr �_fields�_EncodingDetailsr"r�rSrQr.rTr\�TestCaser^rj�cpython_only�
skipUnless�get_config_varr�r�rJ�mainrOr!r�<module>r�sX���
�
�
�	�	�	�	�����
�
�
�
���������"�"�"�"�"�"�������;�;�;�;�;�;�"%�o� 6��%,�!� '��%)�!�/�/�/���<���7�#�#�,���	6�,3�)�(/�%�%�	&�,�,�W�5�5�5�5��\���U�#�#�,�(3�%�$/�!�!��\�X���$+�!�!��\�X���).�%�%��\�Y���(/�%�$+�!�1��"�T��L�+�+���G�F�M�"�"���G�F�I���������O���:�/��9�9��94�94�94�94�94�&�94�94�94�|��J��������N�N�N�<:�:�:�:�:�h�/�:�:�:�@MP�MP�MP�MP�MP�6�MP�MP�MP�^	�����-�Y�-�.B�C�C�?�A�A�S3�S3�S3�S3�S3�1�S3�S3�A�A���S3�l����z����H�M�O�O�O�O�O��r!