
    daf                        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y)    Nc                     t        j                         5  t        j                  dt               t	        j
                  |       cddd       S # 1 sw Y   yxY w)z3Import *name* while suppressing DeprecationWarning.ignorecategoryN)warningscatch_warningssimplefilterDeprecationWarning	importlibimport_module)names    7/root/Python-3.12.4/Lib/test/support/warnings_helper.pyimport_deprecatedr   	   sB    		 	 	" -h1CD&&t,- - -s   0AA    linenooffsetc                   ddl m} t        j                  d      5 }t        j                  dt
               t        |dd       d d d        | j                  t              d|       |\  }| j                  t        |j                  t
              |j                         |r%| j                  t        |j                        |       | j                  |j                  d       | j!                  |j"                         || j                  |j"                  |       t        j                  d      5 }t        j                  d	t
                || ||||
       d d d        | j                  |g        y # 1 sw Y   3xY w# 1 sw Y   )xY w)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-      sA    0		 	 	- 1h6	<01 UQ.ED
4==-@'S.85T[[)T[[&1
 
	 	 	- 9g}58Y"(	99
 #/1 1$9 9s   (E63(F6F Fc                       fd}|S )zDecorator to suppress warnings.

    Use of context managers to hide warnings make diffs
    more noisy and tools like 'git blame' less useful.
    c                 F     t        j                          fd       }|S )Nc                     t        j                         5  t        j                  d        | g|i |cd d d        S # 1 sw Y   y xY w)Nr   r   )r   r   r	   )selfargskwargsr   tests      r   wrapperz3ignore_warnings.<locals>.decorator.<locals>.wrapper5   sF    ((* 3%%hBD242623 3 3s   #AA)	functoolswraps)r4   r5   r   s   ` r   	decoratorz"ignore_warnings.<locals>.decorator4   s%    			3 
	3      )r   r8   s   ` r   ignore_warningsr;   .   s     r9   c                   2    e Zd ZdZd Zd Zed        Zd Zy)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__zWarningsRecorder.__init__B   s    &
r9   c                     t        | j                        | j                  kD  rt        | j                  d   |      S |t        j
                  j                  v ry t        | d|      )Nz has no attribute )r    r@   rA   getattrr   WarningMessage_WARNING_DETAILSAttributeError)r1   attrs     r   __getattr__zWarningsRecorder.__getattr__F   sT    t~~+4>>"-t44X,,===tDEEr9   c                 4    | j                   | j                  d  S Nr?   r1   s    r   r   zWarningsRecorder.warningsM   s    ~~djjk**r9   c                 8    t        | j                        | _        y 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=   >   s+    F + +)r9   r=   c                  Z    |j                  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   T)getWarning_filterwarnings)filtersr3   rW   s      r   check_warningsr\   U   s8     JJwE="=E7E**r9   Fc              #      K   ddl m} t        j                  d      5 }t        j                  d||       d |r |        ddd       | j                  g        y# 1 sw Y   xY w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_collectTr   r   )r%   r   N)r   r^   r   r   filterwarningsr   )r(   r%   r   force_gcr^   r+   s         r   check_no_warningsra   m   sd      (		 	 	- (/)1	3 	L # s   A,&A A, A)%A,c              #   b   K   t        | t        d      5  d ddd       y# 1 sw Y   yxY w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)r   r`   N)ra   ResourceWarning)r(   s    r   check_no_resource_warningrd      s+      
8o	M   s   /#	/,/c              #     K   t        j                  d      }|j                  j                  d      }|r|j	                          t        j                  d      5 }t         j                  d   j                  d       t        |       ddd       t              }g }| D ]  \  }}d}	|dd D ]g  }|j                  }
t        j                  |t        |
      t        j                        s>t!        |
j"                  |      sUd}	|j%                  |       i |	rz|r}|j'                  ||j(                  f        |rt+        d	|d
   z        |rt+        d|d
   z        y# 1 sw Y   xY ww)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      sW     MM!E""#89H		 	 	- " 	J,,X6q!!" 1gGG 0S 	"AiiGc'lBDD17,,c2q!	" ENNC./0 3gaj@AAH$QZ( ) 	) /" "s8   AE10E%A!E1-E1E1E1AE1%E.*E1c               #      K   t         j                  d d  } 	 d  | t         j                  d d  y # | t         j                  d d  w xY wwrM   )r   r[   )old_filterss    r   save_restore_warnings_filtersr      s>     ""1%K*)ks   A/ AAAc                  <    t        j                  dt        d       y )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      s    MM	* 	r9   )r   )F)
contextlibr6   r   rn   rh   r   r   r-   r;   objectr=   contextmanagerr\   rY   ra   rd   rZ   r   r   r:   r9   r   <module>r      s       	 
 -$#$T$< )v ). + +. (*Wu $ $0  "$)N * *r9   