
    Rh                     J    d dl mZ d dlmZ dgZ G d d      Z G d d      Zy)    ref)GenericAliasWeakSetc                       e Zd Zd Zd Zd Zy)_IterationGuardc                 $    t        |      | _        y N)r   weakcontainer)selfr   s     "/usr/lib/python3.12/_weakrefset.py__init__z_IterationGuard.__init__   s     /    c                 `    | j                         }||j                  j                  |        | S r
   )r   
_iteratingadd)r   ws     r   	__enter__z_IterationGuard.__enter__   s,     =LLT"r   c                     | j                         }|1|j                  }|j                  |        |s|j                          y y y r
   )r   r   remove_commit_removals)r   etbr   ss         r   __exit__z_IterationGuard.__exit__   sB     =AHHTN""$  r   N)__name__
__module____qualname__r   r   r    r   r   r   r      s    0%r   r   c                       e Zd Zd!dZd Zd Zd Zd Zd Zd Z	d	 Z
d
 Zd Zd Zd Zd Zd Zd ZeZd Zd Zd ZeZd Zd Zd ZeZd Zd ZeZd Zd Zd Z e Z!d Z"d Z#d Z$e$Z%d Z&d  Z' e(e)      Z*y)"r   Nc                     t               | _        t        |       fd}|| _        g | _        t               | _        || j                  |       y y )Nc                      |       }|D|j                   r|j                  j                  |        y |j                  j	                  |        y y r
   )r   _pending_removalsappenddatadiscard)itemselfrefr   s      r   _removez!WeakSet.__init__.<locals>._remove'   sA    9D??**11$7II%%d+	  r   )setr&   r   r*   r$   r   update)r   r&   r*   s      r   r   zWeakSet.__init__%   sH    E	"%d) 	, !#%KK r   c                     | j                   j                  }| j                  j                  }	 	  |       } ||       # t        $ r Y y w xY wr
   )r$   popr&   r'   
IndexError)r   r.   r'   r(   s       r   r   zWeakSet._commit_removals5   sS    $$(())##u DM   s   ? 	A
Ac              #      K   t        |       5  | j                  D ]  } |       }||  	 d d d        y # 1 sw Y   y xY wwr
   )r   r&   r   itemrefr(   s      r   __iter__zWeakSet.__iter__?   sI     T" 	99 y# J	 	 	s   A88	AAAc                 X    t        | j                        t        | j                        z
  S r
   )lenr&   r$   r   s    r   __len__zWeakSet.__len__H   s     499~D$:$: ;;;r   c                 T    	 t        |      }|| j                  v S # t        $ r Y yw xY w)NF)r   	TypeErrorr&   )r   r(   wrs      r   __contains__zWeakSet.__contains__K   s4    	TB TYY  		s    	''c                 P    | j                   t        |       f| j                         fS r
   )	__class__list__getstate__r6   s    r   
__reduce__zWeakSet.__reduce__R   s"    ~~T
}d.?.?.AAAr   c                     | j                   r| j                          | j                  j                  t	        || j
                               y r
   )r$   r   r&   r   r   r*   r   r(   s     r   r   zWeakSet.addU   s2    !!!!#		c$-.r   c                 p    | j                   r| j                          | j                  j                          y r
   )r$   r   r&   clearr6   s    r   rD   zWeakSet.clearZ   s%    !!!!#		r   c                 $    | j                  |       S r
   r=   r6   s    r   copyzWeakSet.copy_   s    ~~d##r   c                     | j                   r| j                          	 	 | j                  j                         } |       }||S '# t        $ r t	        d      d w xY w)Nzpop from empty WeakSet)r$   r   r&   r.   KeyErrorr1   s      r   r.   zWeakSet.popb   si    !!!!#C))--/ 9D   C78dBCs   A Ac                     | j                   r| j                          | j                  j                  t	        |             y r
   )r$   r   r&   r   r   rB   s     r   r   zWeakSet.removen   s-    !!!!#		T#r   c                     | j                   r| j                          | j                  j                  t	        |             y r
   )r$   r   r&   r'   r   rB   s     r   r'   zWeakSet.discards   s-    !!!!#		#d)$r   c                 l    | j                   r| j                          |D ]  }| j                  |        y r
   )r$   r   r   )r   otherelements      r   r,   zWeakSet.updatex   s2    !!!!# 	GHHW	r   c                 (    | j                  |       | S r
   )r,   r   rM   s     r   __ior__zWeakSet.__ior__~   s    Er   c                 H    | j                         }|j                  |       |S r
   )rG   difference_updater   rM   newsets      r   
