a
    ©ˆc<  ã                   @   s(   d Z ddlZddlZG dd„ deƒZdS )aÊ   An implementation of weak references that works for bound methods.

This code is based on the code in the Python Cookbook, but you can call `ref`
for objects that are *not* bound methods too, in which case it just returns a
standard `weakref.ref`.

Weak references to bound methods are cached so that `ref(x) is ref(x)` as for
standard weakrefs, and the `ref` class defined here is therefore intended to be
used as a drop-in replacement for 'weakref.ref'.

é    Nc                   @   s"   e Zd ZdZe ¡ Zddd„ZdS )Úrefaz  An implementation of weak references that works for bound methods and
    caches them.

    If ``object`` is a bound method, returns a ``weakref.WeakMethod`` for that
    method. This ensures that the method is kept alive for the lifetime of the
    object that it's bound to.

    For any other ``object``, a normal ``weakref.ref`` is returned.

    .. deprecated:: 5.0.0

    Nc                 C   sn   t jdtdd� t|dd ƒd ur^| j |ji ¡}| |j¡}|d u rZt	 
||¡}|||j< |S t	 ||¡S d S )NzRsafeweakref.ref is deprecated, and will be removed in a future version of Envisageé   )ÚmessageÚcategoryÚ
stacklevelÚ__self__)ÚwarningsÚwarnÚDeprecationWarningÚgetattrÚ_cacheÚ
setdefaultr   ÚgetÚ__func__ÚweakrefÚ
WeakMethodr   )ÚclsÚobjÚcallbackZ
func_cacheÚself© r   úW/home/yuhw/wc/wire-cell-python/wcpy/lib/python3.9/site-packages/envisage/safeweakref.pyÚ__new__*   s    ú	
zref.__new__)N)Ú__name__Ú
__module__Ú__qualname__Ú__doc__r   ÚWeakKeyDictionaryr   r   r   r   r   r   r      s   r   )r   r   r   Úobjectr   r   r   r   r   Ú<module>
   s   