Sindbad~EG File Manager

Current Path : /usr/local/lib/python3.9/test/__pycache__/
Upload File :
Current File : //usr/local/lib/python3.9/test/__pycache__/test_capi.cpython-39.pyc

a

��g���@s�ddlmZddlZddlZddlZddlZddlZddlZddlZddl	Z	ddl
Z
ddlZddlZddl
ZddlZddlmZddlmZddlmZmZzddlZWney�dZYn0e�d�ZddlZeed�Zdd	�ZGd
d�d�ZGdd
�d
ej �Z!Gdd�dej �Z"Gdd�dej �Z#Gdd�dej �Z$Gdd�dej �Z%Gdd�dej �Z&Gdd�dej �Z'Gdd�de'�Z(e�)e�*�d�Gdd�de'��Z+e�)ed�Gd d!�d!e'��Z,Gd"d#�d#ej �Z-e.d$k�r�e�/�dS)%�)�OrderedDictN)�support)�MISSING_C_DOCSTRINGS)�assert_python_failure�assert_python_ok�	_testcapiZgettotalrefcountcCs|S)zsome doc���selfrr�*/usr/local/lib/python3.9/test/test_capi.py�testfunction#src@s eZdZe�e�Ze�e�ZdS)�InstanceMethodN)�__name__�
__module__�__qualname__rZinstancemethod�idrrrrrr
(s
r
c@sfeZdZdd�Zdd�Zdd�Zdd�Ze�e	d	�d
d��Z
e�e	d	�dd
��Ze�e
d�dd��Zdd�Zdd�Zdd�Zdd�Zdd�Zdd�Zdd�Zdd �Ze�eed!�d"�d#d$��Zd%d&�Ze�d'�d(d)��Ze�d'�d*d+��Zd,d-�Zd.d/�Z d0d1�Z!d2d3�Z"d4d5�Z#d6d7�Z$d8d9�Z%d:d;�Z&d<d=�Z'd>d?�Z(d@dA�Z)dBdC�Z*dDdE�Z+dFdG�Z,dHdI�Z-dJS)K�CAPITestcCs~t�}|�t|�|���|�|��|u�|�|jjtj�|�tjjtj�dtj_|�tjd�|�tt	|jdd�dS)N�test�	attribute)
r
�assertEqualr�
assertTruer�__doc__r�assertRaises�AttributeError�setattr�r
�instrrr�test_instancemethod.szCAPITest.test_instancemethodcCsvt���,tjtjddgtjtjd�}Wd�n1s:0Y|��\}}|�|d�|�	|�
��d�|�dS)N�-cz4import _testcapi;_testcapi.crash_no_current_thread())�stdout�stderr�s�Fatal Python error: PyThreadState_Get: the function must be called with the GIL held, but the GIL is released (the current Python thread state is NULL))r�SuppressCrashReport�
subprocess�Popen�sys�
executable�PIPE�communicaterr�rstrip�
startswith)r
�p�out�errrrr� test_no_FatalError_infinite_loop9s

��$��z)CAPITest.test_no_FatalError_infinite_loopcCs|�ttj�dS�N)r�
ValueErrorrZ!make_memoryview_from_NULL_pointerr	rrr�!test_memoryview_from_NULL_pointerKsz*CAPITest.test_memoryview_from_NULL_pointerc

