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.7/test/test_importlib/__pycache__/util.cpython-37.opt-1.pyc
B

��g$G�@s�ddlZddlZddlZddlZddlZddlZddlmZmZmZddl	m
Z
ddlZddlZddl
Z
ddlZ
ddlmZmZddlmZddlZddlZddlZddlZddlmZddlmZe��Zde_de_d	ejkr�d	e_d
ejkr�d
e_e��a dt _!dt _"dt _#dt _$dt _%dd
�Z&e&�dd�Z'dBdd�Z(dCdd�Z)dDdd�Z*dZ+ej,dk�r�e-�.�Z/e/e-k�r|e-�0�Z/e
j!�1e/��s�dZ+e'd
�dZ2e3ej4�e3e2j4�d�Z4dd�Z5dEdd�Z6d d!�Z7ej8d"d#��Z9ej8dFdd$�d%d&��Z:ej8d'd(��Z;Gd)d*�d*�Z<Gd+d,�d,e<�Z=Gd-d.�d.e<�Z>d/d0�Z?d1d2�Z@ej8d3d4��ZAd5d6�ZBGd7d8�d8�ZCdGd:d;�ZDGd<d=�d=ejE�ZFGd>d?�d?�ZGGd@dA�dAeG�ZHdS)H�N)�	machinery�util�invalidate_caches)�ResourceReader)�Path�PurePath)�support�)�data01)�	zipdata01�errno�	importlibZ	_testcapicCsdx^tjD]T}xNtjD]D}tj|}tj�||�}tj�|�r|t_|t_	|t_
|t_dSqWqWdS)N)�sys�pathr�EXTENSION_SUFFIXES�
EXTENSIONS�name�os�join�exists�ext�filename�	file_path)rrrr�r�4/usr/local/lib/python3.7/test/test_importlib/util.py�_extension_details's
rcCs4d|krdnd}t�|�}tj||dd�}||d�S)zAImport a module from importlib both w/ and w/o _frozen_importlib.�.)r
r)�_frozen_importlib�_frozen_importlib_external)�freshZblocked)�Frozen�Source)rZimport_fresh_module)Zmodule_namer�frozen�sourcerrr�import_importlib7s

r$c
Ks�|dkrtj}nt|t�s"||}d�||j�}||f}t�||�}|j|_|j|_	||_
x(|��D]\}}||}	t|||	�qdW|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_class@s
r7cKs(t|d|f|�}t|d|f|�}||fS)Nr r!)r7)r/r1r2r"r#rrr�split_frozenSsr8cKst||f|�S)N)r8)Z
test_classr1r2rrr�	test_bothYsr9T)�win32�cygwinFr!)r 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_testslsr?�c	CsBtj�||d�}t|d��}|�|�WdQRXd�||�|fS)Nz.py�wz{}.{})rrr�open�writer()�parentrZpkg_dir�contentrZsubfilerrr�	submodulessrFc	Cs*t|d��}|�d�t�|�SQRXdS)znReads a pyc file and returns the unmarshalled code object within.

    No header validation is performed.
    �rb�N)rB�seek�marshal�load)Zpyc_pathZpyc_frrr�_get_code_from_pyczs
rLcgs�xD|D]<}|dkr td�|���ytj|=Wqtk
r@YqXqWz
dVWdx.|D]&}ytj|=WqXtk
r|YqXXqXWXdS)z�Uncache a module from sys.modules.

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

    )rrJZimpzcannot uncache {0}N)�
ValueErrorr(r�modules�KeyError)�namesrrrr�uncache�s



