
    z%i                        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Nignore)category)warningscatch_warningssimplefilterDeprecationWarning	importlibimport_module)names    P/home/uftp/.pyenv/versions/3.12.0/lib/python3.12/test/support/warnings_helper.pyimport_deprecatedr   	   sE    =		 	 	" -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 )Nc                 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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                   0    e Zd Z	 d Zd Zed        Zd Zy)WarningsRecorderc                      || _         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__rC   rK   propertyr   rP   r:   r9   r   r=   r=   >   s+    F + +)r9   r=   c                  \    	 |j                  d      }| sdt        ff} |d}t        | |      S )Nquietr   T)getWarning_filterwarnings)filtersr3   rV   s      r   check_warningsr[   U   s=     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)Nr   )
gc_collectTr   r   )r%   r   )r   r]   r   r   filterwarningsr   )r(   r%   r   force_gcr]   r+   s         r   check_no_warningsr`   m   si      (		 	 	- (/)1	3 	L # s   A-&A!A-!A*&A-c              #   d   K   	 t        | t        d      5  d  d d d        y # 1 sw Y   y xY ww)NT)r   r_   )r`   ResourceWarning)r(   s    r   check_no_resource_warningrc      s0      
8o	M   s   0$	0-0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)N   __warningregistry__Tr   r   r   Fzunhandled warning %sr   z)filter (%r, %s) did not catch any warning)sys	_getframe	f_globalsrW   clearr   r   modulesr	   r=   listr%   rematchr$   Ir"   	__class__removeappendrQ   AssertionError)rZ   rV   frameregistrywreraisemissingmsgcatseenwarnings              r   rY   rY      s\     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E20E&A!E2.E2E2E2 AE2&E/+E2c               #      K   t         j                  d d  } 	 d  | t         j                  d d  y # | t         j                  d d  w xY wwrM   )r   rZ   )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   rm   rg   r   r   r-   r;   objectr=   contextmanagerr[   rX   r`   rc   rY   r   r   r:   r9   r   <module>r      s       	 
 -$#$T$< )v ). + +. (*Wu $ $0  "$)N * *r9   