403Webshell
Server IP : 118.27.122.248  /  Your IP : 216.73.217.130
Web Server : Apache
System : Linux web0264.sh.tyo1 4.18.0-553.79.1.lve.el7h.x86_64 #1 SMP Wed Oct 15 16:34:46 UTC 2025 x86_64
User : c9415830 ( 11735)
PHP Version : 8.4.17
Disable Function : NONE
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : ON  |  Sudo : OFF  |  Pkexec : OFF
Directory :  /opt/alt/python36/lib64/python3.6/test/__pycache__/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /opt/alt/python36/lib64/python3.6/test/__pycache__/test_capi.cpython-36.pyc
3

�w2_I^�@s�ddlZddlZddlZddlZddlZddlZddlZddlZddlZddl	Z	ddl
mZddlm
Z
ddlmZmZyddlZWnek
r�dZYnXyddlZWnek
r�dZYnXejd�Zeed�Zdd�ZGd	d
�d
�ZGdd�de	j�Ze	jed
�Gdd�de	j��ZGdd�de	j�ZGdd�de	j�Ze	jed
�Gdd�de	j��Z Gdd�de	j�Z!Gdd�de	j�Z"Gdd�de"�Z#e	jej$d�dkd�Gdd �d e"��Z%e	jed!�Gd"d#�d#e"��Z&e'd$k�r�e	j(�dS)%�N)�support)�MISSING_C_DOCSTRINGS)�assert_python_failure�assert_python_ok�	_testcapi�gettotalrefcountcCs|S)zsome doc�)�selfrr�3/opt/alt/python36/lib64/python3.6/test/test_capi.py�testfunction src@s eZdZeje�Zeje�ZdS)�InstanceMethodN)�__name__�
__module__�__qualname__rZinstancemethod�idrrrrr
r$s
rc@s�eZdZdd�Zejed�dd��Zdd�Zdd	�Z	eje
d
�dd��Zeje
d
�d
d��Zej
ed�dd��Zdd�Zdd�Zdd�Zdd�Zdd�ZdS)�CAPITestcCs~t�}|jt|�|j��|j|j�|k�|j|jjtj�|jtjjtj�dtj_|jtjd�|jtt	|jdd�dS)N�test�	attribute)
r�assertEqualr�
assertTruer�__doc__r�assertRaises�AttributeError�setattr)r	Zinstrrr
�test_instancemethod*szCAPITest.test_instancemethodz!Threading required for this test.cCs`tj��"tjtjddgtjtjd�}WdQRX|j�\}}|j|d�|j	|j
�jd��dS)Nz-cz4import _testcapi;_testcapi.crash_no_current_thread())�stdout�stderr�s8Fatal Python error: PyThreadState_Get: no current thread)r�SuppressCrashReport�
subprocess�Popen�sys�
executable�PIPE�communicaterr�rstrip�
startswith)r	�p�out�errrrr
� test_no_FatalError_infinite_loop5s

z)CAPITest.test_no_FatalError_infinite_loopcCs|jttj�dS)N)r�
ValueErrorrZ!make_memoryview_from_NULL_pointer)r	rrr
�!test_memoryview_from_NULL_pointerDsz*CAPITest.test_memoryview_from_NULL_pointerc
Cs�td�}td�}y|�Wn�tk
r�}z�|j}tj�}tj|j|d�}tj�}tj|�}tj�}	|j|d|�|j	||j||f�|j	||�|j	|	|�|j	||j|df�|j	||�WYdd}~XnX|j
d�dS)N�5ZTEST�F)r+�	TypeError�
__traceback__r!�exc_inforZset_exc_info�	__class__rZassertSequenceEqualr)
r	Zraised_exception�new_exc�e�tbZorig_sys_exc_infoZ
orig_exc_infoZnew_sys_exc_infoZnew_exc_infoZreset_sys_exc_inforrr
�
test_exc_infoGs$
zCAPITest.test_exc_infoz(_posixsubprocess required for this test.cCs�Gdd�dt�}|jttjd|�dddddd	d
ddd
ddddd�Gdd�dt�}|jttjd|�dddddd	d
ddd
ddddd�dS)Nc@seZdZdd�ZdS)z1CAPITest.test_seq_bytes_to_charp_array.<locals>.ZcSsdS)Nr.r)r	rrr
�__len__bsz9CAPITest.test_seq_bytes_to_charp_array.<locals>.Z.__len__N)r
rrr7rrrr
�Zasr8r.�������	�
���
����c@seZdZdd�Zdd�ZdS)z1CAPITest.test_seq_bytes_to_charp_array.<locals>.ZcSstjS)N)r!�maxsize)r	rrr
r7hsz9CAPITest.test_seq_bytes_to_charp_array.<locals>.Z.__len__cSsdS)N�xr)r	�irrr
�__getitem__jsz=CAPITest.test_seq_bytes_to_charp_array.<locals>.Z.__getitem__N)r
rrr7rKrrrr
r8gs)r.r:)r.r:)�objectrr/�_posixsubprocess�	fork_exec�MemoryError)r	r8rrr
�test_seq_bytes_to_charp_array^s
(
z&CAPITest.test_seq_bytes_to_charp_arraycCsHGdd�dt�}|jttj|�dgddddd	d
ddd
dddddd�dS)Nc@seZdZdd�ZdS)z-CAPITest.test_subprocess_fork_exec.<locals>.ZcSsdS)Nr.r)r	rrr
r7rsz5CAPITest.test_subprocess_fork_exec.<locals>.Z.__len__N)r
rrr7rrrr
r8qsr8�1r9r.r:r;r<r=r>r?r@rArBrCrDrErFrG)r.r:)rLrr/rMrN)r	r8rrr
�test_subprocess_fork_execos
z"CAPITest.test_subprocess_fork_execz6Signature information for builtins requires docstringscCs|jtjjd�|jtjjd�|jtjjd�|jtjjd�|jtjjd�|jtjjd�|jtjjd�|jtjjd�|jtjjd�|jtjjd�|jtj	jd�|jtj	jd�|jtj
jd�|jtj
jd�|jtjjd�|jtjjd�dS)Nz This docstring has no signature.z[docstring_with_invalid_signature($module, /, boo)

This docstring has an invalid signature.zedocstring_with_invalid_signature2($module, /, boo)

--

This docstring also has an invalid signature.z%This docstring has a valid signature.z($module, /, sig)z>
This docstring has a valid signature and some extra newlines.z($module, /, parameter))rrZno_docstringr�__text_signature__Zdocstring_emptyZdocstring_no_signatureZ docstring_with_invalid_signatureZ!docstring_with_invalid_signature2Zdocstring_with_signatureZ#docstring_with_signature_but_no_docZ+docstring_with_signature_and_extra_newlines)r	rrr
� test_docstring_signature_parsingys.






z)CAPITest.test_docstring_signature_parsingcCs�tj}|�}|�}|j||d||f�|j|dd|df�|jd|dd|f�|}||}|j|d||f�|}|d}|j|d|df�d}||}|j|dd|f�dS)N�matmul�*�imatmul)rZ
matmulTyper)r	�M�m1�m2�orrr
�&test_c_type_with_matrix_multiplication�sz/CAPITest.test_c_type_with_matrix_multiplicationc
Cshtr4tjd�}td|�\}}}|j|jdd�d�n0|jt��}tj	�WdQRX|jt
|j�d�dS)Nz�
                import _testcapi
                from test import support

                with support.SuppressCrashReport():
                    _testcapi.return_null_without_error()
            z-c�
rs�Fatal Python error: a function returned NULL without setting an error\nSystemError: <built-in function return_null_without_error> returned NULL without setting an error\n\nCurrent thread.*:\n  File .*", line 6 in <module>zBreturn_null_without_error.* returned NULL without setting an error)�Py_DEBUG�textwrap�dedentr�assertRegex�replacer�SystemErrorrZreturn_null_without_error�str�	exception)r	�code�rcr(r)�cmrrr
�test_return_null_without_error�s	z'CAPITest.test_return_null_without_errorc
Cshtr4tjd�}td|�\}}}|j|jdd�d�n0|jt��}tj	�WdQRX|jt
|j�d�dS)Nz�
                import _testcapi
                from test import support

                with support.SuppressCrashReport():
                    _testcapi.return_result_with_error()
            z-cr]rs+Fatal Python error: a function returned a result with an error set\nValueError\n\nThe above exception was the direct cause of the following exception:\n\nSystemError: <built-in function return_result_with_error> returned a result with an error set\n\nCurrent thread.*:\n  File .*, line 6 in <module>z>return_result_with_error.* returned a result with an error set)r^r_r`rrarbrrcrZreturn_result_with_errorrdre)r	rfrgr(r)rhrrr
