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/test_importlib/__pycache__/util.cpython-310.opt-1.pyc
o

�i�H�@s�ddlZddlZddlZddlZddlZddlZddlmZmZmZddl	m
Z
ddlZddlZddl
Z
ddlZ
ddlmZmZddlmZddlmZddlmZddlZddlZddlZddlZdd	lmZdd
lmZe��Zde_ de_!dej"vr�de_ dej"vr�de_!e��a#dt#_$dt#_%dt#_&dt#_'d
t#_(dd�Z)e)�dd�Z*dFdd�Z+dFdd�Z,dFdd�Z-dZ.ej/dvr�e0�1�Z2e2e0kr�e0�3�Z2e
j$�4e2�s�dZ.e*d�dZ5e6ej7�e6e5j7�d�Z7dd�Z8dGd d!�Z9d"d#�Z:ej;d$d%��Z<ej;dGdd&�d'd(��Z=ej;d)d*��Z>Gd+d,�d,�Z?Gd-d.�d.e?�Z@Gd/d0�d0e?�ZAd1d2�ZBd3d4�ZCej;d5d6��ZDej;d7d8��ZEd9d:�ZFGd;d<�d<�ZGdHd>d?�ZHGd@dA�dAejI�ZJGdBdC�dC�ZKGdDdE�dEeK�ZLdS)I�N)�	machinery�util�invalidate_caches)�ResourceReader)�Path�PurePath)�support)�
import_helper)�	os_helper�)�data01)�	zipdata01�errno�	importlibZ	_testcapicCs`tjD]*}tjD]$}tj|}tj�||�}tj�|�r,|t_|t_	|t_
|t_dSqqdS�N)�sys�pathr�EXTENSION_SUFFIXES�
EXTENSIONS�name�os�join�exists�ext�filename�	file_path)rrrr�r�5/usr/local/lib/python3.10/test/test_importlib/util.py�_extension_details)s


���rcCs4d|vrdnd}t�|�}tj||dd�}||d�S)zAImport a module from importlib both w/ and w/o _frozen_importlib.�.)rr)�_frozen_importlib�_frozen_importlib_external)�freshZblocked��Frozen�Source)r	Zimport_fresh_module)�module_namer"�frozen�sourcerrr�import_importlib9s
�
r)c
Ks�|durtj}n	t|t�s||}d�||j�}||f}t�||�}|j|_|j|_	||_
|��D]\}}||}	t|||	�q1|S)Nz{}_{})
�unittestZTestCase�
isinstance�type�format�__name__�types�	new_class�
__module__Z_NAMEZ_KIND�items�setattr)
�cls�kind�base�kwargsr�basesZspecialized�attr�values�valuerrr�specialize_classBs
r<cKs0t|d|fi|��}t|d|fi|��}||fS)Nr$r%)r<)r4r6r7r'r(rrr�split_frozenUsr=cKst||fi|��Sr)r=)Z
test_classr6r7rrr�	test_both[sr>T)�win32�cygwinFr%r#cCst�td�|�S)zRClass decorator that nullifies tests requiring a case-insensitive
    file system.z&requires a case-insensitive filesystem)r*�skipIf�CASE_INSENSITIVE_FS)�testrrr�case_insensitive_testsns
��rD�cCsZtj�||d�}t|ddd��
}|�|�Wd�n1s wYd�||�|fS)N�.py�w�utf-8��encodingz{}.{})rrr�open�writer-)�parentrZpkg_dir�contentrZsubfilerrr�	submoduleus
�rOcCsBt|d��}|�d�t�|�Wd�S1swYdS)znReads a pyc file and returns the unmarshalled code object within.

    No header validation is performed.
    �rb�N)rK�seek�marshal�load)Zpyc_pathZpyc_frrr�get_code_from_pyc|s
$�rUcgs��|D]}|dvrtd�|���ztj|=WqtyYqwzdVW|D]}ztj|=Wq'ty8Yq'wdS|D]}ztj|=Wq=tyNYq=ww)z�Uncache a module from sys.modules.

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

    )rrSZimpzcannot uncache {0}N)�
ValueErrorr-r�modules�KeyError)�namesrrrr�uncache�s4�������rZ)�pkgc#s<��fdd�tjD�}t�d���}t�g|�R��ct�|��Nt�tj	�
|��}|r9tj	�
|d�}t���n
|d}|durCd}|durct|ddd��
}|�
|�Wd�n1s^wY|VWd�n1spwYWd�n1swYWd�dSWd�dS1s�wYdS)	Ncs"g|]
}|�d�d�kr|�qS)rr)�	partition)�.0�n�rrr�
<listcomp>�s"ztemp_module.<locals>.<listcomp>z__init__.pyrFrErGrHrI)rrWr
Ztemp_cwdrZr	Z
DirsOnSysPathrrrr�mkdirrKrL)rrNr[�	conflicts�cwd�location�modpathZmodfilerr_r�temp_module�s0������"�rfcks��i}zPdgfdgfdgfdiffD]\}}tt|�||<||vr)||}||=n|}tt||�qt|�r?td�|�����dVW|��D]
\}}tt||�qGdS|��D]
\}}tt||�qXw)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: {0}N)�getattrrr3�lenrVr-�keysr2)r7Z	originalsr9�defaultZ	new_valuer;rrr�import_state�s.�
����rnc@s6eZdZdZid�dd�Zdd�Zdd�Zd	d
�ZdS)�
_ImporterMockz0Base class to help with creating importer mocks.)�module_codecGs�i|_i|_|D]R}|�d�s|}n	|dtd��}d|vr"d}n||kr/|�dd�d}n|}t�|�}||_d|_||_	||_
||krJdg|_||j|<||vrZ|||j|<qdS)N�	.__init__rrrz<mock __file__>z<mock __path__>)rWrp�endswithrk�rsplitr/�
ModuleType�
__loader__�__file__�__package__r9�__path__)�selfrprYr�import_name�package�modulerrr�__init__�s.


��z_ImporterMock.__init__cCs
|j|Sr�rW)ryrrrr�__getitem__�s
z_ImporterMock.__getitem__cCst|j���|_|j��|Sr)rZrWrl�_uncache�	__enter__�ryrrrr��s
z_ImporterMock.__enter__cGs|j�ddd�dSr)r��__exit__)ry�exc_inforrrr��sz_ImporterMock.__exit__N)r.r1�__qualname__�__doc__r}rr�r�rrrrro�sroc@s"eZdZdZddd�Zdd�ZdS)�mock_modulesz!Importer mock using PEP 302 APIs.NcCs||jvrdS|Srr~)ry�fullnamerrrr�find_modules
zmock_modules.find_modulecCs\||jvrt�|j|tj|<||jvr)z|j|�Wnty(tj|=�w|j|Sr)rW�ImportErrorrrp�	Exception)ryr�rrr�load_module
s

�
zmock_modules.load_moduler)r.r1r�r�r�r�rrrrr�s
r�c@s*eZdZdZd	dd�Zdd�Zdd�ZdS)
�	mock_specz!Importer mock using PEP 451 APIs.NcCsDz|j|}Wn
tyYdSwtj||j|t|dd�d�}|S)Nrx)�loader�submodule_search_locations)rWrXr�spec_from_file_locationrvrj)ryr�rrMr|�specrrr�	find_specs�
�zmock_spec.find_speccCs|j|jvrt�|j|jSr)rrWr�)ryr�rrr�
create_module&szmock_spec.create_modulecCs,z|j|jj�WdStyYdSwr)rp�__spec__rrX�ryr|rrr�exec_module+s
�zmock_spec.exec_module)NN)r.r1r�r�r�r�r�rrrrr�s


r�cs.tjr
t�d���St����fdd��}|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 bytecodecs0tj}dt_z
�|i|��}W|t_|S|t_w)NF)r�dont_write_bytecode)�argsr7ZoriginalZ	to_return��fxnrr�wrapper7s�z&writes_bytecode_files.<locals>.wrapper)rr�r*�skip�	functools�wraps)r�r�rr�r�writes_bytecode_files2s
r�c
CsNzt�tj�|��WdSty&}z|jtjkr�WYd}~dSd}~ww)z�Ensure that the __pycache__ directory for PEP 3147 pyc file exists.

    :param bytecode_path: File system path to PEP 3147 pyc file.
    N)rrar�dirname�OSErrorr�EEXIST)�
bytecode_path�errorrrr�ensure_bytecode_pathCs���r�ccs*�tj}|t_z	dVW|t_dS|t_w)z&Adjust and restore sys.pycache_prefix.N)r�pycache_prefix)�prefixZ_orig_prefixrrr�temporary_pycache_prefixOs�r�cgs��d}g}i}d}d}z�t��}||d<t�}|D]{}|�d�s#|}	n	|dtd��}	|�|	�|	tjvr:tj|	=|�d�}
|}|
dd�D]}t	j
�||�}t	j
�|�s`t	�
|�|�|�qGt	j
�||
dd�}t|d	d
d��}
|
�|�|��Wd�n1s�wY|�|�|||<qt|�}|��t|gd�}|��|VW|dur�|�ddd�|dur�|�ddd�t�|�dS|dur�|�ddd�|dur�|�ddd�t�|�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}rqr���rFrGrHrI�r)�tempfile�mkdtemp�setrrrk�addrrW�splitrrrrra�appendrKrLr-rZr�rnr�r
�rmtree)rYr(Z
created_paths�mappingZ
state_managerZuncache_managerZtemp_dirZimport_namesrrzZ
name_partsrZ	directory�filerrr�create_modulesZs\�





��

�r�cs��fdd�}|S)zA mock sys.path_hooks entry.cs|�vrt��Sr)r�)�entry��entries�importerrr�hook�szmock_path_hook.<locals>.hookr)r�r�r�rr�r�mock_path_hook�sr�c@seZdZdd�ZdS)�CASEOKTestBasecs0d}t�fdd�|D��|kr��d�dSdS)N)sPYTHONCASEOK�PYTHONCASEOKc3s �|]}|�jjjjvVqdSr)r�_bootstrap_external�_os�environ)r]�xr�rr�	<genexpr>�s��z4CASEOKTestBase.caseok_env_changed.<locals>.<genexpr>z/os.environ changes not reflected in _os.environ)�anyZskipTest)ryZshould_existZ
possibilitiesrr�r�caseok_env_changed�s���z!CASEOKTestBase.caseok_env_changedN)r.r1r�r�rrrrr��sr�rc	sNG���fdd�dt�}d}t�|�}|�}tj||d|d�}||_||_|S)NcsHeZdZdd�Z�fdd�Z�fdd�Z��fdd�Z��fd	d
�ZdS)zcreate_package.<locals>.ReadercSs|Srr�ryr{rrr�get_resource_reader�sz2create_package.<locals>.Reader.get_resource_readerc�||_t�t�r
���Sr��_pathr+r��ryr)r�rr�
open_resource��
z,create_package.<locals>.Reader.open_resourcecr�rr�)ry�path_r�rr�
resource_path�r�z,create_package.<locals>.Reader.resource_pathcsJ||_t�t�r
���D]}|�d�}t|�dkr"|d|kr"dSqdS)N�/rrTF)r�r+r�r�rk)ryr�r��parts��contentsrrr�is_resource�s

