HEX
Server: Apache
System: Linux zacp120.webway.host 4.18.0-553.50.1.lve.el8.x86_64 #1 SMP Thu Apr 17 19:10:24 UTC 2025 x86_64
User: govancoz (1003)
PHP: 8.3.26
Disabled: exec,system,passthru,shell_exec,proc_close,proc_open,dl,popen,show_source,posix_kill,posix_mkfifo,posix_getpwuid,posix_setpgid,posix_setsid,posix_setuid,posix_setgid,posix_seteuid,posix_setegid,posix_uname
Upload Files
File: //usr/local/lib/python3.10/test/__pycache__/test_c_locale_coercion.cpython-310.opt-1.pyc
o

�i�K�@s�ddlZddlZddlZddlZddlZddlZddlmZddlm	Z	ddl
mZddgZdZ
dZdZgd	�Zej�d
�rLe	jrFdZ
dZn*e�d�n$ej�d
�rWdZ
dZnejdkr_dZnejdkrgdZn	ejdkrpdZ
dZd	Zeejdvo�eed�o�eed��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)kr�e�,�dSdS)*�N)�
namedtuple)�support)�run_python_until_end�Cz
invalid.ascii�asciiT)zC.UTF-8zC.utf8�UTF-8�linux�utf-8ZPOSIXZaixz	iso8859-1�darwin�cygwinF�vxworks)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�8/usr/local/lib/python3.10/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�}|rt}n|�dd�}|�dd�}	|||	f}
t||g|�|
�R����S)	z;Returns expected child process details for a given encodingz:{}��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|��\}}|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_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__�joinr0�classmethodr/r7rrrrres
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�tdurdSgatD]}t|�rt�|�q
tr!tdat�t�atj	rWt
dt���t
dt���t
dt���t
dt
���t
dt���t
dt���t
dt���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_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&
�
�rGc@seZdZdd�ZdS)�_LocaleHandlingTestCasec
CsJt�|�}|\}}t�||||�}	|�||	�|durg}|�||�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)rr7r/�assertEqual)
�selfr-�expected_fs_encoding�expected_stream_encoding�expected_warningsr*rZencoding_detailsr6Zexpected_detailsrrr�_check_child_encoding_details�s

�z5_LocaleHandlingTestCase._check_child_encoding_detailsN)r8r9r:rNrrrrrH�srHc@s eZdZedd��Zdd�ZdS)�LocaleConfigurationTestscCstst�d��dS)Nz No C-with-UTF-8 locale available)r=�unittestZSkipTest)r)rrr�
setUpClass�s
�z#LocaleConfigurationTests.setUpClassc
Cs�d|_d}d}ddddd�}dD]9}tD]4}|dkr|dkrq|j||d��|��}|||<|j|||ddd	�Wd�n1sCwYqqdS)
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�s6�������zBLocaleConfigurationTests.test_external_target_locale_configurationN)r8r9r:r<rQr[rrrrrO�s
rOZPY_COERCE_C_LOCALEz(C locale coercion disabled at build timec@sJeZdZ		ddd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Zdd�Z	dS)�LocaleCoercionTestsNTc

Ksd|_tst}t}d}|rtg}ddddd�}|�|�|dur$||d<|jd|d��&tr3|}|}	nd}d}	tj	rA|t
gkrAd}|�|||||	�Wd�n1sTwYtD]0}
dD]+}|j||
|d	��|�
�}|
||<|�|||||�Wd�n1s�wYq_q[dS)
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
        NFrrRrT)Zdefault_localerrS)rTZnominal_localer)rUr=rErD�LEGACY_LOCALE_WARNING�updaterVrFr�
is_androidr@rNrCrW)
rJr+r,�coerce_c_localerMr*Z
extra_varsrXZ_expected_warningsZ_coercion_expectedrYrTrZrrr�_check_c_locale_coercionsf�
�
��������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_zeroms�z5LocaleCoercionTests.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*)rarErDrdrrr�$test_PYTHONCOERCECLOCALE_set_to_zerozs�
�z8LocaleCoercionTests.test_PYTHONCOERCECLOCALE_set_to_zerocCs0|jttdddd�|jttddtgdd�dS)NrFrlri)r`r#rMr*)rarErDr]rdrrr�test_LC_ALL_set_to_C�s�
�z(LocaleCoercionTests.test_LC_ALL_set_to_Cc
Cs�t�tjd�}|�tjtj|�z	t�tjd�}Wntjy3}z
|�t|��WYd}~nd}~ww|dkr=|�d�|tvrH|�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�PIPErIror5)rJ�old_loc�loc�e�coderprrrr�#test_PYTHONCOERCECLOCALE_set_to_one�s(��
�z7LocaleCoercionTests.test_PYTHONCOERCECLOCALE_set_to_one)NT)
r8r9r:rarerhrjrmrnr�rrrrr\s	
�J
r\cCst��dS)N)r�
reap_childrenrrrr�tearDownModule�sr��__main__)-rrrwryr{Z	sysconfigrP�collectionsr�testrZtest.support.script_helperrrCrDrErFrv�platform�
startswithr_r$r>�bool�hasattrrr�_fieldsZ_EncodingDetailsrr]r?r=r&r@rGZTestCaserHrOZcpython_onlyZ
skipUnlessZget_config_varr\r�r8�mainrrrr�<module>sx



��
:�	�-��