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: //proc/thread-self/root/usr/local/lib/python3.7/test/__pycache__/test_zipimport.cpython-37.pyc
B

��g^y�@s�ddlZddlZddlZddlZddlZddlZddlZddlZddlm	Z	ddl
mZmZm
Z
mZddlZddlZddlZddlZddlZddlmZmZmZyddlZWnek
r�dZYnXdZeedd�ZdZd	d
�Zdd�Ze��Z eee e!e��Z"d
Z#dZ$dZ%ej&�'d�Z(ej&�'d�Z)ej*�+e#d�Z,dZ-Gdd�dej.�Z/Gdd�de/�Z0e	j1Gdd�de0��Z2Gdd�dej.�Z3dd�Z4e5dk�r�e4�dS)�N)�support)�ZipFile�ZipInfo�
ZIP_STORED�ZIP_DEFLATED)�
extract_tb�
extract_stack�print_tbzHdef get_name():
    return __name__
def get_file():
    return __file__
z<???>�execz def do_raise(): raise TypeError
cCsdt�|�}t|�td�kr<|dkr,t|�}ntdt|��}tjjt�ddt|�|d@�|}|S)Ngi���l����z<iiirl��)	�marshal�dumps�type�int�	importlib�util�MAGIC_NUMBER�struct�pack)�co�mtime�size�data�pyc�r�//usr/local/lib/python3.7/test/test_zipimport.py�make_pyc"s

$rcCs|�tjd�S)N�.)�replace�os�sep)�pathrrr�module_path_to_dotted_name.sr!Z
ziptestmoduleZziptestpackageZziptestpackage2Z	junk95142z
junk95142.zipz.pyz.pycc@seZdZdd�Zdd�ZdS)�ImportHooksBaseTestCasecCsHtjdd�|_tjdd�|_tjdd�|_tj��t��|_dS)N)	�sysr �	meta_path�
path_hooks�path_importer_cache�clearrZ
modules_setup�modules_before)�selfrrr�setUpAs

zImportHooksBaseTestCase.setUpcCsJ|jtjdd�<|jtjdd�<|jtjdd�<tj��tj|j�dS)N)	r r#r$r%r&r'rZmodules_cleanupr()r)rrr�tearDownHs

