
    F\h                        S SK r S SKrS SKrS SKrS SKrS SKrS rSSSS.S jjrS r " S S	\	5      r
\ R                  S
 5       r\ R                  S\S4S j5       r\ R                  S 5       rSS jr\ R                  S 5       rS rg)    Nc                     [         R                  " 5          [         R                  " S[        S9  [        R
                  " U 5      sSSS5        $ ! , (       d  f       g= f)z3Import *name* while suppressing DeprecationWarning.ignorecategoryN)warningscatch_warningssimplefilterDeprecationWarning	importlibimport_module)names    3/usr/lib/python3.13/test/support/warnings_helper.pyimport_deprecatedr   	   s9    		 	 	"h1CD&&t, 
#	"	"s   /A
A    linenooffsetc          	      0   SSK Jn  [        R                  " SS9 n[        R                  " S[
        5        [        USS5        S S S 5        U R                  [        W5      SU5        Uu  nU R                  [        UR                  [
        5      UR                  5        U(       a%  U R                  [        UR                  5      U5        U R                  UR                  S5        U R!                  UR"                  5        Ub  U R                  UR"                  U5        [        R                  " SS9 n[        R                  " S	[
        5        U" XUX4S
9  S S S 5        U R                  U/ 5        g ! , (       d  f       GN8= f! , (       d  f       N3= f)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		 	 	-h6	<0 
. UQ.ED
4==-@'S.85T[[)T[[&1
 
	 	 	-g}58"(	9 
.
 #/ 
.	-$ 
.	-s   )E56$F5
F
Fc                    ^  U 4S jnU$ )zDecorator to suppress warnings.

Use of context managers to hide warnings make diffs
more noisy and tools like 'git blame' less useful.
c                 J   >^  [         R                  " T 5      UU 4S j5       nU$ )Nc                    > [         R                  " 5          [         R                  " STS9  T" U /UQ70 UD6sS S S 5        $ ! , (       d  f       g = f)Nr   r   )r   r   r	   )selfargskwargsr   tests      r   wrapper3ignore_warnings.<locals>.decorator.<locals>.wrapper5   s=    ((*%%hBD24262 +**s   !A
A)	functoolswraps)r4   r5   r   s   ` r   	decorator"ignore_warnings.<locals>.decorator4   s%    			3 
	3      )r   r9   s   ` r   ignore_warningsr=   .   s     r;   c                   :    \ rS rSrSrS rS r\S 5       rS r	Sr
g)	WarningsRecorder>   znConvenience wrapper for the warnings list returned on
entry to the warnings.catch_warnings() context manager.
c                     Xl         SU l        g )Nr   	_warnings_last)r1   warnings_lists     r   __init__WarningsRecorder.__init__B   s    &
r;   c                     [        U R                  5      U R                  :  a  [        U R                  S   U5      $ U[        R
                  R                  ;   a  g [        U < SU< 35      e)Nz has no attribute )r    rC   rD   getattrr   WarningMessage_WARNING_DETAILSAttributeError)r1   attrs     r   __getattr__WarningsRecorder.__getattr__F   sT    t~~+4>>"-t44X,,===tDEEr;   c                 4    U R                   U R                  S  $ NrB   r1   s    r   r   WarningsRecorder.warningsM   s    ~~djjk**r;   c                 8    [        U R                  5      U l        g rR   )r    rC   rD   rS   s    r   resetWarningsRecorder.resetQ   s    (
r;   )rD   rC   N)__name__
__module____qualname____firstlineno____doc__rF   rO   propertyr   rV   __static_attributes__r<   r;   r   r?   r?   >   s+    F + +)r;   r?   c                  d    UR                  S5      nU (       d  S[        44n Uc  Sn[        X5      $ )at  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   r`   s      r   check_warningsre   U   s6     JJwE="=E7**r;   Fc              #      #    SSK Jn  [        R                  " SS9 n[        R                  " SUUS9  Sv   U(       a  U" 5         SSS5        U R                  W/ 5        g! , (       d  f       N!= f7f)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   rg   r   r   filterwarningsr   )r(   r%   r   force_gcrg   r+   s         r   check_no_warningsrj   m   s\      (		 	 	-(/)1	3 	L 
. # 
.	-s   A2)A!A2!
A/+A2c              #   f   #    [        U [        SS9   Sv   SSS5        g! , (       d  f       g= f7f)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   ri   N)rj   ResourceWarning)r(   s    r   check_no_resource_warningrm      s"      
8o	M 
N	M	Ms   1 	1
.1c              #   D  #    [         R                  " S5      nUR                  R                  S5      nU(       a  UR	                  5         [
        R                  " SS9 n[         R                  S   R                  S5        [        U5      v   SSS5        [        W5      n/ nU  H  u  pxSn	USS  Hu  nUR                  n
[        R                  " U[        U
5      [        R                  5      (       d  ME  [!        U
R"                  U5      (       d  Mb  Sn	UR%                  U5        Mw     U	(       a  M  U(       a  M  UR'                  XxR(                  45        M     U(       a  [+        S	US
   -  5      eU(       a  [+        SUS
   -  5      eg! , (       d  f       GN= f7f)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_globalsra   clearr   r   modulesr	   r?   listr%   rematchr$   Ir"   	__class__removeappendrX   AssertionError)rd   r`   frameregistrywreraisemissingmsgcatseenwarnings              r   rc   rc      sK     MM!E""#89H		 	 	- 	J,,X6q!! 
. 1gGGAiiGc'lBDD117,,c22q!  tEENNC./  3gaj@AAH$QZ( ) 	) / 
.	-s8   AF 0FA$F 7F F 4F =AF 
FF c               #      #    [         R                  S S  n  S v   U [         R                  S S & g ! U [         R                  S S & f = f7frR   )r   rd   )old_filterss    r   save_restore_warnings_filtersr      s=     ""1%K*)ks   A/ AAAc                  8    [         R                  " S[        SS9  g )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<   r;   r   _warn_about_deprecationr      s    MM	* 	r;   )r   )F)
contextlibr7   r   rw   rq   r   r   r-   r=   objectr?   contextmanagerre   rb   rj   rm   rc   r   r   r<   r;   r   <module>r      s       	 
 -$#$T$< )v ). + +. (*Wu $ $0  "$)N * *r;   