Hacked By AnonymousFox

Current Path : /opt/alt/python39/lib64/python3.9/__pycache__/
Upload File :
Current File : //opt/alt/python39/lib64/python3.9/__pycache__/weakref.cpython-39.pyc

a

���e8T�@s�dZddlmZmZmZmZmZmZmZm	Z	ddl
mZmZddl
Z
ddlZddlZeefZgd�Ze
j�e�e
j�e�Gdd�de�ZGdd	�d	e
j�ZGd
d�de�ZGdd
�d
e
j�ZGdd�d�ZdS)z|Weak reference support for Python.

This module is an implementation of PEP 205:

https://www.python.org/dev/peps/pep-0205/
�)�getweakrefcount�getweakrefs�ref�proxy�CallableProxyType�	ProxyType�
ReferenceType�_remove_dead_weakref)�WeakSet�_IterationGuardN)
rrrr�WeakKeyDictionaryrrr�
ProxyTypes�WeakValueDictionaryr
�
WeakMethod�finalizecsDeZdZdZdZddd�Z�fdd�Zdd	�Zd
d�Ze	j
Z
�ZS)
rz�
    A custom `weakref.ref` subclass which simulates a weak reference to
    a bound method, working around the lifetime problem of bound methods.
    )�	_func_ref�
_meth_type�_alive�__weakref__Ncs|z|j}|j}Wn&ty6td�t|���d�Yn0��fdd�}t�|||�}t||�|_t|�|_	d|_
t|��|S)Nz)argument should be a bound method, not {}cs&��}|jr"d|_�dur"�|�dS�NF)r)�arg�self��callbackZself_wr��,/opt/alt/python39/lib64/python3.9/weakref.py�_cb6s
zWeakMethod.__new__.<locals>._cbT)�__self__�__func__�AttributeError�	TypeError�format�typer�__new__rrr)�clsZmethr�obj�funcrrrrrr#/s 
��
zWeakMethod.__new__cs2t���}|��}|dus"|dur&dS|�||�S�N)�super�__call__rr)rr%r&��	__class__rrr)Es

zWeakMethod.__call__cCs:t|t�r6|jr|js||uSt�||�o4|j|jkStSr')�
isinstancerrr�__eq__r�NotImplemented�r�otherrrrr-Ls

zWeakMethod.__eq__cCs:t|t�r6|jr|js||uSt�||�p4|j|jkStSr')r,rrr�__ne__rr.r/rrrr1Ss

zWeakMethod.__ne__)N)�__name__�
__module__�__qualname__�__doc__�	__slots__r#r)r-r1r�__hash__�
__classcell__rrr*rr's
rc@s�eZdZdZd2dd�Zefdd�Zdd�Zd	d
�Zdd�Z	d
d�Z
dd�Zdd�Zdd�Z
e
Zdd�Zd3dd�Zdd�Zdd�ZeZdd�Zd d!�Zd"d#�Zd$d%�Zd4d&d'�Zd5d(d)�Zd*d+�Zd,d-�Zd.d/�Zd0d1�ZdS)6rz�Mapping class that references values weakly.

    Entries in the dictionary will be discarded when no strong
    reference to the value exists anymore
    rcKsBt|�tfdd�}||_g|_t�|_i|_|j|fi|��dS)NcSs6|�}|dur2|jr$|j�|j�n||j|j�dSr')�
