Sindbad~EG File Manager

Current Path : /proc/2568807/root/usr/local/lib/python3.12/test/__pycache__/
Upload File :
Current File : //proc/2568807/root/usr/local/lib/python3.12/test/__pycache__/test_frame.cpython-312.opt-1.pyc

�

'Μg-8����ddlZddlZddlZddlZddlZddlZddlZddlZddlZ	ddl	Z	ddlmZddl
mZddlmZGd�dej"�ZGd�dej"�ZGd	�d
ej"�ZGd�dej"�Zej,e	dud
�Gd�dej"��Zedk(rej2�yy#e
$rdZ	Y��wxYw)�N)�support)�threading_helper)�assert_python_okc�l�eZdZdZd
d�Zd�Zd�Zd�Zd�Zd�Z	d�Z
d	�Zd
�Ze
jd��Zy)�	ClearTestz"
    Tests for frame.clear().
    c��ddzy�N�r�)�self�x�kwargss   �,/usr/local/lib/python3.12/test/test_frame.py�innerzClearTest.inners	��	�!��c�^�	|jdi|��S#t$r
}|}Yd}~|Sd}~wwxYw)Nr)r�ZeroDivisionError)rr�e�excs    r�outerzClearTest.outers;��	��D�J�J� �� ��
��!�	��C��
��	�s��	,�'�,c�\�|�*|jj�|j}|��)yy)z2
        Clear all frames in a traceback.
        N)�tb_frame�clear�tb_next)r�tbs  r�clear_traceback_framesz ClearTest.clear_traceback_frames#s)���n��K�K�������B��nrc�X�Gd�d�}|�}tj|�}|j|��}~tj�|jd|��|j