z ImportHooksBaseTestCase.tearDownN)�__name__�
__module__�__qualname__r*r+rrrrr"?sr"c@s`eZdZeZdd�Zefdd�Zefdd�Z	dd�Z
d	d
�Zdd�Zd
d�Z
dd�Zdd�Zdd�Zdd�Zdd�Zdd�Zdd�Zdd�Zdd �Zd!d"�Zd#d$�Zd%d&�Zd'd(�Zd)d*�Zd+d,�Zd-d.�Zd/d0�Zd1d2�Zd3d4�Z d5d6�Z!d7d8�Z"d9d:�Z#d;d<�Z$d=d>�Z%d?d@�Z&dAdB�Z'dCdD�Z(dEdF�Z)e*�+e,j-dGkdH�dIdJ��Z.dKdL�Z/e,j0dMdN��Z1dGS)O�UncompressedZipImportTestCasecCs t��tj��t�|�dS)N)�	linecache�
clearcache�	zipimport�_zip_directory_cacher'r"r*)r)rrrr*Ts
z#UncompressedZipImportTestCase.setUpc	
Cs�|�tj|�x�|��D]�\}\}}tj�||�}|dtjkrXtj�|�s�t�	|�qtj�
|�}tj�|�szt�	|�t|d��}|�|�WdQRXqWdS)N����wb)
�
addCleanuprZrmtree�itemsrr �joinr�isdir�makedirs�dirname�open�write)	r)�filesZdirName�namerrr Zdname�fprrr�makeTree[s
z&UncompressedZipImportTestCase.makeTreec	Ks�|�tj|�t|d��D}x<|��D]0\}\}}t|t�|��}|j|_	|�
||�q$WWdQRX|�dd�}	|	dk	r�t|d��}
|
�
�}WdQRXt|d��}
|
�|	�|
�|�WdQRXdS)N�w�stuff�rbr5)r6r�unlinkrr7r�time�	localtime�compression�
compress_type�writestr�getr<�readr=)r)r>ZzipName�kw�zr?rr�zinforC�frrr�makeZipls
z%UncompressedZipImportTestCase.makeZipcOst|j|f|�tj�dt�t�d�|��}|�d�}|dk	rF||�|rp|�	�}|�
|tjjtf|��|�dS)Nrr�call)rQr#r �insert�TEMP_ZIPr�
import_moduler8rKZget_file�assertEqualr)r)Zexpected_extr>�modulesrM�modrR�filerrr�doTest�s
z$UncompressedZipImportTestCase.doTestcCs�dtjkr|�d�dtjkr&tjd=dttfi}y|�d|d�Wn(tk
rl|jt	krh|�
d�YnX|jtkr�|�
d�dS)N�zlibzzlib is a builtin modulezzlib.pyz.pyz&expected test to not raise ImportErrorz"expected test to raise ImportError)r#�builtin_module_namesZskipTestrW�NOW�test_srcrZ�ImportErrorrHr�failr)r)r>rrr�
testAFakeZlib�s




z+UncompressedZipImportTestCase.testAFakeZlibcCs"tdttfi}|�d|t�dS)Nz.py)�TESTMODr]r^rZ)r)r>rrr�testPy�sz$UncompressedZipImportTestCase.testPycCs"ttttfi}|�t|t�dS)N)rb�pyc_extr]�test_pycrZ)r)r>rrr�testPyc�sz%UncompressedZipImportTestCase.testPyccCs.tdttfttttfi}|�t|t�dS)Nz.py)rbr]r^rdrerZ)r)r>rrr�testBoth�sz&UncompressedZipImportTestCase.testBothcsjd}tj�|�}tj�t|dd�|d�}tdtdftdtd|fi}�fd	d
�}�jd|t|d�dS)Ns
state = 'old'z???r
Fz.pyz
state = 'new'z.pyc�cs��|jd�dS)N�old)rV�state)rX)r)rr�check�szFUncompressedZipImportTestCase.testUncheckedHashBasedPyc.<locals>.check)rR)	rr�source_hash�_bootstrap_external�_code_to_hash_pyc�compilerbr]rZ)r)�sourcerl�bytecoder>rkr)r)r�testUncheckedHashBasedPyc�s
z7UncompressedZipImportTestCase.testUncheckedHashBasedPyccCs"tdtdfi}|�d|t�dS)Nz.py�)rbr]rZ)r)r>rrr�testEmptyPy�sz)UncompressedZipImportTestCase.testEmptyPycCsFtt�}|ddN<tdttfttt|fi}|�d|t�dS)Nr�z.py)�	bytearrayrerbr]r^rdrZ)r)�badmagic_pycr>rrr�testBadMagic�s
z*UncompressedZipImportTestCase.testBadMagiccCs^tt�}|ddN<ttt|fi}y|�d|t�Wntk
rNYnX|�d�dS)Nrruz.pyz)expected ImportError; import from bad pyc)rvrerbrdr]rZr_r`)r)rwr>rrr�
testBadMagic2�sz+UncompressedZipImportTestCase.testBadMagic2cCsFtt�}|ddN<tdttfttt|fi}|�d|t�dS)N��z.py)rvrerbr]r^rdrZ)r)Zbadtime_pycr>rrr�testBadMTime�s
z*UncompressedZipImportTestCase.testBadMTimecCsBttj}|dtttf|ttttfi}|�t|tt�dS)N�__init__)�TESTPACKrrrdr]rerbrZ)r)�packdirr>rrr�testPackage�s
z)UncompressedZipImportTestCase.testPackagecCsbttj}|ttj}|dtttf|dtttf|ttttfi}|�t|ttt�dS)Nr})	r~rr�	TESTPACK2rdr]rerbrZ)r)r�packdir2r>rrr�testSubPackage�s
z,UncompressedZipImportTestCase.testSubPackagecCsRttj}|ttj}|tdf|tdf|ttttfi}|�t|ttt�dS)Nrs)	r~rrr�r]rbrdrerZ)r)rr�r>rrr�testSubNamespacePackage�s
z5UncompressedZipImportTestCase.testSubNamespacePackagec
CsRttj}|ttj}|tdtj}|tdf|ttttf|tdf|tdf|ttttf|tdtttf|ttttfi}|tdf|tdtttf|tdf|tdtttf|ttttfi}tj�	d�}|�
||�t}|�||�t
j�d|�t
j�d|�t�t�}|�dt|j��|j\}	}
|�tj�t�|	�tj�d�|�d|
�tj�d�t�|�tjd�dd	��}|�d
t|j��t|j�d�dtj�d
}|�|dd	�|�t�d�ttf��}|�d|j�tj�d�t�d�ttdf��}|�tj�t�|j�tj�d�d�ttf�}t�|�}|�dt|j��|j\}	}
|�tj�t�|	�tj�d�|�d|
�tj�d�t�d�|tf��}|�tj�t�|j�tj�d�t�d�|tdf��}|�tj�t�|j�tj�d�t�d�|tdf��}|�d|j�tj�d�dS)
N�3rs�2z	path1.ziprr{���rr4�������)r~rrr�r]rbrdrer �abspathrQ�TEMP_DIRrAr#rSrrUrV�len�__path__�basename�splitr�listr8�__file__)
r)rr��packdir3�files1�files2�zip1�zip2rX�p1�p2�mpath�subpkgrrr�testMixedNamespacePackagesb


 

 z7UncompressedZipImportTestCase.testMixedNamespacePackagec
