%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /snap/core20/current/lib/python3.8/__pycache__/
Upload File :
Create Path :
Current File : //snap/core20/current/lib/python3.8/__pycache__/weakref.cpython-38.pyc

U

k�]e�S�
@s�dZddlmZmZmZmZmZmZmZm	Z	ddl
mZmZddl
Z
ddlZddlZeefZddddd	d
ddd
ddddg
ZGdd�de�ZGdd�de
j�ZGdd�de�ZGdd	�d	e
j�ZGdd�d�ZdS)z{Weak reference support for Python.

This module is an implementation of PEP 205:

http://www.python.org/dev/peps/pep-0205/
�)�getweakrefcount�getweakrefs�ref�proxy�CallableProxyType�	ProxyType�
ReferenceType�_remove_dead_weakref)�WeakSet�_IterationGuardNrrrr�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(tk
r8td�t|���d�YnX��fdd�}t�|||�}t||�|_t|�|_	d|_
t|��|S)Nz)argument should be a bound method, not {}cs&��}|jr"d|_�dk	r"�|�dS�NF)r)�arg�self��callbackZself_wr��/usr/lib/python3.8/weakref.py�_cb3s
zWeakMethod.__new__.<locals>._cbT)�__self__�__func__�AttributeError�	TypeError�format�typer�__new__rrr)�clsZmethr�obj�funcrrrrrr#,s 
��
zWeakMethod.__new__cs2t���}|��}|dks"|dkr&dS|�||�S�N)�super�__call__rr)rr%r&��	__class__rrr)Bs

zWeakMethod.__call__cCs:t|t�r6|jr|js||kSt�||�o4|j|jkSdSr)�
isinstancerrr�__eq__r�r�otherrrrr-Is

zWeakMethod.__eq__cCs:t|t�r6|jr|js||k	St�||�p4|j|jkSdS�NT)r,rrr�__ne__rr.rrrr1Ps

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

    Entries in the dictionary will be discarded when no strong
    reference to the value exists anymore
    rcKs>t|�tfdd�}||_g|_t�|_i|_|j|f|�dS)NcSs6|�}|dk	r2|jr$|j�|j�n||j|j�dSr')�
_iterating�_pending_removals�append�key�data)�wr�selfrefZ_atomic_removalrrrr�removegs
z,WeakValueDictionary.__init__.<locals>.remove)rr	�_remover:�setr9r=�update)rr/�kwr@rrr�__init__fs	zWeakValueDictionary.__init__cCs(|j}|j}|r$|��}t||�qdSr')r:r=�popr	)r�l�dr<rrr�_commit_removalsws
z$WeakValueDictionary._commit_removalscCs4|jr|��|j|�}|dkr,t|��n|SdSr'�r:rIr=�KeyError�rr<�orrr�__getitem__�s
zWeakValueDictionary.__getitem__cCs|jr|��|j|=dSr')r:rIr=�rr<rrr�__delitem__�szWeakValueDictionary.__delitem__cCs|jr|��t|j�Sr')r:rI�lenr=�rrrr�__len__�szWeakValueDictionary.__len__cCs>|jr|��z|j|�}Wntk
r4YdSX|dk	SrrJrLrrr�__contains__�sz WeakValueDictionary.__contains__cCsd|jjt|�fS�Nz<%s at %#x>�r+r2�idrRrrr�__repr__�szWeakValueDictionary.__repr__cCs&|jr|��t||j|�|j|<dSr')r:rI�KeyedRefrAr=�rr<�valuerrr�__setitem__�szWeakValueDictionary.__setitem__c	CsV|jr|��t�}t|��0|j��D]\}}|�}|dk	r(|||<q(W5QRX|Sr')r:rIrrr=�items)r�newr<r>rMrrr�copy�s
zWeakValueDictionary.copyc	Csjddlm}|jr|��|��}t|��6|j��D]$\}}|�}|dk	r6|||||�<q6W5QRX|S�Nr)�deepcopy)r_rar:rIr+rr=r])r�memorar^r<r>rMrrr�__deepcopy__�s
z WeakValueDictionary.__deepcopy__NcCsP|jr|��z|j|}Wntk
r4|YSX|�}|dkrH|S|SdSr'rJ)rr<�defaultr>rMrrr�get�s
zWeakValueDictionary.getc	csR|jr|��t|��2|j��D] \}}|�}|dk	r"||fVq"W5QRXdSr'�r:rIrr=r])r�kr>�vrrrr]�s
zWeakValueDictionary.itemsc	csJ|jr|��t|��*|j��D]\}}|�dk	r"|Vq"W5QRXdSr'rf)rrgr>rrr�keys�s

zWeakValueDictionary.keysc	cs6|jr|��t|��|j��EdHW5QRXdS)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:rIrr=�valuesrRrrr�
itervaluerefs�s