differencezWeakSet.difference   s       'r   c                 &    | j                  |       y r
   )__isub__rP   s     r   rS   zWeakSet.difference_update       er   c                     | j                   r| j                          | |u r| j                  j                          | S | j                  j	                  d |D               | S )Nc              3   2   K   | ]  }t        |        y wr
   r   .0r(   s     r   	<genexpr>z#WeakSet.__isub__.<locals>.<genexpr>   s     'DdD	'D   )r$   r   r&   rD   rS   rP   s     r   rX   zWeakSet.__isub__   sR    !!!!#5=IIOO  II'''De'DDr   c                 8      j                   fd|D              S )Nc              3   ,   K   | ]  }|v s|  y wr
   r    r]   r(   r   s     r   r^   z'WeakSet.intersection.<locals>.<genexpr>   s     EtdEs   	rF   rP   s   ` r   intersectionzWeakSet.intersection   s    ~~EuEEEr   c                 &    | j                  |       y r
   )__iand__rP   s     r   intersection_updatezWeakSet.intersection_update   rY   r   c                     | j                   r| j                          | j                  j                  d |D               | S )Nc              3   2   K   | ]  }t        |        y wr
   r   r\   s     r   r^   z#WeakSet.__iand__.<locals>.<genexpr>   s     %BDc$i%Br_   )r$   r   r&   rf   rP   s     r   re   zWeakSet.__iand__   s4    !!!!#		%%%BE%BBr   c                 F    | j                   j                  d |D              S )Nc              3   2   K   | ]  }t        |        y wr
   r   r\   s     r   r^   z#WeakSet.issubset.<locals>.<genexpr>   s     !>#d)!>r_   )r&   issubsetrP   s     r   rk   zWeakSet.issubset   s    yy!!!>!>>>r   c                 N    | j                   t        t        t        |            k  S r
   r&   r+   mapr   rP   s     r   __lt__zWeakSet.__lt__       yy3s3///r   c                 F    | j                   j                  d |D              S )Nc              3   2   K   | ]  }t        |        y wr
   r   r\   s     r   r^   z%WeakSet.issuperset.<locals>.<genexpr>   s     #@$CI#@r_   )r&   
issupersetrP   s     r   rs   zWeakSet.issuperset   s    yy###@%#@@@r   c                 N    | j                   t        t        t        |            kD  S r
   rm   rP   s     r   __gt__zWeakSet.__gt__   rp   r   c                     t        || j                        st        S | j                  t	        t        t        |            k(  S r
   )
isinstancer=   NotImplementedr&   r+   rn   r   rP   s     r   __eq__zWeakSet.__eq__   s0    %0!!yyCC000r   c                 H    | j                         }|j                  |       |S r
   )rG   symmetric_difference_updaterT   s      r   symmetric_differencezWeakSet.symmetric_difference   s     **51r   c                 &    | j                  |       y r
   )__ixor__rP   s     r   r{   z#WeakSet.symmetric_difference_update   rY   r   c                       j                   r j                           |u r j                  j                           S  j                  j	                   fd|D                S )Nc              3   J   K   | ]  }t        |j                          y wr
   )r   r*   rb   s     r   r^   z#WeakSet.__ixor__.<locals>.<genexpr>   s     1\d#dDLL2I1\s    #)r$   r   r&   rD   r{   rP   s   ` r   r~   zWeakSet.__ixor__   sT    !!!!#5=IIOO  II111\V[1\\r   c                 6    | j                  d | |fD              S )Nc              3   .   K   | ]  }|D ]  }|   y wr
   r    )r]   r   r   s      r   r^   z WeakSet.union.<locals>.<genexpr>   s     BAB1aBaBs   rF   rP   s     r   unionzWeakSet.union   s    ~~B$BBBr   c                 <    t        | j                  |            dk(  S )Nr   )r5   rc   rP   s     r   
isdisjointzWeakSet.isdisjoint   s    4$$U+,11r   c                 ,    t        | j                        S r
   )reprr&   r6   s    r   __repr__zWeakSet.__repr__   s    DIIr   r
   )+r   r   r   r   r   r3   r7   r;   r@   r   rD   rG   r.   r   r'   r,   rQ   rV   __sub__rS   rX   rc   __and__rf   re   rk   __le__ro   rs   __ge__ru   ry   r|   __xor__r{   r~   r   __or__r   r   classmethodr   __class_getitem__r    r   r   r   r   $   s     <B/

$
$
%
 GFG?F0AF01
 #GCF2 $L1r   N)_weakrefr   typesr   __all__r   r   r    r   r   <module>r      s*   
  +% %2i2 i2r   