rQ)�pkgc#s��fdd�tjD�}t�d���}t�f|����t�|��zt�tj�	|��}|rntj�	|d�}t�
��n|d}|dkr�d}|dk	r�t|d��}|�|�WdQRX|VWdQRXWdQRXWdQRXdS)Ncs"g|]}|�d�d�kr|�qS)rr)�	partition)�.0�n)rrr�
<listcomp>�sztemp_module.<locals>.<listcomp>z__init__.pyz.pyr@rA)
rrNrZtemp_cwdrQZ
DirsOnSysPathrrrr�mkdirrBrC)rrErR�	conflicts�cwd�locationZmodpathZmodfiler)rr�temp_module�s r[cks�i}z�x^dgfdgfdgfdiffD]>\}}tt|�||<||krR||}||=n|}tt||�q$Wt|�r�td�|�����dVWdx |��D]\}}tt||�q�WXdS)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)�getattrrr.�lenrMr(�keysr-)r2Z	originalsr4�defaultZ	new_valuer6rrr�import_state�s"

rcc@s6eZdZdZid�dd�Zdd�Zdd�Zd	d
�ZdS)�
_ImporterMockz0Base class to help with creating importer mocks.)�module_codecGs�i|_i|_x�|D]�}|�d�s&|}n|dtd��}d|krFd}n||kr`|�dd�d}n|}t�|�}||_d|_||_	||_
||kr�dg|_||j|<||kr|||j|<qWdS)Nz	.__init__rr	rz<mock __file__>z<mock __path__>)rNre�endswithr`�rsplitr*�
ModuleType�
__loader__�__file__�__package__r4�__path__)�selfrerPr�import_name�package�modulerrr�__init__�s*



z_ImporterMock.__init__cCs
|j|S)N)rN)rmrrrr�__getitem__�sz_ImporterMock.__getitem__cCst|j���|_|j��|S)N)rQrNra�_uncache�	__enter__)rmrrrrt�s
z_ImporterMock.__enter__cGs|j�ddd�dS)N)rs�__exit__)rm�exc_inforrrru�sz_ImporterMock.__exit__N)r)r,�__qualname__�__doc__rqrrrtrurrrrrd�s
rdc@s"eZdZdZddd�Zdd�ZdS)�mock_modulesz!Importer mock using PEP 302 APIs.NcCs||jkrdS|SdS)N)rN)rm�fullnamerrrr�find_modules
zmock_modules.find_modulecCsh||jkrt�nT|j|tj|<||jkrZy|j|�Wntk
rXtj|=�YnX|j|SdS)N)rN�ImportErrorrre�	Exception)rmrzrrr�load_modules

zmock_modules.load_module)N)r)r,rwrxr{r~rrrrry�s
ryc@s*eZdZdZd	dd�Zdd�Zdd�ZdS)
�	mock_specz!Importer mock using PEP 451 APIs.NcCsDy|j|}Wntk
r"dSXtj||j|t|dd�d�}|S)Nrl)�loader�submodule_search_locations)rNrOr�spec_from_file_locationrjr_)rmrzrrDrp�specrrr�	find_specszmock_spec.find_speccCs|j|jkrt�|j|jS)N)rrNr|)rmr�rrr�
create_module$szmock_spec.create_modulecCs.y|j|jj�Wntk
r(YnXdS)N)re�__spec__rrO)rmrprrr�exec_module)szmock_spec.exec_module)NN)r)r,rwrxr�r�r�rrrrrs

rcs(tjrdd�St����fdd��}|S)ztDecorator to protect sys.dont_write_bytecode from mutation and to skip
    tests that require it to be set to False.c_sdS)Nr)�argsr2rrr�<lambda>4�z'writes_bytecode_files.<locals>.<lambda>cs(tj}dt_z�||�}Wd|t_X|S)NF)r�dont_write_bytecode)r�r2ZoriginalZ	to_return)�fxnrr�wrapper5sz&writes_bytecode_files.<locals>.wrapper)rr��	functools�wraps)r�r�r)r�r�writes_bytecode_files0s	r�c
