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/__pycache__/test_imp.cpython-310.opt-2.pyc
o

�i�K�@s6ddlZddlZddlZddlZddlZddlZddlZddlmZddl	m
Z
ddl	mZddl	mZddl
Z
ddlZe���e�de�ddlZWd�n1sUwYddlZdd�ZGd	d
�d
e
j�ZGdd�de
j�ZGd
d�de
j�ZGdd�de
j�ZGdd�de
j�Zedkr�e
��dSdS)�N)�support)�
import_helper)�	os_helper)�
script_helper�ignorecCs$	t�|�}t�ttd�d�|�S)N�load_dynamiczimp.load_dynamic() required)r�cpython_only�unittest�skipIf�hasattr�imp)�meth�r�*/usr/local/lib/python3.10/test/test_imp.py�requires_load_dynamics
��rc@seZdZ	dd�Zdd�ZdS)�	LockTestscCs|�t��|d|�dS)Nz!expected imp.lock_held() to be %r)�assertEqualr�	lock_held)�self�expectedrrr�verify_lock_state s�zLockTests.verify_lock_statecCs�d}t��}|�|�t|�D]}t��|�d�qt|�D]}t��q|�|�|sEzt��Wn
ty=YdSw|�d�dSdS)N�2Tz5release_lock() without lock should raise RuntimeError)rrr�range�acquire_lock�release_lock�RuntimeErrorZfail)rZLOOPSZlock_held_at_start�irrr�testLock#s"