z!WeakValueDictionary.itervaluerefsc	csJ|jr|��t|��*|j��D]}|�}|dk	r"|Vq"W5QRXdSr'rj�rr>r%rrrrk�s
zWeakValueDictionary.valuescCs8|jr|��|j��\}}|�}|dk	r||fSqdSr')r:rIr=�popitem)rr<r>rMrrrrn�szWeakValueDictionary.popitemcGs`|jr|��z|j�|��}Wntk
r8d}YnX|dkrX|rN|dSt|��n|SdS)Nr)r:rIr=rFrK)rr<�argsrMrrrrFs

zWeakValueDictionary.popcCs`z|j|�}Wntk
r(d}YnX|dkrX|jr@|��t||j|�|j|<|S|SdSr')r=rKr:rIrYrA)rr<rdrMrrr�
setdefaults
zWeakValueDictionary.setdefaultcKsz|jr|��|j}|dk	rRt|d�s.t|�}|��D]\}}t||j|�||<q6|��D]\}}t||j|�||<qZdS�Nr])r:rIr=�hasattr�dictr]rYrA)rr/�kwargsrHr<rMrrrrCs
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:rI�listr=rkrRrrr�	valuerefs(s
zWeakValueDictionary.valuerefs)r)N)N)N)r2r3r4r5rErIrNrPrSrTrXr\r_�__copy__rcrer]ri�__iter__rlrkrnrFrprCrvrrrrrZs.
			
			

cs,eZdZdZdZdd�Z�fdd�Z�ZS)rYa[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#CszKeyedRef.__new__cst��||�dSr')r(rE)rrzrr<r*rrrEHszKeyedRef.__init__)r2r3r4r5r6r#rEr8rrr*rrY7s	rYc@s�eZdZdZd+dd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	dd�Z
dd�Zdd�ZeZ
dd�Zd,dd�Zdd�Zdd�Zdd�ZeZdd �Zd!d"�Zd#d$�Zd%d&�Zd-d'd(�Zd.d)d*�ZdS)/r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|_|dk	rB|�|�dS)NcSs.|�}|dk	r*|jr"|j�|�n|j|=dSr')r9r:r;r=)rgr?rrrrr@Ys
z*WeakKeyDictionary.__init__.<locals>.removeF)r=rrAr:rBr9�
_dirty_lenrC)rrsr@rrrrEWszWeakKeyDictionary.__init__cCs:|j}|j}|r6z||��=Wqtk
r2YqXqdSr')r:r=rFrK)rrGrHrrrrIhsz"WeakKeyDictionary._commit_removalscs&|j��fdd�|jD�|_d|_dS)Ncsg|]}|�kr|�qSrr)�.0rg�rHrr�
<listcomp>wsz5WeakKeyDictionary._scrub_removals.<locals>.<listcomp>F)r=r:r{rRrr}r�_scrub_removalsusz!WeakKeyDictionary._scrub_removalscCsd|_|jt|�=dSr0)r{r=rrOrrrrPzszWeakKeyDictionary.__delitem__cCs|jt|�Sr')r=rrOrrrrN~szWeakKeyDictionary.__getitem__cCs(|jr|jr|��t|j�t|j�Sr')r{r:rrQr=rRrrrrS�szWeakKeyDictionary.__len__cCsd|jjt|�fSrUrVrRrrrrX�szWeakKeyDictionary.__repr__cCs||jt||j�<dSr')r=rrArZrrrr\�szWeakKeyDictionary.__setitem__c	CsHt�}t|��0|j��D]\}}|�}|dk	r|||<qW5QRX|Sr')rrr=r])rr^r<r[rMrrrr_�s
zWeakKeyDictionary.copyc	Cs\ddlm}|��}t|��6|j��D]$\}}|�}|dk	r(|||�||<q(W5QRX|Sr`)r_rar+rr=r])rrbrar^r<r[rMrrrrc�s
zWeakKeyDictionary.__deepcopy__cCs|j�t|�|�Sr')r=rer�rr<rdrrrre�szWeakKeyDictionary.getcCs.zt|�}Wntk
r"YdSX||jkSr)rr r=)rr<r>rrrrT�s
zWeakKeyDictionary.__contains__c	csDt|��2|j��D] \}}|�}|dk	r||fVqW5QRXdSr'�rr=r])rr>r[r<rrrr]�s

zWeakKeyDictionary.itemsc	cs8t|��&|jD]}|�}|dk	r|VqW5QRXdSr')rr=rmrrrri�s


zWeakKeyDictionary.keysc	cs<t|��*|j��D]\}}|�dk	r|VqW5QRXdSr'r�)rr>r[rrrrk�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.

        )rur=rRrrr�keyrefs�s
