HEX
Server: Apache
System: Linux bd12.noc223.com 4.18.0-553.121.1.lve.el8.x86_64 #1 SMP Thu Apr 30 16:40:41 UTC 2026 x86_64
User: handcraf (1693)
PHP: 8.1.28
Disabled: NONE
Upload Files
File: //opt/alt/python312/lib64/python3.12/test/test_importlib/__pycache__/util.cpython-312.pyc
�

h�e�0���ddlZddlZddlZddlZddlmZmZmZddlZddl	Z	ddl
Z	ddlmZddlm
Z
ddlZddlZddlZddlZej$�Zde_de_dej,vrde_dej,vrde_ej$�adt._dt._dt._dt._dt._d�Ze�d	�Zd$d
�Zd$d�Z d$d�Z!d
Z"ejFdvrBe$jK�Z&e&e$k(re$jO�Z&e	j0jQe&�sdZ"ed�dZ)e*ejV�e*e)jV�d�Z+d�Z,d%d�Z-d�Z.ej^d��Z0ej^d%dd�d��Z1ej^d��Z2Gd�d�Z3Gd�de3�Z4d�Z5d�Z6ej^d��Z7ej^d ��Z8d!�Z9Gd"�d#�Z:y)&�N)�	machinery�util�invalidate_caches)�
import_helper)�	os_helper�errno�	importlib�_testsinglephasec�Z�tjD]�}tjD]�}tj
|z}tjj||�}tjj|�s�V|t_|t_	|t_
|t_y��y�N)�sys�pathr�EXTENSION_SUFFIXES�
EXTENSIONS�name�os�join�exists�ext�filename�	file_path)rrrrs    �?/opt/alt/python312/lib64/python3.12/test/test_importlib/util.py�_extension_detailsr s}�����	���/�/�	�C�!����,�H������T�8�4�I��w�w�~�~�i�(�"&�
��!$�
��&.�
�#�'0�
�$��	�	�c�v�d|vrdnd}tj|�}tj||d��}||d�S)zAImport a module from importlib both w/ and w/o _frozen_importlib.�.)r	�)�_frozen_importlib�_frozen_importlib_external)�fresh�blocked��Frozen�Source)r�import_fresh_module)�module_namer �frozen�sources    r�import_importlibr)0sC��!�[�0�N�b�E�
�
.�
.�{�
;�F�
�
.�
.�{�%�1d�f�F���/�/rc�h�|�tj}nt|t�s||}dj	||j
�}||f}t
j||�}|j|_|j
|_	||_
|j�D]\}}||}	t|||	��|S)Nz{}_{})
�unittest�TestCase�
isinstance�type�format�__name__�types�	new_class�
__module__�_NAME�_KIND�items�setattr)
�cls�kind�base�kwargsr�bases�specialized�attr�values�values
          r�specialize_classrA9s����|�� � ��
��d�
#��D�z���>�>�$����-�D�
�$�K�E��/�/�$��.�K� �^�^�K�����K���K������*���f��t�����T�5�)�*��rc�B�t|d|fi|��}t|d|fi|��}||fS)Nr#r$)rA)r8r:r;r'r(s     r�split_frozenrCLs2��
�c�8�T�
<�V�
<�F�
�c�8�T�
<�V�
<�F��6�>�rc��t||fi|��Sr)rC)�
test_classr:r;s   r�	test_bothrFRs���
�D�3�F�3�3rT)�win32�cygwinFr$r"c�D�tjtd�|�S)zRClass decorator that nullifies tests requiring a case-insensitive
    file system.z&requires a case-insensitive filesystem)r+�skipIf�CASE_INSENSITIVE_FS)�tests r�case_insensitive_testsrMes,��F�8�?�?�2�2�D�F�FJ�L�Lrc���tjj||dz�}t|dd��5}|j	|�ddd�dj||�|fS#1swY�xYw)N�.py�w�utf-8��encodingz{}.{})rrr�open�writer/)�parentr�pkg_dir�contentr�subfiles      r�	submodulerZls_��
�7�7�<�<�����.�D�	
�d�C�'�	*��g��
�
�g����>�>�&�$�'��-�-���s�A � A)c��t|d�5}|jd�tj|�cddd�S#1swYyxYw)znReads a pyc file and returns the unmarshalled code object within.

    No header validation is performed.
    �rb�N)rT�seek�marshal�load)�pyc_path�pyc_fs  r�get_code_from_pycrcss<��

�h��	�#��
�
�
�2���|�|�E�"�#�#�#�s	�&=�Ac'�LK�|D]2}|dvrtdj|���	tj|=�4	d��|D]}	tj|=�y#t$rY�_wxYw#t$rY�2wxYw#|D]#}	tj|=�#t$rY�!wxYwwxYw�w)z�Uncache a module from sys.modules.

    A basic sanity check is performed to prevent uncaching modules that either
    cannot/shouldn't be uncached.

    )r
r_zcannot uncache {}N)�
ValueErrorr/r
�modules�KeyError)�namesrs  r�uncacheri}s���������%�%��0�7�7��=�>�>�	����D�!�	��
��	�D�
��K�K��%�	���	��	���
��
���	�D�
��K�K��%���
��
��	�s��$B$�A�B$�A7�B$�A(�B$�	A%�"B$�$A%�%B$�(	A4�1B$�3A4�4B$�7B!�>B�B!�	B	�B!�B	�B!�!B$)�pkgc	#�K�tjD�cgc]}|jd�d|k(s�|��}}tjd�5}t|g|���5t
j|�5t�tjj||�}|r6tjj|d�}tj|�n	|dz}|�d}|�(t|dd��5}|j|�ddd�|��ddd�ddd�ddd�ycc}w#1swY�+xYw#1swY�+xYw#1swY�/xYw#1swYyxYw�w)	Nrrz__init__.pyrO�rPrQrR)r
rf�	partitionr�temp_cwdrir�
DirsOnSysPathrrrr�mkdirrTrU)	rrXrj�n�	conflicts�cwd�location�modpath�modfiles	         r�temp_modulerw�s0�����K�K�G�q�1�;�;�s�+;�A�+>�$�+F��G�I�G�	�	�	�D�	!��S�
�T�
&�I�
&�	��,�,�S�1�
�!�#��7�7�<�<��T�2��� �g�g�l�l�8�]�C�G��H�H�T�N�&��.�G���"$���&��g�s�W�=�/���
�
�g�.�/���!
�	����H�"/�/��
�
��	�	����su�E�D#�D#�E�

E�E�0A<D4�,D(	�>D4�
E�E�E�(D1
�-D4�4D=�9E�E		�E�E�Ec+�K�i}	dgfdgfdgfdiffD]8\}}tt|�||<||vr	||}||=n|}tt||��:t|�rt	dj|���d��|j
�D]\}}tt||��y#|j
�D]\}}tt||��wxYw�w)a,Context manager to manage the various importers and stored state in the
    sys module.

    The 'modules' attribute is not supported as the interpreter state stores a
    pointer to the dict that the interpreter uses internally;
    reassigning to sys.modules does not have the desired effect.

    �	meta_pathr�
path_hooks�path_importer_cachezunrecognized arguments: {}N)�getattrr
r7�lenrer/r6)r;�	originalsr>�default�	new_valuer@s      r�import_stater��s������I�&�*�B�/�&�"��+�R�0�4�b�9�;�		*�M�D�'�&�c�4�0�I�d�O��v�~�"�4�L�	��4�L�#�	��C��y�)�		*��v�;��9�@�@��H�I�I�
�$�?�?�,�	&�K�D�%��C��u�%�	&��9�?�?�,�	&�K�D�%��C��u�%�	&�s�C�A2B"�8*C�"+C
�
Cc�.�eZdZdZid�d�Zd�Zd�Zd�Zy)�
_ImporterMockz0Base class to help with creating importer mocks.)�module_codec��i|_i|_|D]�}|jd�s|}n|dtd�}d|vrd}n||k(r|j	dd�d}n|}tj|�}||_d|_||_	||_
||k7rdg|_||j|<||vs��|||j|<��y)N�	.__init__r�rz<mock __file__>z<mock __path__>)rfr��endswithr}�rsplitr1�
ModuleType�
__loader__�__file__�__package__r>�__path__)�selfr�rhr�import_name�package�modules       r�__init__z_ImporterMock.__init__�s����������	I�D��=�=��-�"��"�#5�S��%5�$5�6���$������$��+�+�c�1�-�a�0��%���%�%�k�2�F� $�F��/�F�O�!(�F���F�K��d�"�#4�"5���(.�D�L�L��%��k�)�0;�K�0H�� � ��-�)	Irc� �|j|Sr)rf)r�rs  r�__getitem__z_ImporterMock.__getitem__�s���|�|�D�!�!rc��t|jj��|_|jj	�|Sr)rirf�keys�_uncache�	__enter__)r�s rr�z_ImporterMock.__enter__�s0������!2�!2�!4�5��
��
�
���!��rc�>�|jjddd�yr)r��__exit__)r��exc_infos  rr�z_ImporterMock.__exit__�s���
�
���t�T�4�0rN)r0r3�__qualname__�__doc__r�r�r�r�rrrr�r��s��:�+-�I�2"��
1rr�c�$�eZdZdZdd�Zd�Zd�Zy)�	mock_specz!Importer mock using PEP 451 APIs.Nc
��	|j|}tj||j|t|dd���}|S#t$rYywxYw)Nr�)�loader�submodule_search_locations)rfrgr�spec_from_file_locationr�r|)r��fullnamerrVr��specs      r�	find_speczmock_spec.find_spec�sZ��	��\�\�(�+�F��+�+��&�/�/�$�+2�6�:�t�+L�N������	��	�s�A�	A
�A
c�p�|j|jvrt�|j|jSr)rrf�ImportError)r�r�s  r�
create_modulezmock_spec.create_modules+���9�9�D�L�L�(����|�|�D�I�I�&�&rc�t�	|j|jj�y#t$rYywxYwr)r��__spec__rrg)r�r�s  r�exec_modulezmock_spec.exec_modules6��	�2�D���V�_�_�1�1�2�4���	��	�s�(+�	7�7)NN)r0r3r�r�r�r�r�rrrr�r��s��+��'�
rr�c���tjrtjd���St	j
���fd��}|S)ztDecorator to protect sys.dont_write_bytecode from mutation and to skip
    tests that require it to be set to False.zrelies on writing bytecodec���tj}dt_	�|i|��}|t_|S#|t_wxYw)NF)r