�test_return_result_with_error�sz&CAPITest.test_return_result_with_errorcCstj�dS)N)r�test_buildvalue_N)r	rrr
rk�szCAPITest.test_buildvalue_NcCs<d}td|�\}}}|jd|�|jd|�|jd|�dS)Na*if 1:
            import _testcapi

            class C(): pass

            # The first loop tests both functions and that remove_mem_hooks()
            # can be called twice in a row. The second loop checks a call to
            # set_nomemory() after a call to remove_mem_hooks(). The third
            # loop checks the start and stop arguments of set_nomemory().
            for outer_cnt in range(1, 4):
                start = 10 * outer_cnt
                for j in range(100):
                    if j == 0:
                        if outer_cnt != 3:
                            _testcapi.set_nomemory(start)
                        else:
                            _testcapi.set_nomemory(start, start + 1)
                    try:
                        C()
                    except MemoryError as e:
                        if outer_cnt != 3:
                            _testcapi.remove_mem_hooks()
                        print('MemoryError', outer_cnt, j)
                        _testcapi.remove_mem_hooks()
                        break
        z-csMemoryError 1 10sMemoryError 2 20sMemoryError 3 30)r�assertIn)r	rfrgr(r)rrr
�test_set_nomemory�s
zCAPITest.test_set_nomemoryN)r
rrr�unittest�
skipUnless�	threadingr*r,r6rMrPrRZskipIfrrTr\rirjrkrmrrrr
r(s
* rz!Threading required for this test.c@s6eZdZdd�Zddd�Zdd�Zdd	�Zd
d�ZdS)
�TestPendingCallscsF�fdd�}x4t|�D](}tjtj�d�xtj|�r.Pq.WqWdS)Ncs�jd�dS)N)�appendr)�lrr
�callbacksz6TestPendingCalls.pendingcalls_submit.<locals>.callbackg{�G�z�?)�range�time�sleep�randomrZ_pending_threadfunc)r	rs�nrtrJr)rsr
�pendingcalls_submits
z$TestPendingCalls.pendingcalls_submitNcCs�d}x|t|�|kr�dr.tjr.tdt|�f�xtd�D]}||}q8W|rZ|jj�rZq|d7}|j|dkd|t|�f�qWdr�tjr�tdt|�f�dS)NrFz(%i)i�r.i'z(timeout waiting for %i callbacks, got %i)�lenr�verbose�printru�eventZis_setr)r	rsry�context�countrJ�arrr
�pendingcalls_wait's