|j�tj�|jd|��y)Nc��eZdZy)�&ClearTest.test_clear_locals.<locals>.CN��__name__�
__module__�__qualname__rrr�Cr,���rr$��c)	�weakref�refrr�
gc_collect�assertIsNotr�
__traceback__�assertIs�rr$r'�wrrs     r�test_clear_localszClearTest.test_clear_locals+s���	�	�
�C��
�[�[��^���j�j�1�j�o��
���������r�t�$��#�#�C�$5�$5�6������
�
�d�B�D�!rc�x�Gd�d�}|�}|j|��}~|jj}|j�|j	|j
d�|j	|jd�|j	|jd�|j	|jd�y)Nc��eZdZy)�7ClearTest.test_clear_does_not_clear_specials.<locals>.CNr rrrr$r3;r%rr$r&)	rr,rrr+�f_code�f_locals�
f_builtins�	f_globals)rr$r'r�fs     r�"test_clear_does_not_clear_specialsz,ClearTest.test_clear_does_not_clear_specials:s���	�	�
�C���j�j�1�j�o��
����&�&��	���	�������4�(�������T�*�������t�,�������d�+rc����d���fd�}|�}t|��j��|jj��j	��y)NFc3�J�K�	d���j�d�y#d�wxYw�w)NT)r)�endlyrs��r�gz)ClearTest.test_clear_generator.<locals>.gIs"�����
���
�
�������s�#��#� �#)�next�assertFalse�gi_framer�
assertTrue)rr=�genr<s`  @r�test_clear_generatorzClearTest.test_clear_generatorGsG�����	��c���S�	����������������rc�d�	ddz|jt�5j�ddd�|jt�5jj�ddd�y#t$r }|jj}Yd}~��d}~wwxYw#1swY�nxYw#1swYyxYwr	�rr,r�assertRaises�RuntimeErrorr�f_back)rrr8s   r�test_clear_executingzClearTest.test_clear_executingWs��	)�
�a�C��
�
�|�
,�
�G�G�I�-�
�
�
�|�
,�
�H�H�N�N��-�
,��	!�	)����(�(�A��	)��
,�
,��
,�
,�s.�A.�B�
B&�.	B�7B�B�B#�&B/c����d���fd�}|�}t|�}�j��|j��j��y)NFc3��K�	ddzd�y#t$r�}|jj}�jt�5|j�ddd�n#1swYnxYw�jt�5|jj�ddd�n#1swYnxYw|��Yd}~d�yd}~wwxYw#d�wxYw�w)Nr
rTrE)rr8r<rs  ��rr=z3ClearTest.test_clear_executing_generator.<locals>.ges������

��!�����%�
��O�O�,�,���&�&�|�4��G�G�I�5�4�4���&�&�|�4��H�H�N�N�$�5�4�4�������
����sl�C�
�C�	B<�+B7�A�	B7�A$	� B7�<B �	B7� B)	�%B7�0B?�4C�7B<�<B?�?C�C)r>r?rrA)rr=rBr8r<s`   @r�test_clear_executing_generatorz(ClearTest.test_clear_executing_generatorbsB�����	��c����I�������	���	�����rc�����fd���fd�}gd�}g�|d�|j�|�g�|d�|j�|�y)Nc���tjd�}�j|j|jj
z
�y)Nr
)�sys�	_getframe�append�f_linenor4�co_firstlineno)r8�liness �r�record_linez7ClearTest.test_lineno_with_tracing.<locals>.record_linezs0����
�
�a� �A��L�L����A�H�H�$;�$;�;�<rc�h����|rdtjd�_����y)NTr)rOrP�f_trace)�tracerUs �r�testz0ClearTest.test_lineno_with_tracing.<locals>.test~s&����M��+/��
�
�a� �(��M��Mr)r
��FT)�assertEqual)rrY�expected_linesrTrUs   @@r�test_lineno_with_tracingz"ClearTest.test_lineno_with_tracingysL���	=�	�#�����U�������/����T�
������/rc�Z�tj�5Gd�d�}|�}tj|�}|j	|��}~|jd|��|j
|j�|jd|��ddd�y#1swYyxYw)Nc��eZdZy)�)ClearTest.test_clear_refcycles.<locals>.CNr rrrr$ra�s��rr$r&)	r�
disable_gcr(r)rr+rr,r-r.s     r�test_clear_refcycleszClearTest.test_clear_refcycles�s����
�
�
!�
�
���A����Q��B��*�*�q�*�/�C�����T�2�4�(��'�'��(9�(9�:��M�M�$���%�"�
!�
!�s�BB!�!B*N)r[)r!r"r#�__doc__rrrr0r9rCrIrLr^r�cpython_onlyrcrrrrrsN������
"�,�� 	��.0�(
���&��&rrc�*�eZdZd�Zd�Zd�Zd�Zd�Zy)�FrameAttrsTestc��d�}	|�S#t$rE}|j}g}|r*|j|j�|j}|r�*Yd}~|Sd}~wwxYw)Nc�$��d�d}�fd�}|�S)Nr[�c����dz}ddzd}y�N�r
r�	r��z�tr
s  �rrz8FrameAttrsTest.make_frames.<locals>.outer.<locals>.inner�������E���!���rr��yrr
s  @rrz)FrameAttrsTest.make_frames.<locals>.outer������A��A�
��7�Nr)rr,rQrr)rrrr�framess     r�make_frameszFrameAttrsTest.make_frames�sa��	�	 ��G��
��
!�	 ����B��F���
�
�b�k�k�*��Z�Z�����
��
	 �s��	A�9A�Ac��|j�\}}}|j}|j|jd�tj