CsLyt�tj�|��Wn0tk
rF}z|jtjkr6�Wdd}~XYnXdS)z�Ensure that the __pycache__ directory for PEP 3147 pyc file exists.

    :param bytecode_path: File system path to PEP 3147 pyc file.
    N)rrWr�dirname�OSErrorrZEEXIST)�
bytecode_path�errorrrr�ensure_bytecode_pathAs
r�cgs�d}g}i}d}d}�z0t��}||d<t�}x�|D]�}|�d�sH|}	n|dtd��}	|�|	�|	tjkrvtj|	=|�d�}
|}xB|
dd�D]2}t	j
�||�}t	j
�|�s�t	�
|�|�|�q�Wt	j
�||
dd�}t|d	��}
|
�|�|��WdQRX|�|�|||<q4Wt|�}|��t|gd
�}|��|VWd|dk	�r`|�ddd�|dk	�rx|�ddd�t�|�XdS)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.rootrqz	.__init__r���z.pyrA)r)�tempfileZmkdtemp�setrfr`�addrrN�splitrrrrrW�appendrBrCr(rQrtrcrurZrmtree)rPr#Z
created_paths�mappingZ
state_managerZuncache_managerZtemp_dirZimport_namesrrnZ
name_partsrZ	directory�filerrr�create_modulesMsL