zWeakKeyDictionary.keyrefscCs0d|_|j��\}}|�}|dk	r||fSqdSr0)r{r=rn)rr<r[rMrrrrn�s
zWeakKeyDictionary.popitemcGsd|_|jjt|�f|��Sr0)r{r=rFr)rr<rorrrrF�szWeakKeyDictionary.popcCs|j�t||j�|�Sr')r=rprrAr�rrrrp�szWeakKeyDictionary.setdefaultcKs\|j}|dk	rFt|d�s$ti�|�}|��D]\}}||t||j�<q,t|�rX|�|�dSrq)r=rrr"r]rrArQrC)rrsrtrHr<r[rrrrC�s
zWeakKeyDictionary.update)N)N)N)N)r2r3r4r5rErIrrPrNrSrXr\r_rwrcrerTr]rirxrkr�rnrFrprCrrrrrLs.


	


c@s�eZdZdZdZiZdZe��Z	dZ
dZGdd�d�Zdd�Z
de
_dd
d�Zdd
�Zdd�Zedd��Zedd��Zejdd��Zdd�Zedd��Zedd��Zd	S)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&rort�atexit�indexN)r2r3r4r6rrrr�_Infosr�cOs>t|�dkr|^}}}}n�|s(td��n�d|krDtdt|�d��|�d�}t|�dkr~|^}}}ddl}|jdtdd	�nFd
|kr�tdt|�d��|�d
�}|^}}ddl}|jdtdd	�t|�}|js�ddl}|�	|j
�dt_|��}t
||�|_||_||_|�pd|_d|_t|j�|_||j|<dt_dS)
N�z<descriptor '__init__' of 'finalize' object needs an argumentr&z9finalize expected at least 2 positional arguments, got %d��rz0Passing 'func' as keyword argument is deprecated)�
stacklevelr%z/Passing 'obj' as keyword argument is deprecatedT)rQr rF�warnings�warn�DeprecationWarning�tuple�_registered_with_atexitr��register�	_exitfuncrr�rr�r&rort�next�_index_iterr��	_registry�_dirty)rortrr%r&r�r��inforrrrEsR

�

�
�
�
zfinalize.__init__z&($self, obj, func, /, *args, **kwargs)NcCs0|j�|d�}|r,|js,|j|j|jp(i�SdS)zZIf alive then mark as dead and return func(*args, **kwargs);
        otherwise return NoneN)r�rF�	_shutdownr&rort)r�_r�rrrr)1s
zfinalize.__call__cCsH|j�|�}|o|��}|dk	rD|j�|d�rD||j|j|jp@ifSdS)z^If alive then mark as dead and return (obj, func, args, kwargs);
        otherwise return NoneN)r�rer�rFr&rort�rr�r%rrr�detach8szfinalize.detachcCs:|j�|�}|o|��}|dk	r6||j|j|jp2ifSdS)zMIf alive then return (obj, func, args, kwargs);
        otherwise return NoneN)r�rer�r&rortr�rrr�peek@sz
finalize.peekcCs
||jkS)zWhether finalizer is alive)r�rRrrr�aliveHszfinalize.alivecCs|j�|�}t|�o|jS)z*Whether finalizer should be called at exit�r�re�boolr�)rr�rrrr�Mszfinalize.atexitcCs|j�|�}|rt|�|_dSr'r�)rr[r�rrrr�SscCs^|j�|�}|o|��}|dkr6dt|�jt|�fSdt|�jt|�t|�jt|�fSdS)Nz<%s object at %#x; dead>z!<%s object at %#x; for %r at %#x>)r�rer�r"r2rWr�rrrrXYs�zfinalize.__repr__cCs2dd�|j��D�}|jdd�d�dd�|D�S)NcSsg|]\}}|jr||f�qSr)r��r|�f�irrrr~esz-finalize._select_for_exit.<locals>.<listcomp>cSs
|djS)Nr�)r�)�itemrrr�<lambda>f�z+finalize._select_for_exit.<locals>.<lambda>rycSsg|]\}}|�qSrrr�rrrr~gs)r�r]�sort)r$�Lrrr�_select_for_exitbszfinalize._select_for_exitcCs�d}z�|jr�ddl}|��r(d}|��d}|dks:tjrH|��}dt_|sNq�|�	�}z
|�Wn"t
k
r�tjt�
��YnX||jks,t�q,W5dt_|r�|��XdS)NFTr)rr�Zenabler��gcZ	isenabledZdisabler�r�rF�	Exception�sys�
excepthook�exc_info�AssertionError)r$Zreenable_gcr�Zpendingr�rrrr�is,
zfinalize._exitfunc)N)r2r3r4r5r6r�r��	itertools�countr�r�r�r�rE�__text_signature__r)r�r��propertyr�r��setterrX�classmethodr�r�rrrrr�s0*



	
)r5�_weakrefrrrrrrrr	Z_weakrefsetr
r�_collections_abcr�r�r
�__all__r�MutableMappingrrYrrrrrr�<module>s0(
�6^

Zerion Mini Shell 1.0