Your IP : 216.73.216.213


Current Path : /opt/alt/python39/lib64/python3.9/test/__pycache__/
Upload File :
Current File : //opt/alt/python39/lib64/python3.9/test/__pycache__/test_c_locale_coercion.cpython-39.opt-2.pyc

a

XC?h�K�@s�ddlZddlZddlZddlZddlZddlZddlmZddlm	Z	ddl
mZddgZdZ
dZdZgd	�Zej�d
�r�e	jr�dZ
dZq�e�d�nHej�d
�r�dZ
dZn2ejdkr�dZn"ejdkr�dZnejdkr�dZ
dZd	Zeejdv�oeed��oeed��Zdd�ZdZede�ZGdd�de�ZdZdZdada da!dd�Z"Gdd �d ej#�Z$Gd!d"�d"e$�Z%e	j&e�'e�(d#�d$�Gd%d&�d&e$���Z)d'd(�Z*e+d)k�r�e�,�dS)*�N)�
namedtuple)�support)�run_python_until_end�Cz
invalid.ascii�asciiT)zC.UTF-8zC.utf8�UTF-8�linux�utf-8ZPOSIXZaixz	iso8859-1�darwin�cygwinFZvxworks)r
r�nl_langinfo�CODESETcCs6d}tr|d7}|�|�}td|dd�\}}|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)Zlocale_nameZcmd_fmt�cmd�result�py_cmd�r�@/opt/alt/python39/lib64/python3.9/test/test_c_locale_coercion.py�_set_locale_in_subprocessWs
rzBfsencoding stdin_info stdout_info stderr_info lang lc_ctype lc_all�EncodingDetailsc@s2eZdZd�gd��Zedd��Zedd��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'))cCs||d}d|�d�g}|�|�d��|�dd�}|r>t}n|�dd�}|�dd�}	|||	f}
t||g|�|
�R����S)	Nz:{}��surrogateescape�backslashreplace�LANGznot set�LC_CTYPE�LC_ALL)r�append�get�CLI_COERCION_TARGET�dict�_asdict)�cls�coercion_expected�fs_encoding�stream_encoding�env_vars�_streamZstream_infoZ
expected_langZexpected_lc_ctypeZexpected_lc_allZenv_inforrr�get_expected_detailsrs
z$EncodingDetails.get_expected_detailscCsltddd|jfi|��\}}|jdks0|�|�|j�d���}t||����}|j	�d��
���}||fS)Nz-Xzutf8=0rrr)r�CHILD_PROCESS_SCRIPTrZfail�out�decode�
splitlinesr&r'�err�rstrip)r(r,rrZstdout_linesZchild_encoding_details�stderr_linesrrr�get_child_details�s
��


z!EncodingDetails.get_child_detailsN)�__name__�
__module__�__qualname__�joinr/�classmethodr.r6rrrrres

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).cCs�tdurdSgatD]}t|�rt�|�qtrBtdat�t�atj	r�t
dt���t
dt���t
dt���t
dt
���t
dt���t
dt���t
dt���dS)	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_LOCALESrr#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)Z
target_localerrr�setUpModule�s"
rFc@seZdZdd�ZdS)�_LocaleHandlingTestCasec
CsJt�|�}|\}}t�||||�}	|�||	�|dur:g}|�||�dS�N)rr6r.�assertEqual)
�selfr,�expected_fs_encoding�expected_stream_encoding�expected_warningsr)rZencoding_detailsr5Zexpected_detailsrrr�_check_child_encoding_details�s
�z5_LocaleHandlingTestCase._check_child_encoding_detailsN)r7r8r9rNrrrrrG�srGc@s eZdZedd��Zdd�ZdS)�LocaleConfigurationTestscCstst�d��dS)Nz No C-with-UTF-8 locale available)r<�unittestZSkipTest)r(rrr�
setUpClass�sz#LocaleConfigurationTests.setUpClassc
Cs�d|_d}d}ddddd�}dD]r}tD]h}|dkr>|dkr>q(|j||d��4|��}|||<|j|||ddd	�Wd�q(1s�0Yq(q dS)
Nr	r�r r!r"r�r r!r r)�env_varZconfigured_localeF)rMr))�maxDiffr<�subTest�copyrN)rJrKrL�
base_var_dictrT�
locale_to_set�var_dictrrr�)test_external_target_locale_configuration�s.���zBLocaleConfigurationTests.test_external_target_locale_configurationN)r7r8r9r;rQr[rrrrrO�s
rOZPY_COERCE_C_LOCALEz(C locale coercion disabled at build timec@sFeZdZddd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Zdd�Z	dS)�LocaleCoercionTestsNTc

Ksd|_ts t}t}d}|r tg}ddddd�}|�|�|durH||d<|jd|d��Ltrf|}|}	nd}d}	tj	r�|t
gkr�d}|�|||||	�Wd�n1s�0YtD]b}
dD]X}|j||
|d��2|�
�}|
||<|�|||||�Wd�q�1�s0Yq�q�dS)	NFrrRrT)Zdefault_localerrS)rTZnominal_localer)rUr<rDrC�LEGACY_LOCALE_WARNING�updaterVrEr�
is_androidr?rNrBrW)
rJr*r+�coerce_c_localerMr)Z
extra_varsrXZ_expected_warningsZ_coercion_expectedrYrTrZrrr�_check_c_locale_coercions^�
���"��z,LocaleCoercionTests._check_c_locale_coercioncCs|jdddd�dS)Nr	�r`�ra�rJrrr� test_PYTHONCOERCECLOCALE_not_setisz4LocaleCoercionTests.test_PYTHONCOERCECLOCALE_not_setcCsdD]}|jdd|d�qdS)N)r�1�trueZfalser	rbrc)rJZsettingrrr�!test_PYTHONCOERCECLOCALE_not_zeromsz5LocaleCoercionTests.test_PYTHONCOERCECLOCALE_not_zerocCs|jdddtgd�dS)Nr	�warn)r`rM)rar?rdrrr�$test_PYTHONCOERCECLOCALE_set_to_warnss�z8LocaleCoercionTests.test_PYTHONCOERCECLOCALE_set_to_warncCs*|jttddd�|jttdddd�dS)N�0F)r`r)r�r`r"r))rarDrCrdrrr�$test_PYTHONCOERCECLOCALE_set_to_zerozs��z8LocaleCoercionTests.test_PYTHONCOERCECLOCALE_set_to_zerocCs0|jttdddd�|jttddtgdd�dS)NrFrlri)r`r"rMr))rarDrCr]rdrrr�test_LC_ALL_set_to_C�s��z(LocaleCoercionTests.test_LC_ALL_set_to_Cc
Cs�t�tjd�}|�tjtj|�zt�tjd�}Wn4tjyf}z|�t|��WYd}~n
d}~00|dkrz|�d�|tvr�|�d|�d}tt	j
dd�}tjt
jd|gtj|d	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))rfrrT)�stdout�env�text)�locale�	setlocaler!Z
addCleanup�ErrorZskipTest�str�TARGET_LOCALESr&�os�environ�
subprocess�run�sys�
executable�PIPErIror4)rJZold_locZloc�e�coderprrrr�#test_PYTHONCOERCECLOCALE_set_to_one�s$$
�z7LocaleCoercionTests.test_PYTHONCOERCECLOCALE_set_to_one)NT)
r7r8r9rarerhrjrmrnr�rrrrr\s	�
J
r\cCst��dSrH)rZ
reap_childrenrrrr�tearDownModule�sr��__main__)-rrrwryr{Z	sysconfigrP�collectionsr�testrZtest.support.script_helperrrBrCrDrErv�platform�
startswithr_r#r=�bool�hasattrrr�_fieldsZ_EncodingDetailsrr]r>r<r%r?rFZTestCaserGrOZcpython_onlyZ
skipUnlessZget_config_varr\r�r7�mainrrrr�<module>st


��
:�	�-