z"TestPendingCalls.pendingcalls_waitcs�d}g}Gdd�dt�}|��g�_d�_|�j�_d�_tj��_tj��_	��fdd�t
�j�D�}tj|���j
�j|��WdQRXdS)N� c@seZdZdS)z8TestPendingCalls.test_pendingcalls_threaded.<locals>.fooN)r
rrrrrr
�foo?sr�r:rcsg|]}tj�j�fd��qS))�target�args)rp�Thread�pendingcalls_thread)�.0rJ)rr	rr
�
<listcomp>Hsz?TestPendingCalls.test_pendingcalls_threaded.<locals>.<listcomp>)rLrsry�nThreads�	nFinishedrpZLock�lockZEventr~rurZ
start_threadsr�)r	ryZthreadsr�r)rr	r
�test_pendingcalls_threaded:s

z+TestPendingCalls.test_pendingcalls_threadedcCsjz|j|j|j�Wd|j�.|jd7_|j}drFtjrFtd|�WdQRX||jkrd|j	j
�XdS)Nr.Fzfinished threads: )rzrsryr�r�rr|r}r�r~�set)r	rr�rrr
r�Ns

z$TestPendingCalls.pendingcalls_threadcCs$g}d}|j||�|j||�dS)N�@)rzr�)r	rsryrrr
�test_pendingcalls_non_threadedZsz/TestPendingCalls.test_pendingcalls_non_threaded)N)r
rrrzr�r�r�r�rrrr
rqs

rqc@seZdZdd�ZdS)�SubinterpreterTestcCs|ddl}tj�\}}dj|�}t|d��J}tj|�}|j|d�|jt	j
|�ttj
��|jt	j
|�t|��WdQRXdS)Nrz�if 1:
            import sys, builtins, pickle
            with open({:d}, "wb") as f:
                pickle.dump(id(sys.modules), f)
                pickle.dump(id(builtins), f)
            �rb)�builtins�os�pipe�format�openrZrun_in_subinterprZassertNotEqual�pickle�loadrr!�modules)r	r��r�wrf�fZretrrr