_iterating�_pending_removals�append�key�data)�wr�selfref�_atomic_removalrrrr�removejs
z,WeakValueDictionary.__init__.<locals>.remove)rr	�_remover:�setr9r=�update)rr0�kwrArrr�__init__is	zWeakValueDictionary.__init__cCs>|jj}|j}z
|�}Wnty,YdS0|||�qdSr')r:�popr=�
IndexError)rr@rG�dr<rrr�_commit_removalszs
z$WeakValueDictionary._commit_removalscCs4|jr|��|j|�}|dur,t|��n|SdSr'�r:rJr=�KeyError�rr<�orrr�__getitem__�s
zWeakValueDictionary.__getitem__cCs|jr|��|j|=dSr')r:rJr=�rr<rrr�__delitem__�szWeakValueDictionary.__delitem__cCs|jr|��t|j�Sr')r:rJ�lenr=�rrrr�__len__�szWeakValueDictionary.__len__cCs<|jr|��z|j|�}Wnty2YdS0|duSrrKrMrrr�__contains__�sz WeakValueDictionary.__contains__cCsd|jjt|�fS�Nz<%s at %#x>�r+r2�idrSrrr�__repr__�szWeakValueDictionary.__repr__cCs&|jr|��t||j|�|j|<dSr')r:rJ�KeyedRefrBr=�rr<�valuerrr�__setitem__�szWeakValueDictionary.__setitem__cCsj|jr|��t�}t|��:|j��D]\}}|�}|dur(|||<q(Wd�n1s\0Y|Sr')r:rJrrr=�items)r�newr<r>rNrrr�copy�s
(zWeakValueDictionary.copycCs~ddlm}|jr|��|��}t|��@|j��D]$\}}|�}|dur6|||||�<q6Wd�n1sp0Y|S�Nr)�deepcopy)r`rbr:rJr+rr=r^)r�memorbr_r<r>rNrrr�__deepcopy__�s
.z WeakValueDictionary.__deepcopy__NcCsN|jr|��z|j|}Wnty2|YS0|�}|durF|S|SdSr'rK)rr<�defaultr>rNrrr�get�s
zWeakValueDictionary.getccsf|jr|��t|��<|j��D] \}}|�}|dur"||fVq"Wd�n1sX0YdSr'�r:rJrr=r^)r�kr>�vrrrr^�s
zWeakValueDictionary.itemsccs^|jr|��t|��4|j��D]\}}|�dur"|Vq"Wd�n1sP0YdSr'rg)rrhr>rrr�keys�s

zWeakValueDictionary.keysccsJ|jr|��t|�� |j��EdHWd�n1s<0YdS)a�Return an iterator that yields the weak references to the values.

        The references are not guaranteed to be 'live' at the time
        they are used, so the result of calling the references needs
        to be checked before being used.  This can be used to avoid
        creating references that will cause the garbage collector to
        keep the values around longer than needed.

        N�r:rJrr=�valuesrSrrr�
itervaluerefs�s

z!WeakValueDictionary.itervaluerefsccs^|jr|��t|��4|j��D]}|�}|dur"|Vq"Wd�n1sP0YdSr'rk�rr>r%rrrrl�s
zWeakValueDictionary.valuescCs8|jr|��|j��\}}|�}|dur||fSqdSr')r:rJr=�popitem)rr<r>rNrrrro�szWeakValueDictionary.popitemcGs^|jr|��z|j�|��}Wnty6d}Yn0|durV|rL|dSt|��n|SdS)Nr)r:rJr=rGrL)rr<�argsrNrrrrGs

zWeakValueDictionary.popcCs^z|j|�}Wnty&d}Yn0|durV|jr>|��t||j|�|j|<|S|SdSr')r=rLr:rJrZrB)rr<rerNrrr�
setdefaults
zWeakValueDictionary.setdefaultcKsz|jr|��|j}|durRt|d�s.t|�}|��D]\}}t||j|�||<q6|��D]\}}t||j|�||<qZdS�Nr^)r:rJr=�hasattr�dictr^rZrB)rr0�kwargsrIr<rNrrrrD"s
zWeakValueDictionary.updatecCs|jr|��t|j���S)a~Return a list of weak references to the values.

        The references are not guaranteed to be 'live' at the time
        they are used, so the result of calling the references needs
        to be checked before being used.  This can be used to avoid
        creating references that will cause the garbage collector to
        keep the values around longer than needed.

        )r:rJ�listr=rlrSrrr�	valuerefs.s
zWeakValueDictionary.valuerefscCs|�|�|Sr'�rDr/rrr�__ior__<s
zWeakValueDictionary.__ior__cCs&t|tj�r"|��}|�|�|StSr'�r,�_collections_abc�Mappingr`rDr.�rr0�crrr�__or__@s

zWeakValueDictionary.__or__cCs0t|tj�r,|��}|�|�|�|�|StSr'�r,r{r|r+rDr.r}rrr�__ror__Gs