�dont_write_bytecode)�argsr;�original�	to_return�fxns    �r�wrapperz&writes_bytecode_files.<locals>.wrappersD����*�*��"'���	/��T�,�V�,�I�&.�C�#����'/�C�#�s	�3�
A)r
r�r+�skip�	functools�wraps)r�r�s` r�writes_bytecode_filesr�sG������:�x�}�}�9�:�3�?�?��_�_�S������Nrc���	tjtjj|��y#t$r(}|j
t
jk7r�Yd}~yd}~wwxYw)z�Ensure that the __pycache__ directory for PEP 3147 pyc file exists.

    :param bytecode_path: File system path to PEP 3147 pyc file.
    N)rrpr�dirname�OSErrorr�EEXIST)�
bytecode_path�errors  r�ensure_bytecode_pathr� sH��
�
���������/�0�����;�;�%�,�,�&��'���s�25�	A&�A!�!A&c#�K�tj}|t_	d��|t_y#|t_wxYw�w)z&Adjust and restore sys.pycache_prefix.N)r
�pycache_prefix)�prefix�_orig_prefixs  r�temporary_pycache_prefixr�,s3�����%�%�L��C��*�
�)����\���s�?�/�?�
<�?c'�K�d}g}i}d}d}	tj�}||d<t�}|D�]P}|jd�s|}	n|dt	d�}	|j|	�|	tjvrtj|	=|jd�}
|}|
ddD]h}tjj||�}tjj|�r�Ctj|�|j|��jtjj||
ddz�}t|d	d
��5}
|
j!|j#|��ddd�|j|�|||<��St%|�}|j'�t)|g��}|j'�|��|�|j+ddd�|�|j+ddd�t-j.|�y#1swY��xYw#|�|j+ddd�|�|j+ddd�t-j.�wxYw�w)
aRTemporarily create each named module with an attribute (named 'attr')
    that contains the name passed into the context manager that caused the
    creation of the module.

    All files are created in a temporary directory returned by
    tempfile.mkdtemp(). This directory is inserted at the beginning of
    sys.path. When the context manager exits all created files (source and
    bytecode) are explicitly deleted.

    No magic is performed when creating packages! This means that if you create
    a module within a package you must also create the package's __init__ as
    well.

    zattr = {0!r}Nz.rootr�r�r���rOrPrQrR)r)�tempfile�mkdtemp�setr�r}�addr
rf�splitrrrrrp�appendrTrUr/rir�r�r�r�rmtree)rhr(�
created_paths�mapping�
state_manager�uncache_manager�temp_dir�import_namesrr��
name_partsr�	directory�files              r�create_modulesr�7s&���� �F��M��G��M��O�"#��#�#�%��#�����u���	&�D��=�=��,�"��"�#5�S��%5�$5�6�����[�)��c�k�k�)��K�K��,����C��J� �I�'���_�
4�	��G�G�L�L��I�>�	��w�w�~�~�i�0��H�H�Y�'�!�(�(��3�	
4�
�����Y�
�2���0F�G�I��i��w�7�
0�4��
�
�6�=�=��.�/�
0�� � ��+�%�G�D�M�'	&�("�<�0���!�!�#�$�8�*�5�
����!��
��$��"�"�4��t�4��&��$�$�T�4��6�����"�
0�
0���$��"�"�4��t�4��&��$�$�T�4��6�����"�s?�I�CH�)AH�!H�&AH�AI�H		�H�AI
�
Ic������fd�}|S)zA mock sys.path_hooks entry.c���|�vrt��Sr)r�)�entry�entries�importers ��r�hookzmock_path_hook.<locals>.hookss���������rr)r�r�r�s`` r�mock_path_hookr�qs�����Krc��eZdZd�Zy)�CASEOKTestBasec�\��d}t�fd�|D��|k7r�jd�yy)N)sPYTHONCASEOK�PYTHONCASEOKc3�v�K�|]0}|�jjjjv���2y�wr)r	�_bootstrap_external�_os�environ)�.0�xr�s  �r�	<genexpr>z4CASEOKTestBase.caseok_env_changed.<locals>.<genexpr>~s4�����,���D�N�N�6�6�:�:�B�B�B�,�s�69z/os.environ changes not reflected in _os.environ)�any�skipTest)r��should_exist�
possibilitiess`  r�caseok_env_changedz!CASEOKTestBase.caseok_env_changed|s7���7�
��,�*�,�,�/;�<��M�M�K�L�<rN)r0r3r�r�rrrr�r�zs��Mrr�r)rl);�builtins�
contextlibrr�r	rrrr_r�os.path�test.supportrrr+r
r�r1�SimpleNamespace�BUILTINS�	good_name�bad_name�builtin_module_namesrrrrrrrr)rArCrFrK�platformr��upper�changed_name�lowerr�source_importlib�staticmethod�
__import__rMrZrc�contextmanagerrirwr�r�r�r�r�r�r�r�r�rrr�<module>rs$������8�8��	��&�"��
���!�5� � �"��������
�c�&�&�&� �H���c�.�.�.�#�H��
"�U�
"�
"�
$�
��
���
���
���
��$�
�����0��&�4����<�<�*�*��>�>�#�L��x���~�~�'��
�7�7�>�>�,�'�#��#�K�0��:��$�X�%8�%8�9�$�%5�%@�%@�A�C�
�L�.�#�������0��������.���&��&�:&1�&1�R�
��4�"	����*��*����6#��6#�r�M�Mr