%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /usr/lib/python3.12/test/support/__pycache__/
Upload File :
Create Path :
Current File : //usr/lib/python3.12/test/support/__pycache__/warnings_helper.cpython-312.pyc

�

���f����ddlZddlZddlZddlZddlZddlZd�Zdddd�d�Zd�ZGd�d	e	�Z
ejd
��Zejde
dfd��Zejd
��Zdd�Zejd��Zd�Zy)�Nc��tj�5tjdt��t	j
|�cddd�S#1swYyxYw)z3Import *name* while suppressing DeprecationWarning.�ignore��categoryN)�warnings�catch_warnings�simplefilter�DeprecationWarning�	importlib�
import_module)�names �3/usr/lib/python3.12/test/support/warnings_helper.py�import_deprecatedr	sB��	�	 �	 �	"�-����h�1C�D��&�&�t�,�-�-�-�s�0A�A����lineno�offsetc��ddlm}tjd��5}tjdt
�t
|dd�ddd�|jt�d|�|\}|jt|jt
�|j�|r%|jt|j�|�|j|jd�|j!|j"�|�|j|j"|�tjd��5}tjd	t
�||||||�
�ddd�|j|g�y#1swY��3xYw#1swY�)xYw)Nr)�check_syntax_errorT��record�alwaysz
<testcase>�execr�errorr)�test.supportrrrr	�
SyntaxWarning�compile�assertEqual�len�
assertTrue�
issubclassr�assertRegex�str�message�filename�assertIsNotNoner)�testcase�	statement�errtextrrr�warns�warns        r�check_syntax_warningr-sA��0�	�	 �	 ��	-�1�����h�
�6��	�<��0�1�
����U��Q��.��E�D����
�4�=�=�-�@��
�
�'�����S����.��8��������5����T�[�[�)�
�����T�[�[�&�1�

�	 �	 ��	-�9�����g�}�5��8�Y��"(��	9�9�

�����#�/1�1��$9�9�s�(E6�3(F�6F�Fc����fd�}|S)z�Decorator to suppress warnings.

    Use of context managers to hide warnings make diffs
    more noisy and tools like 'git blame' less useful.
    c�F���tj����fd��}|S)Nc���tj�5tjd����|g|��i|��cddd�S#1swYyxYw)Nrr)rrr	)�self�args�kwargsr�tests   ��r�wrapperz3ignore_warnings.<locals>.decorator.<locals>.wrapper5sF����(�(�*�
3��%�%�h��B��D�2�4�2�6�2�
3�
3�
3�s�#A�A)�	functools�wraps)r4r5rs` �r�	decoratorz"ignore_warnings.<locals>.decorator4s%���	����	�	3�
�	3����)rr8s` r�ignore_warningsr;.s�����r9c�2�eZdZdZd�Zd�Zed��Zd�Zy)�WarningsRecorderzyConvenience wrapper for the warnings list returned on
       entry to the warnings.catch_warnings() context manager.
    c� �||_d|_y)Nr��	_warnings�_last)r1�
warnings_lists  r�__init__zWarningsRecorder.__init__Bs��&�����
r9c���t|j�|jkDrt|jd|�S|tj
jvryt|�d|����)N���z has no attribute )r r@rA�getattrr�WarningMessage�_WARNING_DETAILS�AttributeError)r1�attrs  r�__getattr__zWarningsRecorder.__getattr__FsT���t�~�~�����+��4�>�>�"�-�t�4�4�
�X�,�,�=�=�
=����t�D�E�Er9c�4�|j|jdS�Nr?�r1s rrzWarningsRecorder.warningsMs���~�~�d�j�j�k�*�*r9c�8�t|j�|_yrM)r r@rArNs r�resetzWarningsRecorder.resetQs������(��
r9N)	�__name__�
__module__�__qualname__�__doc__rCrK�propertyrrPr:r9rr=r=>s+����F��+��+�)r9r=c�Z�|jd�}|s
dtff}|�d}t||�S)a�Context manager to silence warnings.

    Accept 2-tuples as positional arguments:
        ("message regexp", WarningCategory)

    Optional argument:
     - if 'quiet' is True, it does not fail if a filter catches nothing
        (default True without argument,
         default False if some filters are defined)

    Without argument, it defaults to:
        check_warnings(("", Warning), quiet=True)
    �quietrT)�get�Warning�_filterwarnings)�filtersr3rWs   r�check_warningsr\Us8��
�J�J�w��E����=�"���=��E��7�E�*�*r9Fc#��K�ddlm}tjd��5}tjd||��d��|r|�ddd�|jg�y#1swY�xYw�w)a�Context manager to check that no warnings are emitted.

    This context manager enables a given warning within its scope
    and checks that no warnings are emitted even with that warning
    enabled.

    If force_gc is True, a garbage collection is attempted before checking
    for warnings. This may help to catch warnings emitted when objects
    are deleted, such as ResourceWarning.

    Other keyword arguments are passed to warnings.filterwarnings().
    r)�
gc_collectTrr)r%rN)rr^rr�filterwarningsr)r(r%r�force_gcr^r+s      r�check_no_warningsramsd����(�	�	 �	 ��	-�������(/�)1�	3�	���L�
�
�����#���s�A,�&A �A,� A)�%A,c#�bK�t|td��5d��ddd�y#1swYyxYw�w)a"Context manager to check that no ResourceWarning is emitted.

    Usage:

        with check_no_resource_warning(self):
            f = open(...)
            ...
            del f

    You must remove the object which may emit ResourceWarning before
    the end of the context manager.
    T)rr`N)ra�ResourceWarning)r(s r�check_no_resource_warningrd�s+����
�8�o��	M��
����s�/�#�	/�,�/c#��K�tjd�}|jjd�}|r|j	�tjd��5}tjdjd�t|���ddd�t�}g}|D]�\}}d}	|ddD]g}|j}
tj|t|
�tj�s�>t!|
j"|�s�Ud}	|j%|��i|	r�z|r�}|j'||j(f���|rt+d	|d
z��|rt+d|d
z��y#1swY��xYw�w)z�Catch the warnings, then check if all the expected
    warnings have been raised and re-raise unexpected warnings.
    If 'quiet' is True, only re-raise the unexpected warnings.
    ��__warningregistry__TrrrNFzunhandled warning %srz)filter (%r, %s) did not catch any warning)�sys�	_getframe�	f_globalsrX�clearrr�modulesr	r=�listr%�re�matchr$�Ir"�	__class__�remove�appendrQ�AssertionError)r[rW�frame�registry�w�reraise�missing�msg�cat�seen�warnings           rrZrZ�sW����
�M�M�!��E����"�"�#8�9�H������	�	 �	 ��	-�"��	���J��,�,�X�6��q�!�!�"��1�g�G��G��0���S������	"�A��i�i�G�����c�'�l�B�D�D�1��7�,�,�c�2������q�!�
	"��E��N�N�C����.�/�0���3�g�a�j�@�A�A���H�$�Q�Z�(�)�	)��/"�"�s8�AE1�0E%�A!E1�-E1�E1�E1�AE1�%E.�*E1c#�K�tjdd}	d��|tjddy#|tjddwxYw�wrM)rr[)�old_filterss r�save_restore_warnings_filtersr��s>�����"�"�1�%�K�*�
�)�������k������s�A�/�A�A�Ac�<�tjdtd��y)Nz�This is used in test_support test to ensure support.ignore_deprecations_from() works as expected. You should not be seeing this.r)�
stacklevel)rr,r
r:r9r�_warn_about_deprecationr��s���M�M�	*�	��r9)r)F)�
contextlibr6rrnrhrrr-r;�objectr=�contextmanagerr\rYrardrZr�r�r:r9r�<module>r�s������	�
��-�$�#$�T�$�<
� )�v�)�.���+��+�.���(*�W�u�$��$�0������"$)�N���*��*�r9

Zerion Mini Shell 1.0