�test_subinterpsgs

z"SubinterpreterTest.test_subinterpsN)r
rrr�rrrr
r�esr�c@sBeZdZdd�Zdd�Zdd�dd�Zd	d
�Zdd�Zd
d�ZdS)�EmbeddingTestscCs�tjjt�}tjjtjjtjj|���}d}tjjd�rfdtjkrFdndd}||7}tjjtj�}ntjj	|d�}tjj	||�|_
}tjj|�s�|jd|�tj
�|_tj|�dS)NZ
_testembed�winZ_d�z.exeZProgramsz%r doesn't exist)r��path�abspath�__file__�dirnamer!�platformr&r"�join�test_exe�existsZskipTest�getcwd�oldcwd�chdir)r	�hereZbasepathZexenameZextZexepathZexerrr
�setUpxs
zEmbeddingTests.setUpcCstj|j�dS)N)r�r�r�)r	rrr
�tearDown�szEmbeddingTests.tearDownN)�envcGs�|jg}|j|�|dk	r:tjdkr:|j�}tjd|d<tj|tj	tj	d|d�}|j
�\}}|j|jdd|j|f�||fS)z'Runs a test in the embedded interpreterNZwin32Z
SYSTEMROOTT)rrZuniversal_newlinesr�rzbad returncode %d, stderr is %r)
r��extendr!r��copyr��environrr r#r$r�
returncode)r	r�r��cmdr'r(r)rrr
�run_embedded_interpreter�s

z'EmbeddingTests.run_embedded_interpretercCs.|jd�\}}tjr*t�t|�t|�dS)NZ!repeated_init_and_subinterpreters)r�rr|r})r	r(r)rrr
�&test_repeated_init_and_subinterpreters�s
z5EmbeddingTests.test_repeated_init_and_subinterpreterscCs�ttjdd�}|jd|d�\}}tjr<t�t|�t|�d}d}djdd	d
ddd
dd	dddd
ddd
dddddddddg�}|j|||d�}d|_	|j
|j�|�dS)Nzutf-8:surrogateescape)ZPYTHONIOENCODINGZforced_io_encoding)r�zutf-8�surrogateescape�
z--- Use defaults ---zExpected encoding: defaultzExpected errors: defaultzstdin: {in_encoding}:{errors}zstdout: {out_encoding}:{errors}z'stderr: {out_encoding}:backslashreplacez--- Set errors only ---zExpected errors: ignorezstdin: {in_encoding}:ignorezstdout: {out_encoding}:ignorez--- Set encoding only ---zExpected encoding: latin-1zstdin: latin-1:{errors}zstdout: latin-1:{errors}z stderr: latin-1:backslashreplacez--- Set encoding and errors ---zExpected errors: replacezstdin: latin-1:replacezstdout: latin-1:replace)Zin_encodingZout_encoding�errors)�dictr�r�r�rr|r}r�r�ZmaxDiffr�strip)r	r�r(r)Zexpected_stream_encodingZexpected_errorsZexpected_outputrrr
�test_forced_io_encoding�sNz&EmbeddingTests.test_forced_io_encodingcCsFttjtjjtj�d�}|jd|d�\}}|j|d�|j|d�dS)z~
        Checks the few parts of the C-API that work before the runtine
        is initialized (via Py_Initialize()).
        )�
PYTHONPATHZpre_initialization_api)r�r�N)	r�r�r��pathsepr�r!r�r�r)r	r�r(r)rrr
�test_pre_initialization_api�sz*EmbeddingTests.test_pre_initialization_api)	r
rrr�r�r�r�r�r�rrrr
r�ws+r�c@seZdZejdd��ZdS)�TestThreadStatecs2�fdd�}|�tj|d�}|j�|j�dS)NcsHg��fdd�}tj|�|}}tjd��j�jtj��dd�dS)Ncs�jtj��dS)N)rrrp�	get_identr)�identsrr
rt�szCTestThreadState.test_thread_state.<locals>.target.<locals>.callbackr.r9z/Couldn't find main thread correctly in the list)rZ_test_thread_statervrwrr�rpr�)rtr��b)r	)r�r
r��s

z1TestThreadState.test_thread_state.<locals>.target)r�)rpr��startr�)r	r��tr)r	r
�test_thread_state�s