Cs2ttj}|ttj}|tdtj}|tdf|ttttf|tdf|tdf|ttttf|tdtttf|ttttfi}tj�	d�}|�
||�|tdf|tdtttf|tdf|tdtttf|ttttfi}tj�	d�}|�
||�tj�d|�tj�d|�t
�t�}|�dt|j��|j\}	}
|�d|	�tj�d�|�d|
�tj�d�t
�|�tjd	�dd
��}|�dt|j��t|j�d�dtj�d}|�|dd
�|�t
�d	�ttf��}|�d|j�tj�d�t
�d	�ttdf��}|�d|j�tj�d�d	�ttf�}t
�|�}|�dt|j��|j\}	}
|�d|	�tj�d�|�d|
�tj�d�t
�d	�|tf��}|�d|j�tj�d
�t
�d	�|tdf��}|�d|j�tj�d
�t
�d	�|tdf��}|�d|j�tj�d
�dS)Nr�rsz	path1.zipr�z	path2.ziprr{r�rr4r�r�r�)r~rrr�r]rbrdrer r�rQr#rSrrUrVr�r�r�rr�r8r�)
r)rr�r�r�r�r�r�rXr�r�r�r�rrr�testNamespacePackageUs\




z2UncompressedZipImportTestCase.testNamespacePackagec	Cs�ttj}|ttj}|dtttf|dtttf|ttttfdtttfi}tt	d�}�zxB|�
�D]6\}\}}t|t�
|��}|j|_d|_|�||�qpW|��t�t	�}	|�|	jt	�|�|	�t�d�|	�d�}
|�|
�|�|
tj�|�|
�d��|
�d�}|�|
�d�|j�|	�t�}|�|	�t�|j�t� t�j!d}
tj"�#t	t�}|�|
|�|�|	�|d�d�|�|	�|t�d�|�|	�|t�d�|t}t$|�}t� |�}|�%|t&j'k�|�|	�(t�d�|�|	�(|�d�|�|	�|�|j�|j)}|�|�(|�d�|�|�|�|j�t�t	tjt�}|�|jt	�|�|j*ttj�Wd|��t�+t	�XdS)Nr}ZspamrBsspamTrF),r~rrr�rdr]rerbrrTr7rrFrGrHrI�commentrJ�closer2�zipimporterrV�archive�
is_package�find_module�assertIsNotNone�assertIsInstance�assertFalse�load_module�get_filenamer�rrUr�r r8r!�
assertTruer#rW�
get_source�
__loader__�prefix�remove)r)rr�r>rNr?rrrO�ziZfind_mod�load_modrXZexisting_pack_pathZexpected_path_path�mod_path�mod_name�loader�zi2rrr�testZipImporterMethods�s\