�z*create_package.<locals>.Reader.is_resourcec3s$�t�t�r���D]}|Vq
dSr)r+r�)ryr�r�rrr��s�
�z'create_package.<locals>.Reader.contentsN)r.r1r�r�r�r�r�r�r�r�r�rrr�Reader�s
r�Ztestingpackagezdoes-not-exist)�origin�
is_package)rr/rtr�
ModuleSpecr�ru)	r�rr�r�r�rr|r�r�rr�r�create_package�s#
�r�c@s�eZdZejdd��Zdd�Zdd�Zdd�Ze	�
ejd	kd
�dd��Z
d
d�Zdd�Zdd�Zdd�Zdd�Ze	�
ejdkd�dd��Ze	�
ejdkd�dd��Zdd�ZdS) �CommonResourceTestscCst�r)�NotImplementedError)ryr{rrrr�execute�szCommonResourceTests.executecCs|�tjd�dS�N�
utf-8.file)r�rr.r�rrr�test_package_name�sz%CommonResourceTests.test_package_namecCs|�td�dSr��r�rr�rrr�test_package_object�sz'CommonResourceTests.test_package_objectcCsd}|�t|�dSr�r�r�rrr�test_string_path�sz$CommonResourceTests.test_string_path)��zrequires os.PathLike supportcCstd�}|�t|�dSr�)rr�rr�rrr�test_pathlib_path�sz%CommonResourceTests.test_pathlib_pathcCsNtt�}|jd}|�t��|�t|�Wd�dS1s wYdSr�)rrvrM�assertRaisesrVr�r)ryr�	full_pathrrr�test_absolute_path�s