z!TestThreadState.test_thread_stateN)r
rrrZreap_threadsr�rrrr
r��sr�c@s&eZdZe�jdd�ee�D��dS)�
Test_testcapiccs2|]*}|jd�r|jd�r|tt|�fVqdS)Ztest_�_codeN)r&�endswith�getattrr)r��namerrr
�	<genexpr>�szTest_testcapi.<genexpr>N)r
rr�locals�update�dirrrrrr
r��sr�c@sPeZdZdZdZdd�Zdd�Zdd�Zej	e
d	�d
d��Zdd
�Zdd�Z
dS)�PyMemDebugTests�debugz(?:0x)?[0-9a-fA-F]+cCs6tj��td||jd�}WdQRX|j}|jdd�S)Nz-c)�PYTHONMALLOC�asciirb)rrrr�r)�decode)r	rfr(rrrr
�checks

zPyMemDebugTests.checkcCs<|jd�}d}|j|jd�}tj|tjd�}|j||�dS)Nz3import _testcapi; _testcapi.pymem_buffer_overflow()aDebug memory block at address p={ptr}: API 'm'\n    16 bytes originally requested\n    The [0-9] pad bytes at p-[0-9] are FORBIDDENBYTE, as expected.\n    The [0-9] pad bytes at tail={ptr} are not all FORBIDDENBYTE \(0x[0-9a-f]{{2}}\):\n        at tail\+0: 0x78 \*\*\* OUCH\n        at tail\+1: 0xfb\n        at tail\+2: 0xfb\n        .*\n    The block was made by call #[0-9]+ to debug malloc/realloc.\n    Data at p: cb cb cb .*\n\nEnable tracemalloc to get the memory block allocation traceback\n\nFatal Python error: bad trailing pad byte)�ptr)�flags)r�r��	PTR_REGEX�re�compile�DOTALLra)r	r(�regexrrr
�test_buffer_overflows

z$PyMemDebugTests.test_buffer_overflowcCs,|jd�}d}|j|jd�}|j||�dS)Nz.import _testcapi; _testcapi.pymem_api_misuse()a�Debug memory block at address p={ptr}: API 'm'\n    16 bytes originally requested\n    The [0-9] pad bytes at p-[0-9] are FORBIDDENBYTE, as expected.\n    The [0-9] pad bytes at tail={ptr} are FORBIDDENBYTE, as expected.\n    The block was made by call #[0-9]+ to debug malloc/realloc.\n    Data at p: cb cb cb .*\n\nEnable tracemalloc to get the memory block allocation traceback\n\nFatal Python error: bad ID: Allocated using API 'm', verified using API 'r'\n)r�)r�r�r�ra)r	r(r�rrr
�test_api_misuse s

zPyMemDebugTests.test_api_misusez$Test requires a GIL (multithreading)cCs|j|�}d}|j||�dS)NzJFatal Python error: Python memory allocator called without holding the GIL)r�rl)r	rfr(Zexpectedrrr
�check_malloc_without_gil/s
z(PyMemDebugTests.check_malloc_without_gilcCsd}|j|�dS)Nz6import _testcapi; _testcapi.pymem_malloc_without_gil())r�)r	rfrrr
�test_pymem_malloc_without_gil6sz-PyMemDebugTests.test_pymem_malloc_without_gilcCsd}|j|�dS)Nz9import _testcapi; _testcapi.pyobject_malloc_without_gil())r�)r	rfrrr
� test_pyobject_malloc_without_gil<sz0PyMemDebugTests.test_pyobject_malloc_without_gilN)r
rrr�r�r�r�r�rnrorpr�r�r�rrrr
r�sr�c@seZdZdZdS)�PyMemMallocDebugTestsZmalloc_debugN)r
rrr�rrrr
r�Csr��
WITH_PYMALLOCr.z
need pymallocc@seZdZdZdS)�PyMemPymallocDebugTestsZpymalloc_debugN)r
rrr�rrrr
r�Gsr�z
need Py_DEBUGc@seZdZdZdS)�PyMemDefaultTestsr�N)r
rrr�rrrr
r�Msr��__main__))r�r�rxr�rr!�	sysconfigr_rvrnrrZtest.supportrZtest.support.script_helperrrrM�ImportErrorrp�
import_moduler�hasattrr^rrZTestCaserrorqr�r�r�r�r�r��get_config_varr�r�r
�mainrrrr
�<module>sT



n
Oj
C


Youez - 2016 - github.com/yon3zu
LinuXploit