zWeakValueDictionary.__ror__)r)N)N)N)r2r3r4r5rFr	rJrOrQrTrUrYr]r`�__copy__rdrfr^rj�__iter__rmrlrorGrqrDrwryrr�rrrrr]s4
		
			

rcs,eZdZdZdZdd�Z�fdd�Z�ZS)rZa[Specialized reference that includes a key corresponding to the value.

    This is used in the WeakValueDictionary to avoid having to create
    a function object for each key stored in the mapping.  A shared
    callback object can use the 'key' attribute of a KeyedRef instead
    of getting a reference to the key from an enclosing scope.

    �r<cCst�|||�}||_|Sr')rr#r<)r"�obrr<rrrrr#\szKeyedRef.__new__cst��||�dSr')r(rF)rr�rr<r*rrrFaszKeyedRef.__init__)r2r3r4r5r6r#rFr8rrr*rrZPs	rZc@s�eZdZdZd1dd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	dd�Z
dd�Zdd�ZeZ
dd�Zd2dd�Zdd�Zdd�Zdd�ZeZdd �Zd!d"�Zd#d$�Zd%d&�Zd3d'd(�Zd4d)d*�Zd+d,�Zd-d.�Zd/d0�ZdS)5ra� Mapping class that references keys weakly.

    Entries in the dictionary will be discarded when there is no
    longer a strong reference to the key. This can be used to
    associate additional data with an object owned by other parts of
    an application without adding attributes to those objects. This
    can be especially useful with objects that override attribute
    accesses.
    NcCsFi|_t|�fdd�}||_g|_t�|_d|_|durB|�|�dS)NcSsF|�}|durB|jr"|j�|�n z|j|=Wnty@Yn0dSr')r9r:r;r=rL)rhr?rrrrrArsz*WeakKeyDictionary.__init__.<locals>.removeF)r=rrBr:rCr9�
_dirty_lenrD)rrtrArrrrFps
zWeakKeyDictionary.__init__cCsR|jj}|j}z
|�}Wnty,YdS0z
||=WqtyJYq0qdSr')r:rGr=rHrL)rrGrIr<rrrrJ�s

z"WeakKeyDictionary._commit_removalscs&|j��fdd�|jD�|_d|_dS)Ncsg|]}|�vr|�qSrr)�.0rh�rIrr�
<listcomp>��z5WeakKeyDictionary._scrub_removals.<locals>.<listcomp>F)r=r:r�rSrr�r�_scrub_removals�sz!WeakKeyDictionary._scrub_removalscCsd|_|jt|�=dS�NT)r�r=rrPrrrrQ�szWeakKeyDictionary.__delitem__cCs|jt|�Sr')r=rrPrrrrO�szWeakKeyDictionary.__getitem__cCs(|jr|jr|��t|j�t|j�Sr')r�r:r�rRr=rSrrrrT�szWeakKeyDictionary.__len__cCsd|jjt|�fSrVrWrSrrrrY�szWeakKeyDictionary.__repr__cCs||jt||j�<dSr')r=rrBr[rrrr]�szWeakKeyDictionary.__setitem__cCs\t�}t|��:|j��D]\}}|�}|dur|||<qWd�n1sN0Y|Sr')rrr=r^)rr_r<r\rNrrrr`�s
(zWeakKeyDictionary.copycCspddlm}|��}t|��@|j��D]$\}}|�}|dur(|||�||<q(Wd�n1sb0Y|Sra)r`rbr+rr=r^)rrcrbr_r<r\rNrrrrd�s
.zWeakKeyDictionary.__deepcopy__cCs|j�t|�|�Sr')r=rfr�rr<rerrrrf�szWeakKeyDictionary.getcCs,zt|�}Wnty YdS0||jvSr)rr r=)rr<r>rrrrU�s
zWeakKeyDictionary.__contains__ccsXt|��<|j��D] \}}|�}|dur||fVqWd�n1sJ0YdSr'�rr=r^)rr>r\r<rrrr^�s

zWeakKeyDictionary.itemsccsLt|��0|jD]}|�}|dur|VqWd�n1s>0YdSr')rr=rnrrrrj�s


zWeakKeyDictionary.keysccsPt|��4|j��D]\}}|�dur|VqWd�n1sB0YdSr'r�)rr>r\rrrrl�s

zWeakKeyDictionary.valuescCs
t|j�S)azReturn a list of weak references to the keys.

        The references are not guaranteed to be 'live' at the time
        they are used, so the result of calling the references needs
        to be checked before being used.  This can be used to avoid
        creating references that will cause the garbage collector to
        keep the keys around longer than needed.

        )rvr=rSrrr�keyrefs�s
zWeakKeyDictionary.keyrefscCs0d|_|j��\}}|�}|dur||fSqdSr�)r�r=ro)rr<r\rNrrrro�s
zWeakKeyDictionary.popitemcGsd|_|jjt|�g|�R�Sr�)r�r=rGr)rr<rprrrrG�szWeakKeyDictionary.popcCs|j�t||j�|�Sr')r=rqrrBr�rrrrq�szWeakKeyDictionary.setdefaultcKs\|j}|durFt|d�s$ti�|�}|��D]\}}||t||j�<q,t|�rX|�|�dSrr)r=rsr"r^rrBrRrD)rrtrurIr<r\rrrrD�s
zWeakKeyDictionary.updatecCs|�|�|Sr'rxr/rrrry	s
zWeakKeyDictionary.__ior__cCs&t|tj�r"|��}|�|�|StSr'rzr}rrrr
s

zWeakKeyDictionary.__or__cCs0t|tj�r,|��}|�|�|�|�|StSr'r�r}rrrr�s

zWeakKeyDictionary.__ror__)N)N)N)N)r2r3r4r5rFrJr�rQrOrTrYr]r`r�rdrfrUr^rjr�rlr�rorGrqrDryrr�rrrrres4

	




rc@s�eZdZdZdZiZdZe��Z	dZ
dZGdd�d�Zdd�Z
dd	d
�Zdd�Zd
d�Zedd��Zedd��Zejdd��Zdd�Zedd��Zedd��ZdS)raClass for finalization of weakrefable objects

    finalize(obj, func, *args, **kwargs) returns a callable finalizer
    object which will be called when obj is garbage collected. The
    first time the finalizer is called it evaluates func(*arg, **kwargs)
    and returns the result. After this the finalizer is dead, and
    calling it just returns None.

    When the program exits any remaining finalizers for which the
    atexit attribute is true will be run in reverse order of creation.
    By default atexit is true.
    rFc@seZdZdZdS)zfinalize._Info)�weakrefr&rpru�atexit�indexN)r2r3r4r6rrrr�_Info6sr�cOsp|js ddl}|�|j�dt_|��}t||�|_||_||_	|pFd|_