�|j
|ddd��|j}|j
|ddd��y)Nrr[rj)r
rt�)r
rp)rwr5�assertIsInstance�pop�types�FunctionTyper\)rr8rr�outer_locals�inner_localss      r�test_localszFrameAttrsTest.test_locals�ss���*�*�,���5�%��~�~�����l�.�.�w�7��9K�9K�L�����Q�Q�'7�8��~�~������Q�Q�'7�8rc���|j�\}}}|j�|j�|j|ji�|j|ji�y�N)rwrr\r5�rr8rrs    rr0z FrameAttrsTest.test_clear_locals�sP���*�*�,���5�%�
���
�
���
��������,��������,rc��|j�\}}}|j|j|j�|j�|j|ji�|j|ji�yr�)rwr5rr\r�s    r�test_locals_clear_localsz'FrameAttrsTest.test_locals_clear_locals�s^���*�*�,���5�%�
���
���
���
�
���
��������,��������,rc��|j�\}}}|jt�5|`ddd�y#1swYyxYwr�)rwrF�AttributeErrorrR)rr8�_s   r�test_f_lineno_del_segfaultz)FrameAttrsTest.test_f_lineno_del_segfault�s5���"�"�$���1�a�
�
�
�~�
.��
�/�
.�
.�s�6�?N)r!r"r#rwr�r0r�r�rrrrgrg�s���&9�-�-�rrgc��eZdZdZd�Zy)�ReprTestz 
    Tests for repr(frame).
    c�*�d�}|jj}	|�|jd�\}}}tjtt��}	|jt|�d|	|dzfz�|jt|�d|	|dzfz�|jt|�d|	|dzfz�y#t$rD}|j}g}|r*|j|j�|j}|r�*Yd}~��d}~wwxYw)	Nc�$��d�d}�fd�}|�S)Nr[rjc����dz}ddzd}yrlrros  �rrz0ReprTest.test_repr.<locals>.outer.<locals>.inner�rrrrrss  @rrz!ReprTest.test_repr.<locals>.outer�rurzshould have raisedz=^<frame at 0x[0-9a-fA-F]+, file %s, line %d, code test_repr>$�z9^<frame at 0x[0-9a-fA-F]+, file %s, line %d, code outer>$ryz9^<frame at 0x[0-9a-fA-F]+, file %s, line %d, code inner>$r[)
�__code__rS�failrr,rQrr�re�escape�repr�__file__�assertRegex)
rr�offsetrrrv�f_this�f_outer�f_inner�	file_reprs
          r�	test_reprzReprTest.test_repr�s
��	����.�.��		,��G�
�I�I�*�+�#)� �����I�I�d�8�n�-�	�����f��Y�%�v��{�3�4�	5�	
����g��U�%�v��z�2�3�	4�	
����g��U�%�v��z�2�3�	4��#!�	 ����B��F���
�
�b�k�k�*��Z�Z�����	 �s�C�	D�9D
�
DN)r!r"r#rdr�rrrr�r��s��� 4rr�c��eZdZd�Zej
d��Zej
ej�d���Z	d�Z
y)�TestIncompleteFrameAreInvisiblec�V�tjdt�d��}td|�y)Nz�
            import gc

            gc.set_threshold(1,1,1)
            class GCHello:
                def __del__(self):
                    print("Destroyed from gc")

            def gen():
                yield

            fd = open(zy)
            l = [fd, GCHello()]
            l.append(l)
            del fd
            del l
            gen()
        z-c)�textwrap�dedentr�r)r�codes  r�test_issue95818z/TestIncompleteFrameAreInvisible.test_issue95818�s2�����$� �l�#	� �
��$	��t�$rc���	�d�}��	fd��d�}tj�}tjdd}tj�}t	j
�}	tj�|�}t|�tj�tjddd�t	j|�tjj��d�	tj�t|�|j|j�	�tj|�|tjddt	j|�|rtj�yy#tj|�|tjddt	j|�|rtj�wwxYw)Nc��y)z^
            Don't actually do anything, just force a frame object to be created.
            Nr)�frame�event�args   rrXzGTestIncompleteFrameAreInvisible.test_sneaky_frame_object.<locals>.traces�rc���tj�jj�tjj��y)z�
            Yo dawg, I heard you like frames, so I'm allocating a frame while
            you're allocating a frame, so you can have a frame while you have a
            frame!
            N)rOrPrH�gc�	callbacks�remove)�phase�info�callback�sneaky_frame_objects  ��rr�zJTestIncompleteFrameAreInvisible.test_sneaky_frame_object.<locals>.callbacks/���#&�-�-�/�"8�"8�"?�"?���L�L����)rc3�K�	d����wr�rrrrr8zCTestIncompleteFrameAreInvisible.test_sneaky_frame_object.<locals>.f#s�������s�	r
r)r��
get_thresholdr��	isenabledrO�gettrace�disabler>�collect�
set_threshold�settracerQ�enabler-r@)
rrXr8�
old_threshold�
old_callbacks�old_enabled�	old_tracer=r�r�s
        @@r�test_sneaky_frame_objectz8TestIncompleteFrameAreInvisible.test_sneaky_frame_objects=���	�
		*�	��(�(�*�
����Q��
��l�l�n���L�L�N�	�"	��J�J�L���A���G�
�J�J�L����Q��1�%�
�L�L����L�L����)�"&���I�I�K���G�
�M�M�!�*�*�&9�:����m�,�+�B�L�L��O��L�L��#���	�	����
���m�,�+�B�L�L��O��L�L��#���	�	���s�CE3�3AGc�N���G�fd�d��G�fd�dtj�}d�|�}|j�|j�|j	����@|j�j|jj��j����?yy)Nc���eZdZ�fd�Zy)�TTestIncompleteFrameAreInvisible.test_sneaky_frame_object_teardown.<locals>.SneakyDelc�.��tj��y)a@
                Stash a reference to the entire stack for walking later.

                It may look crazy, but you'd be surprised how common this is
                when using a test runner (like pytest). The typical recipe is:
                ResourceWarning + -Werror + a custom sys.unraisablehook.
                N�rOrP)rr�s �r�__del__z\TestIncompleteFrameAreInvisible.test_sneaky_frame_object_teardown.<locals>.SneakyDel.__del__Ts���'*�m�m�o�#rN)r!r"r#r�)r�s�r�	SneakyDelr�Ss���	
6rr�c���eZdZdZ�fd�Zy)�WTestIncompleteFrameAreInvisible.test_sneaky_frame_object_teardown.<locals>.SneakyThreadz�
            A separate thread isn't needed to make this code crash, but it does
            make crashes more consistent, since it means sneaky_frame_object is
            backed by freed memory after the thread completes!
            c�����}y)z.Run SneakyDel.__del__ as this frame is popped.Nr)rr)r�s  �r�runz[TestIncompleteFrameAreInvisible.test_sneaky_frame_object_teardown.<locals>.SneakyThread.runfs
����k�rN)r!r"r#rdr�)r�s�r�SneakyThreadr�_s
���
�
"rr�)
�	threading�Thread�start�join�assertIsNotNoner+r4r�r�rH)rr�rqr�r�s   @@r�!test_sneaky_frame_object_teardownzATestIncompleteFrameAreInvisible.test_sneaky_frame_object_teardownOs����
	6�
	6�		"�9�+�+�		"�#���N��	���	�	����	
���0�1�!�-����#�*�*�L�,<�,<�,E�,E�
�#6�"<�"<��	"�-rc� ��Gd�d���fd�}tj�5}tj|�}|j	|j
jt�ddd�|j��y#1swY� xYw)Nc��eZdZdZy)�ZTestIncompleteFrameAreInvisible.test_entry_frames_are_invisible_during_teardown.<locals>.CzA weakref'able class.N)r!r"r#rdrrrr$r�ys��'rr$c�F����}tj|t�S)z>Try to find globals and locals as this frame is being cleared.)r(r)�exec)r)r$s �rr8zZTestIncompleteFrameAreInvisible.test_entry_frames_are_invisible_during_teardown.<locals>.f|s����#�C�
�;�;�s�D�)�)r)	r�catch_unraisable_exception�operator�callr-�
unraisable�exc_type�	TypeError�assertIsNone)rr8�catcher�weakr$s    @r�/test_entry_frames_are_invisible_during_teardownzOTestIncompleteFrameAreInvisible.test_entry_frames_are_invisible_during_teardownxsj���	(�	(�	*��
/�
/�
1�W��=�=��#�D��M�M�'�,�,�5�5�y�A�	2�
	
���$�&�!�2�
1�s�AB�B
N)r!r"r#r�rrer�r�requires_working_threadingr�r�rrrr�r��sV��%�,
���<��<�|
���0��0�0�2�%=�3��%=�N"rr�zneed _testcapic�0�eZdZd�Zd�Zd�Zd�Zd�Zd�Zy)�TestCAPIc�*�tj�Sr�r��rs r�getframezTestCAPI.getframe�s���}�}��rc��|j�}|j|jtj|��|j|jtj|��|j|jtj|��|j|jtj|��yr�)r�r\r5�	_testcapi�frame_getlocalsr-r7�frame_getglobalsr6�frame_getbuiltins�f_lasti�frame_getlasti)rr�s  r�test_frame_getterszTestCAPI.test_frame_getters�s����
�
����������)B�)B�5�)I�J��
�
�e�o�o�y�'A�'A�%�'H�I��
�
�e�&�&�	�(C�(C�E�(J�K�������	�(@�(@��(G�Hrc���tj�}d}|jtj|d�d�|jtj
|d�d�|j
t�5tj|d�ddd�|j
t�5tj
|d�ddd�|j
t�5tj|d�ddd�|j
t�5tj|d�ddd�y#1swY��xYw#1swY�~xYw#1swY�VxYw#1swYyxYw)Nr
r
�xrt�y�{)	rOrPr\r��frame_getvar�frame_getvarstringrF�	NameErrorr�)r�
current_framer
s   r�test_getvarzTestCAPI.test_getvar�s����
�
��
�
������/�/�
�s�C�Q�G�����5�5�m�T�J�A�N�
�
�
�y�
)��"�"�=�#�6�*�
�
�
�y�
)��(�(���=�*��
�
�y�
)��"�"�=�$�7�*�
�
�
�y�
)��"�"�=�#�6�*�
)�*�
)��
)�
)��*�
)��
)�
)�s0�8D4�,E� E�E�4D=�E	�E�E!c#�8K�tj���y�wr�r�r�s r�getgenframezTestCAPI.getgenframe�s�����m�m�o��s�c��|j�}t|�}|j|tj|��yr�)r�r>r-r��frame_getgenerator)rrBr�s   r�test_frame_get_generatorz!TestCAPI.test_frame_get_generator�s2����� ���S�	���
�
�c�9�7�7��>�?rc��d�}tj|jt�t	��}|j|j�y)zzTest that accessing `f_back` does not cause a segmentation fault on
        a frame created with `PyFrame_New` (GH-99110).c��yr�rrrr�dummyz,TestCAPI.test_frame_fback_api.<locals>.dummy�s��rN)r��	frame_newr��globals�localsr�rH)rr�r�s   r�test_frame_fback_apizTestCAPI.test_frame_fback_api�s7��	��#�#�E�N�N�G�I�v�x�H�����%�,�,�'rN)	r!r"r#r�r�r�r�r�rrrrr�r��s"���I�7� �@�
(rr��__main__)r�r�r�rOr�r�r|�unittestr(r��ImportErrorrYr�test.supportr�test.support.script_helperr�TestCaserrgr�r��skipIfr�r!�mainrrr�<module>rs���	��	�
���������)�7�E&��!�!�E&�P2�X�&�&�2�j%4�x� � �%4�NR"�h�&7�&7�R"�h�����d�"�$4�5�+(�x� � �+(�6�+(�Z�z���H�M�M�O���]
���I��s�C�C�C

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