��zLockTests.testLockN)�__name__�
__module__�__qualname__rrrrrrrsrc@s�eZdZdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	dd�Z
edd��Zedd��Z
edd��Zedd��Zedd��Ze�ejd�dd��Zdd�Zd d!�Zejd"d#��Zd$d%�Zd&d'�Zd(d)�Zd*d+�Zejd,d-��Zd.S)/�ImportTestscCst�d�}|j|_|j|_dS)Nztest.encoded_modules)�	importlib�
import_module�test_strings�__path__�	test_path)r�modrrr�setUp?s
zImportTests.setUpcCs2|jD]\}}}t�d|�}|�||j�qdS)Nztest.encoded_modules.module_)r$r"r#r�test)r�modname�encodingZteststrr'rrr�test_import_encoded_moduleDs��z&ImportTests.test_import_encoded_modulec	Cs�|jD]'\}}}t�d||j�d�}|�|j|�Wd�n1s%wYqtj�t	�g}|�
t��t�d|�Wd�dS1sIwYdS)N�module_r�badsyntax_pep3120)r$r�find_moduler&rr+�os�path�dirname�__file__�assertRaises�SyntaxError)rr'r+�_�fdr1rrr�test_find_module_encodingJs��"�z%ImportTests.test_find_module_encodingc	Cs|jD]B\}}}t�d||j�\}}}|�'|�|d�|�|j|�|�|��d�|�|��d|�Wd�n1s@wYqt�d�\}}}|�&|�|d�|�|jd�|�|��d�|�|��d�Wd�dS1sywYdS)Nr-rz# test %s encoding
�tokenize�utf-8z*"""Tokenization help for Python programs.
)	r$rr/r&ZassertNotEqualrr+�tell�readline)rr'r+r6�fp�filename�inforrr�test_issue1267Ss,

����
�"�zImportTests.test_issue1267c
Cs�d}tj�dd�zFt|dddd��
}|�d�Wd�n1s#wYt�|�\}}}|��|�|j	d	�Wtjd=t
�|d�t
�|d
�dStjd=t
�|d�t
�|d
�w)NZtest_imp_helperr�.�.py�wzlatin-1�r+z%# coding: cp1252
u = 'test.test_imp'
�cp1252�.pyc)�sysr1�insert�open�writerr/�closerr+r�unlink)r�
temp_mod_name�filer>r?rrr�test_issue3594fs��zImportTests.test_issue3594cCsVt��}ddddddddddd�
}tjdkr|�|d�d	}n|�|�}|s-|�d
|�|�|�}d|}d|}tj�	|d
�}�zEtj�
dtj�t|dddd��
}|�
d�Wd�n1sdwYt�|�\}}	}
|�A|�|�|�|	dd��|��|�|
dd�|�|
dd�|�|
dtj�t�|||	|
�}|�|jd�Wd�n1s�wYt���t�d�t�||d�}Wd�n1s�wY|�|jd�t���t�d�tjs�t�|t�|d��}Wd�n	1�swY|�|jd�tj�|��st�|�t|ddd��
}|�
d�Wd�n	1�s7wYt���t�d�t�||�}Wd�n	1�sWwY|�|j d�Wtjd=dD]}
t!�"||
�t!�"||
��qjt!�#|�t!�#d�dStjd=dD]}
t!�"||
�t!�"||
��q�t!�#|�t!�#d�w)Ns�������)
r:�cp1250�cp1251rE�cp1253�cp1254�cp1255�cp1256�cp1257�cp1258�darwinr:säz2can't run this test with %s as filesystem encodingZtest_imp_helper_Ztest_imp_helper_package_z__init__.pyrrBrCrDza = 1
�����r�rzb = 2
)rBrF�__pycache__)$rG�getfilesystemencoding�platformr�get�skipTest�decoder0r1�joinrH�curdirrIrJrr/ZassertIsNotNoneZ
assertTrue�endswithZ	PY_SOURCE�load_module�a�warnings�catch_warnings�simplefilter�load_source�dont_write_bytecodeZ
load_compiled�cache_from_source�exists�mkdirZload_package�brrL�rmtree)rZfs_encodingZ
known_localesZspecial_charZdecoded_charrMZtest_package_nameZinit_file_namerNr>r?r'�package�extrrr�test_issue5604ts��


�
�
�


�

���
�

�
�
zImportTests.test_issue5604cCs$tj�t�}|�ttjd|g�dS)Nr.)r0r1r2r3r4r5rr/)rr1rrr�test_issue9319�s
�zImportTests.test_issue9319cCs�tj}tj}t���3t�d�}|�|dj�tj	dg|�R�}|�
t|�|�
||j�|�||j�Wd�dS1s@wYdS)Nr0r)r0r1�getenvr�EnvironmentVarGuardrr/�
addCleanuprKrj�assertIsZassertIsNot)r�	orig_pathZorig_getenv�xZnew_osrrr�test_load_from_source�s	

"�z!ImportTests.test_load_from_sourcecCsNd}t�|�}|d}|dur|�|j�tj|g|�R�}|�|j|�dS)N�_heapqr)rr/r|rKrjrr)rZexamplerZfile_r'rrr�test_issue15828_load_extensions�s
z+ImportTests.test_issue15828_load_extensionscCs�d}t�|�\}}}|��t�||�}t�d|�}t�d|�}|�|j|�|�|jd�|�|jd�|�t��t�d|�Wd�dS1sLwYdS)N�_testimportmultipleZ_testimportmultiple_fooZ_testimportmultiple_barZnonexistent)rr/rKrrrr4�ImportError)r�m�fileobj�pathname�descriptionZmod0Zmod1Zmod2rrr�+test_issue16421_multiple_modules_in_one_dll�s"�z7ImportTests.test_issue16421_multiple_modules_in_one_dllcCsbd}d}|�t��}t�||�Wd�n1swY|�||jj�|�||jj�dS)Nzbogus file path�	extension)	r4r�rrZassertIn�	exceptionr1r�name)rr1r��errrrr�"test_load_dynamic_ImportError_path�s�z.ImportTests.test_load_dynamic_ImportError_pathcCsbd}t�|�}|ddur|d��|ddtjkr!|�d�tj|dg|dd��R�dS)Nr�rr`z/found module doesn't appear to be a C extensionr^)rr/rKZC_EXTENSIONrerj)rr��foundrrr�'test_load_module_extension_file_is_None
s

 z3ImportTests.test_load_module_extension_file_is_NonecCs�d}ztj|=Wn	tyYnwzUt�|�}tj�d�}t�||j	�}|�
|j|�|�
|jj
|�|�
|jj	|j	�|�tt|d�|�
|jd�|�tj||�Wztj|=WdStygYdSwztj|=WwtywYww)Nztest.imp_dummyZ_testmultiphaseZ
dummy_namei�)rG�modules�KeyErrorr"r#�util�	find_specrr�originrr�__spec__r�r4�AttributeError�getattrZ	int_constr})rr��module�specrrr�3test_issue24748_load_module_skips_sys_modules_checks4�
���z?ImportTests.test_issue24748_load_module_skips_sys_modules_checkz*test meaningful only when writing bytecodecCsZt���tjd}t�|�|�tdtjtjdg�Wd�dS1s&wYdS)NrBz
^No modulerA)	r�temp_cwdZTESTFNr0rs�assertRaisesRegexr�rr/)r�sourcerrr�test_bug7732.s


�"�zImportTests.test_bug7732cCs6t�dtjttjdd��}|�tj�|�tj�dS)Nrr:rD)rZ_LoadSourceCompatibilityr3rI�get_data)r�loaderrrr�test_multiple_calls_to_get_data7s

�z+ImportTests.test_multiple_calls_to_get_datac	Cs�dt��}ttjt�|�}t�tj||��/|�td��t�	|t
d�Wd�n1s0wYWd�dSWd�dS1sHwYdS)N�tmpz
embedded null�)r�typerGr�rZ	swap_itemr��
ValueErrorrror3)rr*r'rrr�test_load_source>s
��"�zImportTests.test_load_sourcecCsTt�td�}Gdd�d�}|�t��||��Wd�dS1s#wYdS)N�create_dynamicc@seZdZdZdZdS)z,ImportTests.test_issue31315.<locals>.BadSpecN�foo)rrr r�r�rrrr�BadSpecLsr�)r�
get_attributerr4�	TypeError)rr�r�rrr�test_issue31315Gs
"�zImportTests.test_issue31315cCs4ddl}|�|jjd�ddl}|�|jjd�dS)Nr�frozen)�_frozen_importlib_externalrr�r��_frozen_importlib)rr�r�rrr�test_issue_35321RszImportTests.test_issue_35321cCs,|�t�dd�d�|�t�dd�d�dS)N�*shis��Z
:}��+s��65���9)r�_imp�source_hash)rrrr�test_source_hash]szImportTests.test_source_hashcCshgdfddgdfddgdfddgdfg}|D]\}}|ddg}tj|�}|�|j���d�|�qdS)N�defaultz--check-hash-based-pycs�always�neverz-cz.import _imp; print(_imp.check_hash_based_pycs)r:)rZassert_python_okr�out�striprf)r�casesZinterp_argsr�args�resrrr�'test_pyc_invalidation_mode_from_cmdlineas


��
�z3ImportTests.test_pyc_invalidation_mode_from_cmdlinec	Cs�t���?tdd��
}|�d�Wd�n1swYtjddtjjd�tj	ddgd�\}}}t�
d|||�}Wd�n1sFwY|�|jd	�dS)
Nzmymod.py�wbsx = 42
T)�doraise�invalidation_modeZmymodrA)r1r�)
rr�rIrJ�
py_compile�compile�PycInvalidationMode�CHECKED_HASHrr/rjrr)rr=rNr1r�r'rrr�test_find_and_load_checked_pycps
���
z*ImportTests.test_find_and_load_checked_pyccs^ddl�t�td�}Gdd�d�}|�����fdd�}|�t�d�}��|d�|�dS)Nr�create_builtinc@seZdZdZdS)z7ImportTests.test_create_builtin_subinterp.<locals>.Spec�builtinsN)rrr r�rrrr�Spec�sr�csBt���}t���}��|����t���|d�t��dS)Nr^)rG�getrefcountr�r�r}r�gcZcollect)Zrefcntr'�r�rr�rr�check_get_builtins�s


zEImportTests.test_create_builtin_subinterp.<locals>.check_get_builtinszimport builtins)r�rr�r�Zrun_in_subinterpr)rr�r�r��retrr�r�test_create_builtin_subinterps

z)ImportTests.test_create_builtin_subinterpN) rrr r(r,r8r@rOrxryr�rr�r�r�r�r�r	r
rGrpr�r�r�rrr�r�r�r�r�r�rrrrr!>sB	W




�
	

r!c@s.eZdZ	dd�Zdd�Zdd�Zdd�Zd	S)
�ReloadTestscCs@t���ddl}t�|�Wd�dS1swYdS)Nr)rr{r0r�reload)rr0rrr�test_source�s
"�zReloadTests.test_sourcecC�Bt�d��ddl}t�|�Wd�dS1swYdS)N�timer)r�CleanImportr�rr�)rr�rrr�test_extension��"�zReloadTests.test_extensioncCr�)N�marshalr)rr�r�rr�)rr�rrr�test_builtin�r�zReloadTests.test_builtincsjddlm}tj�d���fdd�}|�|�|�td��t�	|�Wd�dS1s.wYdS)Nr)�parser�htmlcs�tjd<dS)Nr�)rGr�r�r�rr�cleanup�sz5ReloadTests.test_with_deleted_parent.<locals>.cleanup)
r�r�rGr��popr|r�r�rr�)rr�r�rr�r�test_with_deleted_parent�s
"�z$ReloadTests.test_with_deleted_parentN)rrr r�r�r�r�rrrrr��sr�c@sNeZdZ	e��Ze�ej	j
dud�dd��Ze�ej	j
dud�dd��ZdS)�PEP3147TestsNz1requires sys.implementation.cache_tag not be Nonec	CsFtj�dddd�}tj�ddddd�|j��}|�t�|d�|�dS)Nr��bar�baz�qux.pyra�
qux.{}.pycT)r0r1rg�format�tagrrrq�rr1�expectrrr�test_cache_from_source�s

�z#PEP3147Tests.test_cache_from_sourcez4requires sys.implementation.cache_tag to not be Nonec	CsDtj�ddddd�|j��}tj�dddd�}|�t�|�|�dS)Nr�r�r�rar�r�)r0r1rgr�r�rr�source_from_cacher�rrr�test_source_from_cache�s

�z#PEP3147Tests.test_source_from_cache)
rrr rZget_tagr�r	Z
skipUnlessrG�implementation�	cache_tagr�r�rrrrr��s�
�r�c@s&eZdZe�ejdud�dd��ZdS)�NullImporterTestsNzNeed an undecodeable filenamec	Cs>tj}t�|�z|�ttj|�Wt�|�dSt�|�w)N)	r�TESTFN_UNENCODABLEr0rsr4r�rZNullImporter�rmdir)rr�rrr�test_unencodeable�s

z#NullImporterTests.test_unencodeable)rrr r	r
rr�r�rrrrr��s
�r��__main__)r�r"�importlib.utilr0Zos.pathr�rGr)rZtest.supportrrrr	rlrmrn�DeprecationWarningrr�rZTestCaserr!r�r�r�r�mainrrrr�<module>s:

�"`&