Cs�td�}td�}z|�Wn�ty�}z�|j}t��}t�|j|d�}t��}tj|�}t��}	|�|d|�|�	||j||f�|�	||�|�	|	|�|�	||j|df�|�	||�WYd}~nd}~00|�
d�dS)N�5ZTEST�F)r0�	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_infoNs$
"zCAPITest.test_exc_infoz(_posixsubprocess required for this test.cCs�Gdd�dt�}|�ttjd|�dddddd	d
ddd
ddddddddd�Gdd�dt�}|�ttjd|�dddddd	d
ddd
ddddddddd�dS)Nc@seZdZdd�ZdS)�1CAPITest.test_seq_bytes_to_charp_array.<locals>.ZcSsdS�Nr3rr	rrr�__len__is�9CAPITest.test_seq_bytes_to_charp_array.<locals>.Z.__len__N�rrrr>rrrr�ZhsrAr3��r3������	�
���
��������c@seZdZdd�Zdd�ZdS)r<cSstjSr/)r%�maxsizer	rrrr>osr?cSsdS)N�xr)r
�irrr�__getitem__qsz=CAPITest.test_seq_bytes_to_charp_array.<locals>.Z.__getitem__N)rrrr>rYrrrrrAns)�objectrr4�_posixsubprocess�	fork_exec�MemoryError�r
rArrr�test_seq_bytes_to_charp_arrayes
,�
,�z&CAPITest.test_seq_bytes_to_charp_arraycCsPGdd�dt�}|�ttj|�dgdddddd	d
ddd
ddddddddd�dS)Nc@seZdZdd�ZdS)z-CAPITest.test_subprocess_fork_exec.<locals>.ZcSsdSr=rr	rrrr>ysz5CAPITest.test_subprocess_fork_exec.<locals>.Z.__len__Nr@rrrrrAxsrA�1rBrCrErFrGrHrIrJrKrLrMrNrOrPrQrRrSrTrU)rZrr4r[r\r^rrr�test_subprocess_fork_execvs
.�z"CAPITest.test_subprocess_fork_execz6Signature information for builtins requires docstringscCs|�tjjd�|�tjjd�|�tjjd�|�tjjd�|�tjjd�|�tjjd�|�tjjd�|�tjjd�|�tjjd�|�tjjd�|�tj	jd�|�tj	jd�|�tj
jd�|�tj
jd�|�tjjd�|�tjjd�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_newlinesr	rrr� test_docstring_signature_parsing�s<
�
�
�
�
�
�
�z)CAPITest.test_docstring_signature_parsingcCs�tj}|�}|�}|�||d||f�|�|dd|df�|�d|dd|f�|}||}|�|d||f�|}|d}|�|d|df�d}||}|�|dd|f�dS)N�matmul�*�imatmul)rZ
matmulTyper)r
�MZm1Zm2�orrr�&test_c_type_with_matrix_multiplication�sz/CAPITest.test_c_type_with_matrix_multiplicationcCs2t��}|�|�d�d�|�|�dd�d�dS)Nr3)r3NrD)rDrD)rZipowTyper�__ipow__)r
rhrrr�test_c_type_with_ipow�szCAPITest.test_c_type_with_ipowcCs|tr4t�d�}td|�\}}}|�|�dd�d�nD|�t��}t�	�Wd�n1s\0Y|�t
|j�d�dS)Nz�
                import _testcapi
                from test import support

                with support.SuppressCrashReport():
                    _testcapi.return_null_without_error()
            r�
r!sFatal Python error: _Py_CheckFunctionResult: a function returned NULL without setting an error\nPython runtime state: initialized\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_errorcCs|tr4t�d�}td|�\}}}|�|�dd�d�nD|�t��}t�	�Wd�n1s\0Y|�t
|j�d�dS)Nz�
                import _testcapi
                from test import support

                with support.SuppressCrashReport():
                    _testcapi.return_result_with_error()
            rrlr!sgFatal Python error: _Py_CheckFunctionResult: a function returned a result with an error set\nPython runtime state: initialized\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)rmrnrorrprqrrrrZreturn_result_with_errorrsrtrurrr�test_return_result_with_error�s
�&�z&CAPITest.test_return_result_with_errorcCst��dSr/)r�test_buildvalue_Nr	rrrr{szCAPITest.test_buildvalue_NcCs<d}td|�\}}}|�d|�|�d|�|�d|�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
        rsMemoryError 1 10sMemoryError 2 20sMemoryError 3 30)r�assertIn�r