z4UncompressedZipImportTestCase.testZipImporterMethodsc	CsJttj}|ttj}|dtttf|ttttfi}tt	d�}�z�xB|�
�D]6\}\}}t|t�
|��}|j|_d|_|�||�qTW|��t�t	tj|�}	|�|	jt	�|�|	j|�|�|	�t�d�|	�t�}
|�|	�t�|
j�|�|	�ttjd�d�|�|	�ttjt�d�t	tj|t}t�|�}|�t�}
|�|
�|�|
tj�|�|�t��|
�t�}|�|
�t�|j�ttjt}t |�}t!�"|�}
|�#|t$j%k�|�|	�&t�d�|�|	�&|�d�|�|	�|�|
j�|
j'}|�|�&|�d�|�|�|�|
j�Wd|��t�(t	�XdS)Nr}rBseggsTF))r~rrr�rdr]rerbrrTr7rrFrGrHrIr�rJr�r2r�rVr�r�r�r�r�r�r�r�r�r�r!rrUr�r#rWr�r�r�)r)rr�r>rNr?rrrOr�rXZpkg_pathr�Zfind_mod_dottedr�r�r�r�rrr�$testZipImporterMethodsInSubDirectory�sV







zBUncompressedZipImportTestCase.testZipImporterMethodsInSubDirectoryc	Cs�ttd�}|j|_z^d}tdd�td�D��}|�||�|��t�t�}|�	||�
|��|�dt|��Wd|��t
�t�XdS)NrBztestdata.datcss|]
}|VqdS)Nr)�.0�xrrr�	<genexpr>sz<UncompressedZipImportTestCase.testGetData.<locals>.<genexpr>�zzipimporter object)rrTrH�bytes�rangerJr�r2r�rV�get_dataZassertIn�reprrr�)r)rNr?rr�rrr�testGetDatas

z)UncompressedZipImportTestCase.testGetDatac	CstGdd�dt�}ttd�}z@d}d}|�||�|��t�t�}|�||�||���Wd|��t	�
t�XdS)Nc@seZdZdd�ZdS)z?UncompressedZipImportTestCase.test_issue31291.<locals>.FunnyStrcSsdS)N�*r)r)ri�newrrrr!szGUncompressedZipImportTestCase.test_issue31291.<locals>.FunnyStr.replaceN)r,r-r.rrrrr�FunnyStr sr�rBz
test31291.datsfoo)�strrrTrJr�r2r�rVr�rr�)r)r�rNr?rr�rrr�test_issue31291s

z-UncompressedZipImportTestCase.test_issue31291cCsFd}tt|dd�tt|��}ttt|fdtdfi}|�t|t�dS)Nz�if 1:  # indent hack
        def get_file():
            return __file__
        if __loader__.get_data("some.data") != b"some data":
            raise AssertionError("bad data")
z<???>r
z	some.dataz	some data)rror]r�rbrdrZ)r)�srcrr>rrr�testImporterAttr/s
z.UncompressedZipImportTestCase.testImporterAttrcCs\d}tdt|fi}|�|�tj�dt�t�t�}|�	|�
d�d�|�t|j
d�dS)Nz[if 1:  # indent hack
        def test(val):
            assert(val)
            return val
z.pyrr�F)
rbr]rQr#r rSrTrrUrV�test�assertRaises�AssertionError)r)r�r>rXrrr�testDefaultOptimizationLevel:s