"�z&CommonResourceTests.test_absolute_pathcC�<|�t��|�td�Wd�dS1swYdS)Nz../data01/utf-8.file)r�rVr�rr�rrr�test_relative_path��"�z&CommonResourceTests.test_relative_pathcCstjtj=|�tjd�dSr�)rrWrr.r�r�rrr�$test_importing_module_as_side_effect�s
z8CommonResourceTests.test_importing_module_as_side_effectcCr�r�)r��	TypeErrorr�r.r�rrr�test_non_package_by_namer�z,CommonResourceTests.test_non_package_by_namecCsF|�t��tjd}|�|d�Wd�dS1swYdS)Nztest.test_importlib.utilr�)r�r�rrWr�r�rrr�test_non_package_by_packages
"�z/CommonResourceTests.test_non_package_by_package)r�zNo ResourceReader in Python 2cCs8t�d�}t|t�d�}|�|d�|�|jjd�dS�Ns
Hello, world!�r�rr�)�io�BytesIOr��FileNotFoundErrorr��assertEqualrur�)ry�
bytes_datar{rrr�test_resource_openers
z(CommonResourceTests.test_resource_openercCs:t�d�}t}t||d�}|�|d�|�|jjd�dSr�)r�r�rvr�r�r�rur�)ryr�rr{rrr�test_resource_paths

z&CommonResourceTests.test_resource_pathcCsLtt�t�d�}|�t��|�|d�Wd�dS1swYdS)Nr�r�)r�r�r�r�r�rrr�test_useless_loaders�"�z'CommonResourceTests.test_useless_loaderN)r.r1r��abc�abstractmethodr�r�r�r�r*rAr�version_infor�r�r�r�r�r�r�r�r�rrrrr��s$