rvrwr,r-rrr�test_set_nomemorys
zCAPITest.test_set_nomemoryc	Cs�Gdd�dt�}Gdd�dt�}dddd�}it�|�|�|t|�||�||�fD]R}|�t�|�t|����|�t�|�t|����|�t�	|�t|�
���qRdS)	Ncs4eZdZ�fdd�Z�fdd�Z�fdd�Z�ZS)z9CAPITest.test_mapping_keys_values_items.<locals>.Mapping1cstt����Sr/)�list�super�keysr	�r7rrr�(sz>CAPITest.test_mapping_keys_values_items.<locals>.Mapping1.keyscstt����Sr/)rr��valuesr	r�rrr�*sz@CAPITest.test_mapping_keys_values_items.<locals>.Mapping1.valuescstt����Sr/)rr��itemsr	r�rrr�,sz?CAPITest.test_mapping_keys_values_items.<locals>.Mapping1.items�rrrr�r�r��
__classcell__rrr�r�Mapping1'sr�cs4eZdZ�fdd�Z�fdd�Z�fdd�Z�ZS)z9CAPITest.test_mapping_keys_values_items.<locals>.Mapping2cstt����Sr/)�tupler�r�r	r�rrr�/sz>CAPITest.test_mapping_keys_values_items.<locals>.Mapping2.keyscstt����Sr/)r�r�r�r	r�rrr�1sz@CAPITest.test_mapping_keys_values_items.<locals>.Mapping2.valuescstt����Sr/)r�r�r�r	r�rrr�3sz?CAPITest.test_mapping_keys_values_items.<locals>.Mapping2.itemsr�rrr�r�Mapping2.sr�r3rDrB)�fooZbarZspam)�dictrZassertListEqualr�get_mapping_keysrr��get_mapping_valuesr��get_mapping_itemsr�)r
r�r�Zdict_obj�mappingrrr�test_mapping_keys_values_items&s �
�
�
�z'CAPITest.test_mapping_keys_values_itemscCsx|�ttjd�|�ttjd�|�ttjd�Gdd�d�}|�}|�ttj|�|�ttj|�|�ttj|�dS)Nc@s$eZdZdd�Zdd�Zdd�ZdS)zCCAPITest.test_mapping_keys_values_items_bad_arg.<locals>.BadMappingcSsdSr/rr	rrrr�GszHCAPITest.test_mapping_keys_values_items_bad_arg.<locals>.BadMapping.keyscSsdSr/rr	rrrr�IszJCAPITest.test_mapping_keys_values_items_bad_arg.<locals>.BadMapping.valuescSsdSr/rr	rrrr�KszICAPITest.test_mapping_keys_values_items_bad_arg.<locals>.BadMapping.itemsN)rrrr�r�r�rrrr�
BadMappingFsr�)rrrr�r�r�r4)r
r�Zbad_mappingrrr�&test_mapping_keys_values_items_bad_argAsz/CAPITest.test_mapping_keys_values_items_bad_argZnegative_refcountz need _testcapi.negative_refcountcCs*t�d�}td|�\}}}|�|d�dS)Nz�
            import _testcapi
            from test import support

            with support.SuppressCrashReport():
                _testcapi.negative_refcount()
        rs`_testcapimodule\.c:[0-9]+: _Py_NegativeRefcount: Assertion failed: object has negative ref count)rnrorrpr}rrr�test_negative_refcountRs

�zCAPITest.test_negative_refcountcCs,ddlm}d}td�D]}||f�}qdS)Nr��MyList��)rr��range)r
r��LrXrrr�test_trashcan_subclassdszCAPITest.test_trashcan_subclassZcpucCs|�t�dSr/)�do_test_trashcan_python_classrr	rrr�test_trashcan_python_class1lsz$CAPITest.test_trashcan_python_class1cCsddlm}|�|�dS)Nrr�)rr�r�)r
r�rrr�test_trashcan_python_class2psz$CAPITest.test_trashcan_python_class2cCshGdd�d|�}dD]N}d}td�D]}||f�}||_q$|rD|f}|�|jd�~|�|jd�qdS)Ncs,eZdZdZ�fdd�Z�fdd�Z�ZS)z6CAPITest.do_test_trashcan_python_class.<locals>.PyListrcs�jd7_t�j|�dSr=)�numr��__init__)r
�argsr�rrr�}sz?CAPITest.do_test_trashcan_python_class.<locals>.PyList.__init__cs�jd8_dSr=)r�r	r�rr�__del__�sz>CAPITest.do_test_trashcan_python_class.<locals>.PyList.__del__)rrrr�r�r�r�rrr�r�PyListysr�)rr3ir)r��attrZ
assertGreaterr�r)r
�baser�Zparityr�rXrrrr�us

z&CAPITest.do_test_trashcan_python_classcCsZGdd�dtj�}|�}t�|�}|�|jd�|�|jd�~|�|dt�|��dS)NcseZdZ�fdd�Z�ZS)z`CAPITest.test_subclass_of_heap_gc_ctype_with_tpdealloc_decrefs_once.<locals>.HeapGcCTypeSubclasscsd|_t���dS�NrT��value2r�r�r	r�rrr��sziCAPITest.test_subclass_of_heap_gc_ctype_with_tpdealloc_decrefs_once.<locals>.HeapGcCTypeSubclass.__init__�rrrr�r�rrr�r�HeapGcCTypeSubclass�sr�rJrTr3)r�HeapGcCTyper%�getrefcountr�valuer�)r
r��subclass_instance�type_refcntrrr�:test_subclass_of_heap_gc_ctype_with_tpdealloc_decrefs_once�s
zCCAPITest.test_subclass_of_heap_gc_ctype_with_tpdealloc_decrefs_oncecs�Gdd�dtj��G��fdd�d�����}t���}t���}|�|jd�|�|jd�~|�|d�j�|�|d�j�|�|dt����|�|t����dS)NcseZdZ�fdd�Z�ZS)zdCAPITest.test_subclass_of_heap_gc_ctype_with_del_modifying_dunder_class_only_decrefs_once.<locals>.Acsd|_t���dSr�r�r	r�rrr��szmCAPITest.test_subclass_of_heap_gc_ctype_with_del_modifying_dunder_class_only_decrefs_once.<locals>.A.__init__r�rrr�r�A�sr�cs*eZdZ�fdd�Z��fdd�Z�ZS)zdCAPITest.test_subclass_of_heap_gc_ctype_with_del_modifying_dunder_class_only_decrefs_once.<locals>.Bcst���dSr/)r�r�r	r�rrr��szmCAPITest.test_subclass_of_heap_gc_ctype_with_del_modifying_dunder_class_only_decrefs_once.<locals>.B.__init__cs"�|_t����_t����_dSr/)r7r%r��
refcnt_in_delr	�r��Brrr��szlCAPITest.test_subclass_of_heap_gc_ctype_with_del_modifying_dunder_class_only_decrefs_once.<locals>.B.__del__)rrrr�r�r�rr�r�rr��sr�rJrTr3)rr�r%r�rr�r�r��r
r�r�Znew_type_refcntrr�r�Ptest_subclass_of_heap_gc_ctype_with_del_modifying_dunder_class_only_decrefs_once�s	

