HEX
Server: Microsoft-IIS/10.0
System: Windows NT ITPWINWEBSVR22 10.0 build 20348 (Windows Server 2022) AMD64
User: www.conferencesearch.co.uk (0)
PHP: 8.3.30
Disabled: NONE
Upload Files
File: D:/Python311/Lib/test/test_importlib/source/__pycache__/test_source_encoding.cpython-311.pyc
�

��Vc����ddlmZejd��ZddlZddlZddlZddlZddl	Z	ddl
Z
ddlZejdej
��ZGd�d��ZGd�de��Zejee�	��\ZZGd
�de��Zejee�	��\ZZGd�d
��ZGd�de��Zejee�	��\ZZGd�de��Zejee�	��\ZZedkre
j��dSdS)�)�utilzimportlib.machineryNz&^[ \t\f]*#.*?coding[:=][ \t]*([-\w.]+)c��eZdZdZdZdZd�ee��ZdZd�Z	d�Z
d�Zd	�Zd
�Z
d�Zd�Zd
�Zd�ZdS)�EncodingTesta�PEP 3120 makes UTF-8 the default encoding for source code
    [default encoding].

    PEP 263 specifies how that can change on a per-file basis. Either the first
    or second line can contain the encoding line [encoding first line]
    [encoding second line]. If the file has the BOM marker it is considered UTF-8
    implicitly [BOM]. If any encoding is specified it must be UTF-8, else it is
    an error [BOM and utf-8][BOM conflict].

    �ü�Éz{0} = '{1}'
�_tempc�x�tj|j��5}t||jd��5}|�|��ddd��n#1swxYwY|j�|j||j��}|�|��cddd��S#1swxYwYdS)N�wb)r�create_modules�module_name�open�write�	machinery�SourceFileLoader�load)�self�source�mapping�file�loaders     �CD:\Python311\Lib\test\test_importlib\source\test_source_encoding.py�run_testzEncodingTest.run_test%s+��
�
 ��!1�
2�
2�	%�g��g�d�.�/��6�6�
#�$��
�
�6�"�"�"�
#�
#�
#�
#�
#�
#�
#�
#�
#�
#�
#����
#�
#�
#�
#��^�4�4�T�5E�29�$�:J�2K�M�M�F��9�9�V�$�$�	%�	%�	%�	%�	%�	%�	%�	%�	%�	%�	%�	%����	%�	%�	%�	%�	%�	%s5�B/�A�B/�A	�B/�A	� AB/�/B3�6B3c��d�|��}t�|��sJ�|�d��g}|�|j�|����d�|��S)Nz# coding={0}�utf-8�
)�format�	CODING_RE�match�encode�append�source_line�join)r�encoding�
encoding_line�source_liness    r�
create_sourcezEncodingTest.create_source-sz��&�-�-�h�7�7�
����}�-�-�-�-�-�%�,�,�W�5�5�6�����D�,�3�3�H�=�=�>�>�>��z�z�,�'�'�'�c��d}t�|��sJ�d�|���d��}|�|��dS)Nz# coding=koi8-rz	{0}
a=42
zkoi8-r)rrrrr)rr$rs   r�test_non_obvious_encodingz&EncodingTest.test_non_obvious_encoding4sZ��*�
����}�-�-�-�-�-��%�%�m�4�4�;�;�H�E�E���
�
�f�����r'c�`�|�|j�d����dS�Nr)rr!r�rs r�test_default_encodingz"EncodingTest.test_default_encoding=s+���
�
�d�&�-�-�g�6�6�7�7�7�7�7r'c�^�d}|�|��}|�|��dS)N�Latin-1�r&r)rr#rs   r�test_encoding_on_first_linez(EncodingTest.test_encoding_on_first_lineAs2�����#�#�H�-�-���
�
�f�����r'c�`�d|�d��z}|�|��dS)Ns#/usr/bin/python
r/r0�rrs  r�test_encoding_on_second_linez)EncodingTest.test_encoding_on_second_lineGs2��&��);�);�I�)F�)F�F���
�
�f�����r'c�z�|�tj|j�d��z��dSr+)r�codecs�BOM_UTF8r!rr,s r�test_bomzEncodingTest.test_bomLs2���
�
�f�o��(8�(?�(?��(H�(H�H�I�I�I�I�Ir'c�t�tj|�d��z}|�|��dSr+)r6r7r&rr3s  r�test_bom_and_utf_8zEncodingTest.test_bom_and_utf_8Ps4����4�#5�#5�g�#>�#>�>���
�
�f�����r'c���tj|�d��z}|�t��5|�|��ddd��dS#1swxYwYdS)Nzlatin-1)r6r7r&�assertRaises�SyntaxErrorrr3s  r�test_bom_conflictzEncodingTest.test_bom_conflictUs�����4�#5�#5�i�#@�#@�@��
�
�
�{�
+�
+�	"�	"��M�M�&�!�!�!�	"�	"�	"�	"�	"�	"�	"�	"�	"�	"�	"�	"����	"�	"�	"�	"�	"�	"s�A � A$�'A$N)�__name__�
__module__�__qualname__�__doc__�variable�	characterrr!rrr&r)r-r1r4r8r:r>�r'rrrs�������	�	��H��I�!�(�(��9�=�=�K��K�%�%�%�(�(�(����8�8�8�������
J�J�J����
"�"�"�"�"r'rc��eZdZd�ZdS)�EncodingTestPEP451c��tj|j��}tj�|j|��|_|�|��|S�N)�types�
ModuleTyper�	importlibr�spec_from_loader�__spec__�exec_module)rr�modules   rrzEncodingTestPEP451.load]sJ���!�$�"2�3�3��#�.�9�9�$�:J�F�S�S������6�"�"�"��
r'N�r?r@rArrEr'rrGrG[�#����������r'rG)rc��eZdZd�ZdS)�EncodingTestPEP302c���tj��5tjdt��|�|j��cddd��S#1swxYwYdS�N�ignore)�warnings�catch_warnings�simplefilter�DeprecationWarning�load_moduler)rrs  rrzEncodingTestPEP302.loadks���
�
$�
&�
&�	8�	8��!�(�,>�?�?�?��%�%�d�&6�7�7�	8�	8�	8�	8�	8�	8�	8�	8�	8�	8�	8�	8����	8�	8�	8�	8�	8�	8s�4A�A�ANrQrEr'rrTrTis#������8�8�8�8�8r'rTc�*�eZdZdZd�Zd�Zd�Zd�ZdS)�LineEndingTestzjSource written with the three types of line endings (\n, \r\n, \r)
    need to be readable [cr][crlf][lf].c��d}gd�}|�|��}tj|��5}t||d��5}|�|��ddd��n#1swxYwY|j�|||��}|�||��cddd��S#1swxYwYdS)Nr)sa = 42sb = -13r'r
)r"rrr
rrrr)r�line_endingrr%rrrrs        rrzLineEndingTest.run_test{sD����3�3�3���!�!�,�/�/��
�
 ��
-�
-�	2���g�k�*�D�1�1�
#�T��
�
�6�"�"�"�
#�
#�
#�
#�
#�
#�
#�
#�
#�
#�
#����
#�
#�
#�
#��^�4�4�[�5<�[�5I�K�K�F��9�9�V�[�1�1�	2�	2�	2�	2�	2�	2�	2�	2�	2�	2�	2�	2����	2�	2�	2�	2�	2�	2s5�B7�A)�B7�)A-	�-B7�0A-	�19B7�7B;�>B;c�0�|�d��dS)N�
�rr,s r�test_crzLineEndingTest.test_cr�����
�
�e�����r'c�0�|�d��dS)Ns
rcr,s r�	test_crlfzLineEndingTest.test_crlf�s���
�
�g�����r'c�0�|�d��dS)Nrrcr,s r�test_lfzLineEndingTest.test_lf�rer'N)r?r@rArBrrdrgrirEr'rr^r^vsZ������+�+�	2�	2�	2�����������r'r^c��eZdZd�ZdS)�LineEndingTestPEP451c��tj|��}tj�||��|_|�|��|SrI)rJrKrLrrMrNrO)rrrrPs    rrzLineEndingTestPEP451.load�sD���!�+�.�.��#�.�9�9�+�v�N�N������6�"�"�"��
r'NrQrEr'rrkrk�rRr'rkc��eZdZd�ZdS)�LineEndingTestPEP302c��tj��5tjdt��|�|��cddd��S#1swxYwYdSrV)rXrYrZr[r\)rrrs   rrzLineEndingTestPEP302.load�s���
�
$�
&�
&�	3�	3��!�(�,>�?�?�?��%�%�k�2�2�	3�	3�	3�	3�	3�	3�	3�	3�	3�	3�	3�	3����	3�	3�	3�	3�	3�	3s�/A�A�ANrQrEr'rrnrn�s#������3�3�3�3�3r'rn�__main__) �test.test_importlibr�import_importlibrr6�importlib.utilrL�rerJ�unicodedata�unittestrX�compile�ASCIIrrrG�	test_both�Frozen_EncodingTestPEP451�Source_EncodingTestPEP451rT�Frozen_EncodingTestPEP302�Source_EncodingTestPEP302r^rk�Frozen_LineEndingTestPEP451�Source_LineEndingTestPEP451rn�Frozen_LineEndingTestPEP302�Source_LineEndingTestPEP302r?�mainrEr'r�<module>r�s<��$�$�$�$�$�$�!�D�!�"7�8�8�	�
�
�
�
�����	�	�	�	�����������������
�B�J�@�"�(�K�K�	�E"�E"�E"�E"�E"�E"�E"�E"�P����������T�^�&�)�<�<�<����8�8�8�8�8��8�8�8��T�^�&�)�<�<�<������������:�����>�����T�^�(�I�>�>�>����3�3�3�3�3�>�3�3�3��T�^�(�I�>�>�>�����z����H�M�O�O�O�O�O��r'