r�c@s0eZdZdZedd��Zedd��Zdd�ZdS)�ZipSetupBaseNcCs>t|jj�}|j}t|d�|_tj�|j�t	�
d�|_dS)Nzziptestdata.zipZziptestdata)r�
ZIP_MODULErvrM�str�	_zip_pathrrr�r�
import_module�data)r4Z	data_pathZdata_dirrrr�
setUpClass%s
zZipSetupBase.setUpClasscCsxz	tj�|j�Wn	tyYnwz
tj|j=tj|jj=Wn	t	y)Ynwz|`|`WdSt
y;YdSwr)rr�remover�rVrirWrr.rX�AttributeError)r4rrr�
tearDownClass-s"�
�
�zZipSetupBase.tearDownClasscCs t��}|jtjg|�R�dSr)r	Z
modules_setupZ
addCleanupZmodules_cleanup)ryrWrrr�setUp@szZipSetupBase.setUp)r.r1r�r��classmethodrrrrrrrr�"s

r�c@seZdZeZdS)�ZipSetupN)r.r1r�r
r�rrrrrEsrr)rE)Tr)Mr��builtins�
contextlibrr�rrrrZ
importlib.abcrr�rSrZos.path�pathlibrrrCrZtest.supportr	r
r*rr�r/rErr
�SimpleNamespaceZBUILTINSZ	good_nameZbad_name�builtin_module_namesrrrrrrrr)r<r=r>rB�platformrv�upperZchanged_name�lowerrZsource_importlib�staticmethod�
__import__rDrOrU�contextmanagerrZrfrnror�r�r�r�r�r�r�r�r��ABCr�r�rrrrr�<module>s�



	


�



)


9	
	2J#