r�cs��fdd�}|S)zA mock sys.path_hooks entry.cs|�krt��S)N)r|)�entry)�entries�importerrr�hook�szmock_path_hook.<locals>.hookr)r�r�r�r)r�r�r�mock_path_hook�sr�c@seZdZdd�ZdS)�CASEOKTestBasecs,d}t�fdd�|D��|kr(��d�dS)N)sPYTHONCASEOK�PYTHONCASEOKc3s|]}|�jjjjkVqdS)N)r
�_bootstrap_external�_os�environ)rT�x)rmrr�	<genexpr>�sz4CASEOKTestBase.caseok_env_changed.<locals>.<genexpr>z/os.environ changes not reflected in _os.environ)�anyZskipTest)rmZshould_existZ
possibilitiesr)rmr�caseok_env_changed�sz!CASEOKTestBase.caseok_env_changedN)r)r,rwr�rrrrr��sr�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|S)Nr)rmrorrr�get_resource_reader�sz2create_package.<locals>.Reader.get_resource_readercs||_t�t�r��n�SdS)N)�_pathr&r})rmr)r�rr�
open_resource�s
z,create_package.<locals>.Reader.open_resourcecs||_t�t�r��n�SdS)N)r�r&r})rm�path_)rrr�
resource_path�s
z,create_package.<locals>.Reader.resource_pathcsL||_t�t�r��x2�D]*}|�d�}t|�dkr|d|krdSqWdS)N�/r	rTF)r�r&r}r�r`)rmr�r��parts)�contentsrrr�is_resource�s


z*create_package.<locals>.Reader.is_resourcec3s&t�t�r��x�D]
}|VqWdS)N)r&r})rmr�)r�rrrr��s

z'create_package.<locals>.Reader.contentsN)r)r,rwr�r�r�r�r�r)r�r�rrr�Reader�s

r�Ztestingpackagezdoes-not-exist)�origin�
is_package)rr*rhr�
ModuleSpecr�ri)	r�rr�r�r�rrpr�r�r)r�r�rr�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�dS)N)�NotImplementedError)rmrorrrr�execute�szCommonResourceTests.executecCs|�tjd�dS)Nz
utf-8.file)r�r
r))rmrrr�test_package_name�sz%CommonResourceTests.test_package_namecCs|�td�dS)Nz
utf-8.file)r�r
)rmrrr�test_package_object�sz'CommonResourceTests.test_package_objectcCsd}|�t|�dS)Nz
utf-8.file)r�r
)rmrrrr�test_string_path�sz$CommonResourceTests.test_string_path)��zrequires os.PathLike supportcCstd�}|�t|�dS)Nz
utf-8.file)rr�r
)rmrrrr�test_pathlib_path�sz%CommonResourceTests.test_pathlib_pathc	Cs8tt�}|jd}|�t��|�t|�WdQRXdS)Nz
utf-8.file)rrjrD�assertRaisesrMr�r
)rmr�	full_pathrrr�test_absolute_path�s
z&CommonResourceTests.test_absolute_pathc	Cs&|�t��|�td�WdQRXdS)Nz../data01/utf-8.file)r�rMr�r
)rmrrr�test_relative_path�sz&CommonResourceTests.test_relative_pathcCstjtj=|�tjd�dS)Nz
utf-8.file)rrNr
r)r�)rmrrr�$test_importing_module_as_side_effect�s
z8CommonResourceTests.test_importing_module_as_side_effectc	Cs&|�t��|�td�WdQRXdS)Nz
utf-8.file)r��	TypeErrorr�r))rmrrr�test_non_package_by_name�sz,CommonResourceTests.test_non_package_by_namec	Cs0|�t��tjd}|�|d�WdQRXdS)Nztest.test_importlib.utilz
utf-8.file)r�r�rrNr�)rmrprrr�test_non_package_by_package�s
z/CommonResourceTests.test_non_package_by_package)r�zNo ResourceReader in Python 2cCs8t�d�}t|t�d�}|�|d�|�|jjd�dS)Ns
Hello, world!)r�rz
utf-8.file)�io�BytesIOr��FileNotFoundErrorr��assertEqualrir�)rm�
bytes_datarorrr�test_resource_opener�s
z(CommonResourceTests.test_resource_openercCs:t�d�}t}t||d�}|�|d�|�|jjd�dS)Ns
Hello, world!)r�rz
utf-8.file)r�r�rjr�r�r�rir�)rmr�rrorrr�test_resource_paths

z&CommonResourceTests.test_resource_pathc	Cs6tt�t�d�}|�t��|�|d�WdQRXdS)N)r�rz
utf-8.file)r�r�r�r�)rmrorrr�test_useless_loaders
z'CommonResourceTests.test_useless_loaderN)r)r,rw�abc�abstractmethodr�r�r�r�r%r<r�version_infor�r�r�r�r�r�r�r�r�rrrrr��sr�c@s0eZdZdZedd��Zedd��Zdd�ZdS)�ZipSetupBaseNcCs>t|jj�}|j}t|d�|_tj�|j�t	�
d�|_dS)Nzziptestdata.zipZziptestdata)r�
ZIP_MODULErjrD�str�	_zip_pathrrr�r
�
import_module�data)r/Z	data_pathZdata_dirrrr�
setUpClasss
zZipSetupBase.setUpClasscCs~ytj�|j�Wntk
r&YnXytj|j=tj|jj=Wnt	k
rVYnXy|`|`Wnt
k
rxYnXdS)N)rr�remover�rMr^rNr�r)rO�AttributeError)r/rrr�
tearDownClass s
zZipSetupBase.tearDownClasscCst��}|jtjf|��dS)N)rZ
modules_setupZ
addCleanupZmodules_cleanup)rmrNrrr�setUp3szZipSetupBase.setUp)r)r,rwr��classmethodr�r�r�rrrrr�sr�c@seZdZeZdS)�ZipSetupN)r)r,rwrr�rrrrr�8sr�)N)N)N)r@)r@)Tr)Ir��builtins�
contextlibrr�r
rrrZ
importlib.abcrr�rJrZos.pathZpathlibrrr>rr%rr�r*r@r
r�SimpleNamespaceZBUILTINSZ	good_nameZbad_name�builtin_module_namesrrrrrrrr$r7r8r9r=�platformrj�upperZchanged_name�lowerrZsource_importlib�staticmethod�
__import__r?rFrL�contextmanagerrQr[rcrdryrr�r�r�r�r�r��ABCr�r�r�rrrr�<module>s�


	





):		
2J#