File: //usr/local/lib/python3.10/test/__pycache__/test_c_locale_coercion.cpython-310.opt-1.pyc
o
�i�K � @ s� d dl Z d dlZd dlZd dlZd dlZd dlZd dlmZ d dlm Z d dl
mZ ddgZdZ
dZdZg d �Zej�d
�rLe jrFdZ
dZn*e�d� n$ej�d
�rWdZ
dZnejdkr_dZnejdkrgdZn ejdkrpdZ
dZd Zeejdvo�ee d�o�ee d��Zdd� ZdZede�ZG dd� de�ZdZdZdada da!dd� Z"G dd � d ej#�Z$G d!d"� d"e$�Z%e j&e�'e�(d#�d$�G d%d&� d&e$���Z)d'd(� Z*e+d)kr�e�,� dS dS )*� 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�CODESETc C s6 d}t r|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_subprocessW s
r zBfsencoding stdin_info stdout_info stderr_info lang lc_ctype lc_all�EncodingDetailsc @ s2 e Zd Zd�g d��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'))c C s| |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_infor r r �get_expected_detailsr s
z$EncodingDetails.get_expected_detailsc C sl t ddd| jfi |��\}}|jdks|�|� |j�d��� }t| |� �� �}|j �d��
� �� }||fS )aj Retrieves 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=0r r r )r �CHILD_PROCESS_SCRIPTr Zfail�out�decode�
splitlinesr'