z:UncompressedZipImportTestCase.testDefaultOptimizationLevelcCs&tdttfi}|jd|tdd�dS)Nz.pys6Some StuffSome StuffSome StuffSome StuffSome StuffSome StuffSome StuffSome StuffSome StuffSome StuffSome StuffSome StuffSome StuffSome StuffSome StuffSome StuffSome StuffSome StuffSome StuffSome StuffSome StuffSome StuffSome StuffSome StuffSome StuffSome StuffSome StuffSome StuffSome StuffSome StuffSome Stuff)rC)rbr]r^rZ)r)r>rrr�testImport_WithStuffGs
z2UncompressedZipImportTestCase.testImport_WithStuffcCs|�t�|�t�dS)N)rV�inspectZ	getsourcer^)r)�modulerrr�assertModuleSourceNsz0UncompressedZipImportTestCase.assertModuleSourcecCs(tdttfi}|jd|t|jd�dS)Nz.py)rR)rbr]r^rZr�)r)r>rrr�
testGetSourceQsz+UncompressedZipImportTestCase.testGetSourcecCsLtttdd�ttt��}tdttfttt|fi}|jt|t|jd�dS)Nz<???>r
z.py)rR)	rror^r]r�rbrdrZr�)r)rr>rrr�testGetCompiledSourceUsz3UncompressedZipImportTestCase.testGetCompiledSourcecCs.tdttfdtdfi}|jd|t|d�dS)Nz.pyzxyz.txtz>>> log.append(True)
)rR)rbr]r^rZ)r)�callbackr>rrr�
runDoctest[sz(UncompressedZipImportTestCase.runDoctestcCsFg}tjd}t_ztjd|dt�d�Wd|t_X|�|dg�dS)Nzxyz.txtT)�package�module_relative�globs)�doctestZmasterZtestfile�localsrV)r)r��logZ
old_masterrrr�
doDoctestFile`sz+UncompressedZipImportTestCase.doDoctestFilecCs|�|j�dS)N)r�r�)r)rrr�testDoctestFilelsz-UncompressedZipImportTestCase.testDoctestFilecCs.g}tjd|dt�d���|�|dg�dS)Nzxyz.txtT)r�r�r�)r�ZDocFileTestr��runrV)r)r�r�rrr�doDoctestSuiteos
z,UncompressedZipImportTestCase.doDoctestSuitecCs|�|j�dS)N)r�r�)r)rrr�testDoctestSuitewsz.UncompressedZipImportTestCase.testDoctestSuitecCs�y|��Wn�t��dj}t|d�d\}}}}|�|t���t|j	d�d\}}}}|�|t���t
��}t|d|�|�
|���t��Yn
Xtd��dS)Nr{r�rzThis ought to be impossible)Zdo_raiser#�exc_info�tb_nextrrV�	raise_src�stripr�tb_frame�io�StringIOr	r��getvalue�endswithr�)r)r��tbrPZlno�n�line�srrr�doTracebackzsz)UncompressedZipImportTestCase.doTracebackcCs(tdttfi}|jd|t|jd�dS)Nz.py)rR)rbr]r�rZr�)r)r>rrr�
testTraceback�sz+UncompressedZipImportTestCase.testTracebackNzneed an unencodable filenamec	Csjtjd}t|d�}ttdt�t��}|j|_	|�
|t�|��zt
�|��t�Wdt�|�XdS)Nz.ziprBz.py)r�TESTFN_UNENCODABLErrrbrFrGr]rHrIrJr^r�r2r�r�rr�)r)�filenamerNrOrrr�testUnencodable�s

z-UncompressedZipImportTestCase.testUnencodablec	Cs�tjd}|�tj|�t|d��.}ttdt�t	��}|j
|_|�|t
�WdQRXt�|�t�t�|��|�t��t�tt�|���WdQRX|�t��t�tt�|���WdQRXdS)Nz.ziprBz.py)rZTESTFNr6rErrrbrFrGr]rHrIrJr^r2r�r�fsencodeZassertWarns�DeprecationWarningrv�
memoryview)r)r�rNrOrrr�
testBytesPath�s

z+UncompressedZipImportTestCase.testBytesPathcCs�tj�tj�}|�t|jd�|�t|jd�|�t|jd�|�t|jd�|�t|j	d�|�t|j
d�|�t|jd�|�t|jd�dS)NZfoo)
r2r��__new__r��
ValueErrorr��find_loaderr�r�r�r��get_coder�)r)r�rrr�testUninitializedZipimporter�sz:UncompressedZipImportTestCase.testUninitializedZipimporter)2r,r-r.rrHr*r�rArTrQrZrarcrfrgrrrtrxryr|r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r��unittestZskipIfrr�r�r��cpython_onlyr�rrrrr/PsP 	
MI<5

r/c@seZdZeZejdd��ZdS)�CompressedZipImportTestCasec	Csrdd�}ttd��"}|�tjt�|�ddt�WdQRXt�t�}t�	t
d|��|�t|j
d�WdQRXdS)NcWsdS)Nr)�argsrrr�bad_decompress�szCCompressedZipImportTestCase.test_issue31602.<locals>.bad_decompressrBzbar.pysprint("hello world")Z
decompressZbar)rrTr6rrErJrr2r�Z	swap_attrr[r��	TypeErrorr�)r)r�Zzip_filer�rrr�test_issue31602�s
z+CompressedZipImportTestCase.test_issue31602N)r,r-r.rrHrr�r�rrrrr��sr�c@sTeZdZdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	dd�Z
dd�ZdS)�BadFileZipImportTestCasecCs|�tjtj|�dS)N)r�r2�ZipImportErrorr�)r)r�rrr�assertZipFailure�sz)BadFileZipImportTestCase.assertZipFailurecCs|�d�dS)NZAdfjdkFJKDFJjdklfjs)r)r)rrr�
testNoFile�sz#BadFileZipImportTestCase.testNoFilecCs|�d�dS)Nrs)r)r)rrr�testEmptyFilename�sz*BadFileZipImportTestCase.testEmptyFilenamecCsB|�ttjd�|jttjtdd�|�ttjtt�t���dS)N)Zkwd)r�r�r2r�rbr�rr�)r)rrr�testBadArgs�s
z$BadFileZipImportTestCase.testBadArgscCs|�dd�dS)N�Ai�)r)r)rrr�testFilenameTooLong�sz,BadFileZipImportTestCase.testFilenameTooLongcCs"t�t�t�t�|�t�dS)N)rrErbZcreate_empty_filer)r)rrr�
testEmptyFile�s

z&BadFileZipImportTestCase.testEmptyFilec
Csht�t�t�ttjd�}z0t�|�|�tj	��}t�
t�WdQRXWdt�td�t�t�XdS)Nri�)rrErbrr<�O_CREATr�r�r2rr��chmod)r)�fd�cmrrr�testFileUnreadable�s

z+BadFileZipImportTestCase.testFileUnreadablecCs4t�t�ttd�}|�d�|��|�t�dS)Nzw+Zaaaaaaaaaaaaaaaaaaaaaa)rrErbr<r=r�r)r)r@rrr�testNotZipFile�s



z'BadFileZipImportTestCase.testNotZipFilecCs t�t�ttd�}|�t�dd��|�d�|��t�	t�}z�|�
t|jd�|�
t|j
d�|�
t|jd�|�
t|jd�|�
t|jd�|�
t|jd�tj}|�|�d�d�|�
||j
d�|�
||jd�|�
t|jd�|�
||jd�|�
||jd�Wdtj��XdS)Nzw+z=IiPKZaaaaaaaaaaaaaaaaaa�abc)rrErbr<r=rrr�r2r�r�r�r�r�r�r�r�r�rrV�OSErrorr3r')r)r@rN�errorrrr�_testBogusZipFile�s*



z*BadFileZipImportTestCase._testBogusZipFileN)r,r-r.rrrrrrrr
rrrrrr��sr�c	Cs$zt�ttt�Wdt�t�XdS)N)rZrun_unittestr/r�r�rErbrrrr�	test_mains
r�__main__)6r#rrr�importlib.utilrrFr�r�rZzipfilerrrrr2r0r�r�r��	tracebackrrr	r[r_r^roZtest_cor�rr!r]r�rerbr~r�r r�r�rTr�cache_from_sourceZpyc_filerdZTestCaser"r/Z
requires_zlibr�r�rr,rrrr�<module>sZ
pK