
    h                        d dl Z d dlZd dlZd dlZd dlZd dlZd ZdddddZd Z G d d	e	          Z
e j        d
             Ze j        dedfd            Ze j        d             ZddZe j        d             Zd ZdS )    Nc                     t          j                    5  t          j        dt                     t	          j        |           cddd           S # 1 swxY w Y   dS )z3Import *name* while suppressing DeprecationWarning.ignorecategoryN)warningscatch_warningssimplefilterDeprecationWarning	importlibimport_module)names    3/usr/lib/python3.11/test/support/warnings_helper.pyimport_deprecatedr   	   s    		 	"	" - -h1CDDDD&t,,- - - - - - - - - - - - - - - - - -s   /AAA    linenooffsetc                J   ddl m} t          j        d          5 }t          j        dt
                     t          |dd           d d d            n# 1 swxY w Y   |                     t          |          d|           |\  }| 	                    t          |j        t
                    |j                   |r(|                     t          |j                  |           |                     |j        d           |                     |j                   ||                     |j        |           t          j        d          5 }t          j        d	t
                      || ||||
           d d d            n# 1 swxY w Y   |                     |g            d S )Nr   )check_syntax_errorTrecordalwaysz
<testcase>execr   errorr   )test.supportr   r   r   r	   SyntaxWarningcompileassertEquallen
assertTrue
issubclassr   assertRegexstrmessagefilenameassertIsNotNoner   )testcase	statementerrtextr   r   r   warnswarns           r   check_syntax_warningr-      s%    0/////		 	-	-	- 1h666	<0001 1 1 1 1 1 1 1 1 1 1 1 1 1 1 UQ...ED
4=-@@' ' ' 9S..888555T[)))T[&111
 
	 	-	-	- 9g}5558Y"(	9 	9 	9 	99 9 9 9 9 9 9 9 9 9 9 9 9 9 9
 #####s#   ,AAA+FF	Fc                       fd}|S )zDecorator to suppress deprecation warnings.

    Use of context managers to hide warnings make diffs
    more noisy and tools like 'git blame' less useful.
    c                 J     t          j                    fd            }|S )Nc                     t          j                    5  t          j        d            | g|R i |cd d d            S # 1 swxY w Y   d S )Nr   r   )r   r   r	   )selfargskwargsr   tests      r   wrapperz3ignore_warnings.<locals>.decorator.<locals>.wrapper5   s    (** 3 3%hBBBBtD242226223 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3s   "AAA)	functoolswraps)r4   r5   r   s   ` r   	decoratorz"ignore_warnings.<locals>.decorator4   s>    				3 	3 	3 	3 	3 
		3      )r   r8   s   ` r   ignore_warningsr;   .   s$         r9   c                   :    e Zd ZdZd Zd Zed             Zd ZdS )WarningsRecorderzyConvenience wrapper for the warnings list returned on
       entry to the warnings.catch_warnings() context manager.
    c                 "    || _         d| _        d S )Nr   	_warnings_last)r1   warnings_lists     r   __init__zWarningsRecorder.__init__B   s    &


r9   c                     t          | j                  | j        k    rt          | j        d         |          S |t          j        j        v rd S t          | d|          )Nz has no attribute )r    r@   rA   getattrr   WarningMessage_WARNING_DETAILSAttributeError)r1   attrs     r   __getattr__zWarningsRecorder.__getattr__F   s_    t~++4>"-t444X,===4ttDEEEr9   c                 *    | j         | j        d          S Nr?   r1   s    r   r   zWarningsRecorder.warningsM   s    ~djkk**r9   c                 8    t          | j                  | _        d S rM   )r    r@   rA   rN   s    r   resetzWarningsRecorder.resetQ   s    ((


r9   N)	__name__
__module____qualname____doc__rC   rK   propertyr   rP   r:   r9   r   r=   r=   >   si           F F F + + X+) ) ) ) )r9   r=   c                  l    |                     d          }| sdt          ff} |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)
    quietr   NT)getWarning_filterwarnings)filtersr3   rW   s      r   check_warningsr\   U   sC     JJwE ="=E7E***r9   Fc              #      K   ddl m} t          j        d          5 }t          j        d||           dV  |r
 |             ddd           n# 1 swxY w Y   |                     |g            dS )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_collectTr   r   )r%   r   N)r   r^   r   r   filterwarningsr   )r(   r%   r   force_gcr^   r+   s         r   check_no_warningsra   m   s       ('''''		 	-	-	- (/)1	3 	3 	3 	3 	 	JLLL               #####s   (AAAc              #   r   K   t          | t          d          5  dV  ddd           dS # 1 swxY w Y   dS )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)r   r`   N)ra   ResourceWarning)r(   s    r   check_no_resource_warningrd      s       
8o	M	M	M                   s   ,00c              #     K   t          j        d          }|j                            d          }|r|                                 t          j        d          5 }t           j        d                             d           t          |          V  ddd           n# 1 swxY w Y   t          |          }g }| D ]\  }}d}	|dd         D ]b}|j        }
t          j        |t          |
          t          j                  r,t!          |
j        |          rd}	|                    |           c|	s|s|                    ||j        f           |rt+          d	|d
         z            |rt+          d|d
         z            dS )zCatch 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__Tr   r   r   NFzunhandled warning %sr   z)filter (%r, %s) did not catch any warning)sys	_getframe	f_globalsrX   clearr   r   modulesr	   r=   listr%   rematchr$   Ir"   	__class__removeappendrQ   AssertionError)r[   rW   frameregistrywreraisemissingmsgcatseenwarnings              r   rZ   rZ      s      M!E""#899H 		 	-	-	- " 	J,,X666q!!!!!" " " " " " " " " " " " " " " 1ggGG 0 0S 	" 	"AiGc'llBD11 "7,c22"q!!! 	0E 	0NNC./// B3gaj@AAA )H$QZ( ) ) 	)) )s   7BB#&B#c               #      K   t           j        d d          } 	 d V  | t           j        d d <   d S # | t           j        d d <   w xY wrM   )r   r[   )old_filterss    r   save_restore_warnings_filtersr      sY      "111%K*)k))))s	   / Ac                  >    t          j        dt          d           d S )NzThis is used in test_support test to ensure support.ignore_deprecations_from() works as expected. You should not be seeing this.r   )
stacklevel)r   r,   r
   r:   r9   r   _warn_about_deprecationr      s2    M	* 	     r9   )r   )F)
contextlibr6   r   rn   rh   r   r   r-   r;   objectr=   contextmanagerr\   rY   ra   rd   rZ   r   r   r:   r9   r   <module>r      se               				 



 - - -$#$T$ $ $ $ $<   ) ) ) ) )v ) ) ). + + +. (*Wu $ $ $ $0   "$) $) $) $)N * * *    r9   