d|_t|j�|_
||j|<dt_dS)NrT)�_registered_with_atexitr��register�	_exitfuncrr�rr�r&rpru�next�_index_iterr��	_registry�_dirty)rr%r&rprur��inforrrrF9s

zfinalize.__init__NcCs4|j�|d�}|r0|js0|j|ji|jp*i��SdS)zZIf alive then mark as dead and return func(*args, **kwargs);
        otherwise return NoneN)r�rG�	_shutdownr&rpru)r�_r�rrrr)Js
zfinalize.__call__cCsH|j�|�}|o|��}|durD|j�|d�rD||j|j|jp@ifSdS)z^If alive then mark as dead and return (obj, func, args, kwargs);
        otherwise return NoneN)r�rfr�rGr&rpru�rr�r%rrr�detachQszfinalize.detachcCs:|j�|�}|o|��}|dur6||j|j|jp2ifSdS)zMIf alive then return (obj, func, args, kwargs);
        otherwise return NoneN)r�rfr�r&rprur�rrr�peekYsz
finalize.peekcCs
||jvS)zWhether finalizer is alive)r�rSrrr�aliveaszfinalize.alivecCs|j�|�}t|�o|jS)z*Whether finalizer should be called at exit�r�rf�boolr�)rr�rrrr�fszfinalize.atexitcCs|j�|�}|rt|�|_dSr'r�)rr\r�rrrr�lscCs^|j�|�}|o|��}|dur6dt|�jt|�fSdt|�jt|�t|�jt|�fSdS)Nz<%s object at %#x; dead>z!<%s object at %#x; for %r at %#x>)r�rfr�r"r2rXr�rrrrYrs�zfinalize.__repr__cCs2dd�|j��D�}|jdd�d�dd�|D�S)NcSsg|]\}}|jr||f�qSr)r��r��f�irrrr�~r�z-finalize._select_for_exit.<locals>.<listcomp>cSs
|djS)N�)r�)�itemrrr�<lambda>r�z+finalize._select_for_exit.<locals>.<lambda>r�cSsg|]\}}|�qSrrr�rrrr��r�)r�r^�sort)r$�Lrrr�_select_for_exit{szfinalize._select_for_exitcCs�d}z�|jr�ddl}|��r(d}|��d}|dus:tjrH|��}dt_|sNq�|��}z
|�Wn ty�t	j
t	���Yn0||jvs,J�q,Wdt_|r�|�
�ndt_|r�|�
�0dS)NFrT)r��gcZ	isenabledZdisablerr�r�rG�	Exception�sys�
excepthook�exc_infor�Zenable)r$Zreenable_gcr�Zpendingr�rrrr��s2

�zfinalize._exitfunc)N)r2r3r4r5r6r�r��	itertools�countr�r�r�r�rFr)r�r��propertyr�r��setterrY�classmethodr�r�rrrrrs.



	
r)r5�_weakrefrrrrrrrr	Z_weakrefsetr
rr{r�r�r
�__all__�Setr��
MutableSetr�MutableMappingrrZrrrrrr�<module>s (
6t9

Hacked By AnonymousFox1.0, Coded By AnonymousFox