zYCAPITest.test_subclass_of_heap_gc_ctype_with_del_modifying_dunder_class_only_decrefs_oncecCsXt��}d|_|�|jd�|�|j|j�|�|jddi�t��}|�i|j�dS�Nrer�)rZHeapCTypeWithDictr�r�dictobj�__dict__rrrr�test_heaptype_with_dict�sz CAPITest.test_heaptype_with_dictcCsXt��}d|_|�|jd�|�|j|j�|�|jddi�t��}|�i|j�dSr�)rZHeapCTypeWithNegativeDictr�rr�r�rrrr� test_heaptype_with_negative_dict�sz)CAPITest.test_heaptype_with_negative_dictcCs2t��}t�|�}|�|�|�|�|j|�dSr/)rZHeapCTypeWithWeakref�weakref�refrZweakreflist)r
rr�rrr�test_heaptype_with_weakref�s
z#CAPITest.test_heaptype_with_weakrefcCs t��}t|�}|�|d�dS)Ns1234)rZHeapCTypeWithBuffer�bytesr)r
r�brrr�test_heaptype_with_buffer�sz"CAPITest.test_heaptype_with_buffercCsNt��}t�tj�}|�|jd�|�|jd�~|�|dt�tj��dS�NrJrTr3)r�HeapCTypeSubclassr%r�rr�r�)r
r�r�rrr�9test_c_subclass_of_heap_ctype_with_tpdealloc_decrefs_once�szBCAPITest.test_c_subclass_of_heap_ctype_with_tpdealloc_decrefs_oncecCs�t��}t�tj�}t�tj�}|�|jd�|�|jd�~|�|dtjj�|�|dtjj�|�|dt�tj��|�|t�tj��dSr�)	rZHeapCTypeSubclassWithFinalizerr%r�r�rr�r�r�r�rrr�Otest_c_subclass_of_heap_ctype_with_del_modifying_dunder_class_only_decrefs_once�szXCAPITest.test_c_subclass_of_heap_ctype_with_del_modifying_dunder_class_only_decrefs_oncecCs@t��}|�|jd�d|_|�|jd�|`|�|jd�dS)NrJrLr)rZHeapCTypeSetattrrZpvaluer�)r
�objrrr�test_heaptype_with_setattrosz$CAPITest.test_heaptype_with_setattrocCs�ddlm}|�|dd�d�|�|dd�d�|�|dd�d	�|�|dd
�d�|�|dd�d
�|�|dd�d�|�|dd�d�|�|dd
�d�|�t|dd�|�t|d	d�|�t|dd�dS)Nr)�pynumber_tobase�{rDZ	0b1111011rHZ0o173rJ�123rPZ0x7bi����z
-0b1111011z-0o173z-123z-0x7bg�^@)rr�rrr4rr)r
r�rrr�test_pynumber_tobaseszCAPITest.test_pynumber_tobasecCst��}|�|d�dS�Nz<NULL>)rZpyobject_repr_from_nullr�r
�srrr�test_pyobject_repr_from_nullsz%CAPITest.test_pyobject_repr_from_nullcCst��}|�|d�dSr�)rZpyobject_str_from_nullrr�rrr�test_pyobject_str_from_null sz$CAPITest.test_pyobject_str_from_nullcCst��}|�|d�dS)Ns<NULL>)rZpyobject_bytes_from_nullrr�rrr�test_pyobject_bytes_from_null$sz&CAPITest.test_pyobject_bytes_from_nullcCs2tj}d}||�}t|dd�}|�|j|j�dS)Ns%# -*- coding: latin1 -*-
print('¤')
z<string>�exec)rZPy_CompileString�compiler�	co_consts)r
�_compilerv�result�expectedrrr�test_Py_CompileString(s
zCAPITest.test_Py_CompileStringN).rrrrr.r1r;�unittest�
skipUnlessr[r_raZskipIfrrcrirkryrzr{r~r�r��hasattrrr�r�rZrequires_resourcer�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�rrrrr,sX



	�
)" �


#

rc@s6eZdZdd�Zddd�Zdd�Zdd	�Zd
d�ZdS)
�TestPendingCallscs>�fdd�}t|�D]$}t�t��d�t�|�r*qq*qdS)Ncs��d�dSr/)�appendr��lrr�callback4sz6TestPendingCalls.pendingcalls_submit.<locals>.callbackg{�G�z�?)r��time�sleep�randomrZ_pending_threadfunc)r
r��nr�rXrr�r�pendingcalls_submit3s

z$TestPendingCalls.pendingcalls_submitNcCs�d}t|�|krxdr,tjr,tdt|�f�td�D]}||}q4|rR|j��sRq|d7}|�|dkd|t|�f�qdr�tjr�tdt|�f�dS)NrFz(%i)r�r3i'z(timeout waiting for %i callbacks, got %i)�lenr�verbose�printr��event�is_setr)r
r�r��context�countrX�arrr�pendingcalls_waitBs


�
z"TestPendingCalls.pendingcalls_waitcs�d}g}Gdd�dt�}|��g�_d�_|�j�_d�_t���_t���_	��fdd�t
�j�D�}t�|�� ��
�j|��Wd�n1s�0YdS)N� c@seZdZdS)z8TestPendingCalls.test_pendingcalls_threaded.<locals>.fooN�rrrrrrrr�Zr!r�rDrcsg|]}tj�j�fd��qS))�targetr�)�	threading�Thread�pendingcalls_thread)�.0rX�r�r
rr�
<listcomp>cs��z?TestPendingCalls.test_pendingcalls_threaded.<locals>.<listcomp>)rZr�r��nThreads�	nFinishedr��Lock�lock�Eventr�r�rZ
start_threadsr�)r
r��threadsr�rr�r�test_pendingcalls_threadedUs

�z+TestPendingCalls.test_pendingcalls_threadedcCs�zv|�|j|j�W|j�8|jd7_|j}drDtjrDtd|�Wd�n1sX0Y||jkr�|j	�
�nd|j�8|jd7_|j}dr�tjr�td|�Wd�n1s�0Y||jkr�|j	�
�0dS)Nr3Fzfinished threads: )r�r�r�r�r�rr�r�r�r��set)r
r�r�rrrr�is 
(
�
(
z$TestPendingCalls.pendingcalls_threadcCs$g}d}|�||�|�||�dS)N�@)r�r�)r
r�r�rrr�test_pendingcalls_non_threadedusz/TestPendingCalls.test_pendingcalls_non_threaded)N)rrrr�r�r�r�r�rrrrr�1s

r�c@s,eZdZdd�Zdd�Zdd�Zdd�Zd	S)
�SubinterpreterTestcCs�ddl}t��\}}d�|�}t|d��T}t�|�}|�|d�|�t	�
|�ttj
��|�t	�
|�t|��Wd�n1s�0YdS)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�openr�run_in_subinterprZassertNotEqual�pickle�loadrr%�modules)r
r�r�wrv�f�retrrr�test_subinterps�s�
z"SubinterpreterTest.test_subinterpscCsrt��\}}d�|�}t|d��>}t�|�}|�|d�|�t�|�ddd��Wd�n1sd0YdS)Naaif 1:
            import pickle
            with open({:d}, "wb") as f:

                @(lambda x:x)  # Py 3.9
                def noop(x): return x

                a = (b := f'1{{2}}3') + noop('x')  # Py 3.8 (:=) / 3.6 (f'')

                async def foo(arg): return await arg  # Py 3.5

                pickle.dump(dict(a=a, b=b), f)
            rrZ123xr�)r�r�)	rrrrrrrrr	)r
rrrvr
rrrr�(test_subinterps_recent_language_features�s�
z;SubinterpreterTest.test_subinterps_recent_language_featurescCs(ddl}t�d�|�t|jd��dS)z�
        Exceptions saved in global module state get shared between
        individual module instances. This test checks whether or not
        a change in one interpreter's module gets reflected into the
        other ones.
        rNz1import binascii; binascii.Error.foobar = 'foobar'Zfoobar)�binasciirrZassertFalser��Error)r
rrrr�test_mutate_exception�s
z(SubinterpreterTest.test_mutate_exceptioncCs�t��\}}|�tj|�|�tj|�t�d|�d��}t|�t�|d�}t�	|�}|�
|d�t�|d�}|�
||�dS)z�
        bpo-44050: Extension module state should be shared between interpreters
        when it doesn't support sub-interpreters.
        a�
            import importlib.machinery
            import importlib.util
            import os

            fullname = '_test_module_state_shared'
            origin = importlib.util.find_spec('_testmultiphase').origin
            loader = importlib.machinery.ExtensionFileLoader(fullname, origin)
            spec = importlib.util.spec_from_loader(fullname, loader)
            module = importlib.util.module_from_spec(spec)
            attr_id = str(id(module.Error)).encode()

            os.write(z, attr_id)
            �drN)rrZ
addCleanup�closernror��readrrr)r
rrZscriptZmain_attr_idrZsubinterp_attr_idrrr�"test_module_state_shared_in_global�s�

z5SubinterpreterTest.test_module_state_shared_in_globalN)rrrrrrrrrrrr�s
rc@seZdZejdd��ZdS)�TestThreadStatecs2�fdd�}|�tj|d�}|��|��dS)NcsHg��fdd�}t�|�|}}t�d�����t���dd�dS)Ncs��t���dSr/)r�r��	get_identr�Zidentsrrr��szCTestThreadState.test_thread_state.<locals>.target.<locals>.callbackr3rBz/Couldn't find main thread correctly in the list)rZ_test_thread_stater�r�rr�r�r)r�r�r�r	rrr��s

�z1TestThreadState.test_thread_state.<locals>.target)r�)r�r��start�join)r
r��trr	r�test_thread_state�s

z!TestThreadState.test_thread_stateN)rrrrZreap_threadsrrrrrr�src@s&eZdZe��dd�ee�D��dS)�
Test_testcapiccs0|](}|�d�r|�d�s|tt|�fVqdS)�test_�_codeN)r*�endswith�getattrr�r��namerrr�	<genexpr>�s�zTest_testcapi.<genexpr>N)rrr�locals�update�dirrrrrrr�s�rc@s&eZdZe��dd�ee�D��dS)�Test_testinternalcapiccs&|]}|�d�r|tt|�fVqdS)r N)r*r#�_testinternalcapir$rrrr&�s
�zTest_testinternalcapi.<genexpr>N)rrrr'r(r)r+rrrrr*�s�r*c@sleZdZdZdZdd�Zdd�Zdd�Zd	d
�Zdd�Z	d
d�Z
dd�Zdd�Zdd�Z
dd�Zdd�ZdS)�PyMemDebugTests�debugz(?:0x)?[0-9a-fA-F]+cCsLt���"td||jdd�}Wd�n1s00Y|j}|�dd�S)Nr�
junk:false��PYTHONMALLOCZMALLOC_CONF�asciirq)rr"rr0r-�decode)r
rvr,r rrr�check�s
�$zPyMemDebugTests.checkcCs<|�d�}d}|j|jd�}tj|tjd�}|�||�dS)Nz3import _testcapi; _testcapi.pymem_buffer_overflow()a6Debug 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: 0xfd\n        at tail\+2: 0xfd\n        .*\n(    The block was made by call #[0-9]+ to debug malloc/realloc.\n)?    Data at p: cd cd cd .*\n\nEnable tracemalloc to get the memory block allocation traceback\n\nFatal Python error: _PyMem_DebugRawFree: bad trailing pad byte�Zptr)�flags)r3r�	PTR_REGEX�rer��DOTALLrp�r
r,Zregexrrr�test_buffer_overflows

z$PyMemDebugTests.test_buffer_overflowcCs,|�d�}d}|j|jd�}|�||�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: cd cd cd .*\n\nEnable tracemalloc to get the memory block allocation traceback\n\nFatal Python error: _PyMem_DebugRawFree: bad ID: Allocated using API 'm', verified using API 'r'\nr4)r3rr6rpr9rrr�test_api_misuses

zPyMemDebugTests.test_api_misusecCs|�|�}d}|�||�dS)Nz^Fatal Python error: _PyMem_DebugMalloc: Python memory allocator called without holding the GIL)r3r|)r
rvr,r�rrr�check_malloc_without_gil+s
z(PyMemDebugTests.check_malloc_without_gilcCsd}|�|�dS)Nz6import _testcapi; _testcapi.pymem_malloc_without_gil()�r<�r
rvrrr�test_pymem_malloc_without_gil1sz-PyMemDebugTests.test_pymem_malloc_without_gilcCsd}|�|�dS)Nz9import _testcapi; _testcapi.pyobject_malloc_without_gil()r=r>rrr� test_pyobject_malloc_without_gil7sz0PyMemDebugTests.test_pyobject_malloc_without_gilcCs(t�d|�d��}td||jdd�dS)Nz�
            import gc, os, sys, _testcapi
            # Disable the GC to avoid crash on GC collection
            gc.disable()
            try:
                _testcapi.z�()
                # Exit immediately to avoid a crash while deallocating
                # the invalid object
                os._exit(0)
            except _testcapi.error:
                os._exit(1)
        rr.r/)rnrorr0)r
�	func_namervrrr�check_pyobject_is_freed=s�
�z'PyMemDebugTests.check_pyobject_is_freedcCs|�d�dS)NZcheck_pyobject_null_is_freed�rBr	rrr�test_pyobject_null_is_freedPsz+PyMemDebugTests.test_pyobject_null_is_freedcCs|�d�dS)NZ%check_pyobject_uninitialized_is_freedrCr	rrr�$test_pyobject_uninitialized_is_freedSsz4PyMemDebugTests.test_pyobject_uninitialized_is_freedcCs|�d�dS)NZ'check_pyobject_forbidden_bytes_is_freedrCr	rrr�&test_pyobject_forbidden_bytes_is_freedVsz6PyMemDebugTests.test_pyobject_forbidden_bytes_is_freedcCs|�d�dS)NZcheck_pyobject_freed_is_freedrCr	rrr�test_pyobject_freed_is_freedYsz,PyMemDebugTests.test_pyobject_freed_is_freedN)rrrr0r6r3r:r;r<r?r@rBrDrErFrGrrrrr,�sr,c@seZdZdZdS)�PyMemMallocDebugTestsZmalloc_debugN�rrrr0rrrrrH]srHz
need pymallocc@seZdZdZdS)�PyMemPymallocDebugTestsZpymalloc_debugNrIrrrrrJasrJz
need Py_DEBUGc@seZdZdZdS)�PyMemDefaultTests�NrIrrrrrKfsrKc@s0eZdZdZdd�Zdd�Zdd�Zdd	�Zd
S)�Test_ModuleStateAccessz%Test access to module start (PEP 573)cCsNd}tj�d�j}tj�||�}tj�||�}tj�|�}|�|�||_	dS)NZ!_testmultiphase_meth_state_accessZ_testmultiphase)
�	importlib�util�	find_spec�origin�	machinery�ExtensionFileLoader�spec_from_loader�module_from_spec�exec_module�module)r
�fullnamerQ�loader�specrWrrr�setUpss
zTest_ModuleStateAccess.setUpcCs0Gdd�d|jj�}|�}|�|��|j�dS)z#PyType_GetModule for defining_classc@seZdZdS)zQTest_ModuleStateAccess.test_subclass_get_module.<locals>.StateAccessType_SubclassNr�rrrr�StateAccessType_Subclass~sr\N�rW�StateAccessTypeZassertIs�get_defining_module�r
r\�instancerrr�test_subclass_get_module|sz/Test_ModuleStateAccess.test_subclass_get_modulecCs0Gdd�d|jj�}|�}|�|��|j�dS)NcseZdZ�fdd�Z�ZS)z\Test_ModuleStateAccess.test_subclass_get_module_with_super.<locals>.StateAccessType_Subclasscs
t���Sr/)r�r_r	r�rrr_�szpTest_ModuleStateAccess.test_subclass_get_module_with_super.<locals>.StateAccessType_Subclass.get_defining_module)rrrr_r�rrr�rr\�sr\r]r`rrr�#test_subclass_get_module_with_super�sz:Test_ModuleStateAccess.test_subclass_get_module_with_superc
Cs�|j��}|j��}|j|jd�}|��D�]N\}}|�|���(|�|��|���|�|��d�|�|�|��|���|�|��d�|d�|�|��|���|�|��d�|ddd�|�|��|���|�|��d�|�t	��|dd	�Wd
�n1�s0Y|�t	��|ddd�Wd
�n1�sP0YWd
�q*1�sp0Yq*d
S)z�Checks methods defined with and without argument clinic

        This tests a no-arg method (get_count) and a method with
        both a positional and keyword argument.
        )ZclinicZnoclinicrr3rB����T)Ztwice)ZthriceNrD)
rWr^Zincrement_count_clinicZincrement_count_noclinicr�ZsubTestrZ	get_countrr4)r
r�r��methodsr%Zincrement_countrrr�test_state_access�s,

�*z(Test_ModuleStateAccess.test_state_accessN)rrrrr[rbrcrgrrrrrMls
	rM�__main__)0�collectionsrrrr�r7r#r%rnr�r�r�r�Zimportlib.machineryrN�importlib.utilrrZtest.supportrZtest.support.script_helperrrr[�ImportError�
import_modulerr+r�rmrr
ZTestCaserr�rrrr*r,rHr�Z
with_pymallocrJrKrMr�mainrrrr�<module>sX


	OSf
G


Sindbad File Manager Version 1.0, Coded By Sindbad EG ~ The Terrorists