Ë
    ý]ueˆ#  ã                   óŒ   — d Z ddlZddlZddlZddlZ ej
                  d«      Z ej
                  d«      Zdd„Z G d„ d«      Z	y)	z-Refactored 'safe reference from dispatcher.pyé    NÚ__self__Ú__func__c                 ó  — 	 t        | «      }|�2t        | d«      st        | d«      sJ d| ›d�«       ‚t        | |¬«      }|S y# t        $ r; t	        |«      rt        j                  | |«      cY S t        j                  | «      cY S w xY w)aÖ  Return a *safe* weak reference to a callable target.

    - ``target``: The object to be weakly referenced, if it's a bound
      method reference, will create a BoundMethodWeakref, otherwise
      creates a simple weakref.

    - ``on_delete``: If provided, will have a hard reference stored to
      the callable to be called after the safe reference goes out of
      scope with the reference object, (either a weakref or a
      BoundMethodWeakref) as argument.
    NÚim_funcr   zsafe_ref target z@ has im_self, but no im_func, don't know how to create reference)ÚtargetÚ	on_delete)Úget_selfÚhasattrÚBoundMethodWeakrefÚAttributeErrorÚcallableÚweakrefÚref)r   r   Úim_selfÚ	references       ú2/usr/lib/python3/dist-packages/blinker/_saferef.pyÚsafe_refr   .   sž   € ðÜ˜6Ó"ˆð Ðô ˜6 9Ô-´¸ÀÔ1Lð Ø" 6 *ð -5ð 5óÐLô +°&ÀIÔNˆIØÐð øô ò 'Ü�IÔÜ—;‘;˜v yÓ1Ò1ä—;‘;˜vÓ&Ò&ð	'ús   ‚A Á*BÁ.BÂBc                   ó€   ‡ — e Zd ZdZ ej
                  «       Zd
ˆ fd„	Zd
d„Ze	d„ «       Z
d„ ZeZd„ Zd„ Zd„ Zd	„ Zˆ xZS )r   a‰  'Safe' and reusable weak references to instance methods.

    BoundMethodWeakref objects provide a mechanism for referencing a
    bound method without requiring that the method object itself
    (which is normally a transient object) is kept alive.  Instead,
    the BoundMethodWeakref object keeps weak references to both the
    object and the function which together define the instance method.

    Attributes:

    - ``key``: The identity key for the reference, calculated by the
      class's calculate_key method applied to the target instance method.

    - ``deletion_methods``: Sequence of callable objects taking single
      argument, a reference to this object which will be called when
      *either* the target object or target function is garbage
      collected (i.e. when this object becomes invalid).  These are
      specified as the on_delete parameters of safe_ref calls.

    - ``weak_self``: Weak reference to the target object.

    - ``weak_func``: Weak reference to the target function.

    Class Attributes:

    - ``_all_instances``: Class attribute pointing to all live
      BoundMethodWeakref objects indexed by the class's
      calculate_key(target) method applied to the target objects.
      This weak value dictionary is used to short-circuit creation so
      that multiple references to the same (object, function) pair
      produce the same BoundMethodWeakref instance.
    c                 ó  •— | j                  |«      }| j                  j                  |«      }|�|j                  j	                  |«       |S t
        ‰| �  | «      }|| j                  |<    |j                  ||g|¢­i |¤Ž |S )aô  Create new instance or return current instance.

        Basically this method of construction allows us to
        short-circuit creation of references to already-referenced
        instance methods.  The key corresponding to the target is
        calculated, and if there is already an existing reference,
        that is returned, with its deletion_methods attribute updated.
        Otherwise the new instance is created and registered in the
        table of already-referenced methods.
        )Úcalculate_keyÚ_all_instancesÚgetÚdeletion_methodsÚappendÚsuperÚ__new__Ú__init__)	Úclsr   r   Ú	argumentsÚnamedÚkeyÚcurrentÚbaseÚ	__class__s	           €r   r   zBoundMethodWeakref.__new__q   s‡   ø€ ð ×Ñ Ó'ˆØ×$Ñ$×(Ñ(¨Ó-ˆØÐØ×$Ñ$×+Ñ+¨IÔ6ØˆNä‘7‘? 3Ó'ˆDØ&*ˆC×Ñ˜sÑ#ØˆD�M‰M˜& )ÐA¨iÒA¸5ÒAØˆKó    c                 ó6  — | fd„}|g| _         | j                  |«      | _        t        |«      }t	        |«      }t        j                  ||«      | _        t        j                  ||«      | _        t        |«      | _
        t        |j                  «      | _        y)aƒ  Return a weak-reference-like instance for a bound method.

        - ``target``: The instance-method target for the weak reference,
          must have im_self and im_func attributes and be
          reconstructable via the following, which is true of built-in
          instance methods::

            target.im_func.__get__( target.im_self )

        - ``on_delete``: Optional callback which will be called when
          this weak reference ceases to be valid (i.e. either the
          object or the function is garbage collected).  Should take a
          single argument, which will be passed a pointer to this
          object.
        c                 ó–  — |j                   dd }|j                   dd…= 	 |j                  j                  |j                  = |D ]  }	 t        |«      r ||«       Œ y# t        $ r Y Œ'w xY w# t        $ rS 	 t        j                  «        n:# t        $ r. t        j                  «       d   }t        d|› d|› d|› �«       Y nw xY wY Œ„w xY w)z=Set self.isDead to True when method or instance is destroyed.Né   zException during saferef z cleanup function z: )r   r$   r   r!   ÚKeyErrorr   Ú	ExceptionÚ	tracebackÚ	print_excr   ÚsysÚexc_infoÚprint)ÚweakÚselfÚmethodsÚfunctionÚes        r   Úremovez+BoundMethodWeakref.__init__.<locals>.remove˜   sÚ   € à×+Ñ+©AÐ.ˆGØ×%Ñ%¢aÐ(ðØ—N‘N×1Ñ1°$·(±(Ð;ð $ò �ðÜ Ô)Ù  œøñøô ò Ùðûô !ò ðÜ!×+Ñ+Õ-øÜ)ò ÜŸL™L›N¨1Ñ-˜ÜØ7¸°vð >0Ø08¨z¸¸A¸3ð@öðüðúsG    !A ÁA,Á	A)Á(A)Á,	CÁ6BÂ
CÂ4CÂ?CÃCÃCÃCN)r   r   r!   r	   Úget_funcr   r   Ú	weak_selfÚ	weak_funcÚstrÚ	self_nameÚ__name__Ú	func_name)r1   r   r   r5   r   r   s         r   r   zBoundMethodWeakref.__init__‡   s   € ð" #ó 	ð, "+ ˆÔØ×%Ñ% fÓ-ˆŒÜ˜6Ó"ˆÜ˜6Ó"ˆÜ Ÿ™ W¨fÓ5ˆŒÜ Ÿ™ W¨fÓ5ˆŒÜ˜W›ˆŒÜ˜W×-Ñ-Ó.ˆ�r%   c                 óR   — t        t        |«      «      t        t        |«      «      fS )z°Calculate the reference key for this reference.

        Currently this is a two-tuple of the id()'s of the target
        object and the target function respectively.
        )Úidr	   r6   )r   r   s     r   r   z BoundMethodWeakref.calculate_key·   s#   € ô ”8˜FÓ#Ó$¤b¬°&Ó)9Ó&:Ð;Ð;r%   c                 óx   — dj                  | j                  j                  | j                  | j                  «      S )z-Give a friendly representation of the object.z	{}({}.{}))Úformatr$   r;   r:   r<   ©r1   s    r   Ú__str__zBoundMethodWeakref.__str__À   s0   € à×!Ñ!Ø�N‰N×#Ñ#Ø�N‰NØ�N‰Nó
ð 	
r%   c                 óD   — t        | j                  | j                  f«      S ©N)Úhashr:   r!   rA   s    r   Ú__hash__zBoundMethodWeakref.__hash__Ê   s   € Ü�T—^‘^ T§X¡XÐ.Ó/Ð/r%   c                 ó   —  | «       duS )z'Whether we are still a valid reference.N© rA   s    r   Ú__nonzero__zBoundMethodWeakref.__nonzero__Í   s   € á‹v˜TÐ!Ð!r%   c                 óÔ   — t        || j                  «      s)t        j                  | j                  t	        |«      «      S t        j                  | j
                  |j
                  «      S )zCompare with another reference.)Ú
isinstancer$   ÚoperatorÚeqÚtyper!   )r1   Úothers     r   Ú__eq__zBoundMethodWeakref.__eq__Ñ   sB   € ä˜% §¡Ô0Ü—;‘;˜tŸ~™~¬t°E«{Ó;Ð;Ü�{‰{˜4Ÿ8™8 U§Y¡YÓ/Ð/r%   c                 ón   — | j                  «       }|�#| j                  «       }|�|j                  |«      S y)a?  Return a strong reference to the bound method.

        If the target cannot be retrieved, then will return None,
        otherwise returns a bound instance method for our object and
        function.

        Note: You may call this method any number of times, as it does
        not invalidate the reference.
        N)r7   r8   Ú__get__)r1   r   r3   s      r   Ú__call__zBoundMethodWeakref.__call__×   s<   € ð —‘Ó!ˆØÐØ—~‘~Ó'ˆHØÐ#Ø×'Ñ'¨Ó/Ð/Ør%   rD   )r;   Ú
__module__Ú__qualname__Ú__doc__r   ÚWeakValueDictionaryr   r   r   Úclassmethodr   rB   Ú__repr__rF   rI   rP   rS   Ú__classcell__)r$   s   @r   r   r   M   sZ   ø„ ñðB 1�W×0Ñ0Ó2€Nõó,./ð` ñ<ó ð<ò
ð €Hò0ò"ò0ör%   r   rD   )
rV   rL   r-   r+   r   Ú
attrgetterr	   r6   r   r   rH   r%   r   ú<module>r\      sN   ðñF 4Û Û 
Û Û ð ˆ8×Ñ˜zÓ*€Øˆ8×Ñ˜zÓ*€ó÷>Yò Yr%   