§
     ¶c$  ã                   ó
  — d Z ddlZddlZddlZddlZ	 e n# e$ r d„ ZY nw xY wej        dk     r! ej        d¦  «        Z	 ej        d¦  «        Z
n  ej        d¦  «        Z	 ej        d¦  «        Z
dd	„Z G d
„ de¦  «        ZdS )z-Refactored 'safe reference from dispatcher.pyé    Nc                 ó"   — t          | d¦  «        S )NÚ__call__)Úhasattr)Úobjects    ú2/usr/lib/python3/dist-packages/blinker/_saferef.pyÚcallabler   .   s   € Ý�v˜zÑ*Ô*Ð*ó    )é   Úim_selfÚim_funcÚ__self__Ú__func__c                 ó>  — 	 t          | ¦  «        }|�@t          | d¦  «        st          | d¦  «        sJ d| z  ¦   «         ‚t          | |¬¦  «        }|S dS # 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.
    Nr   r   zRsafe_ref target %r has im_self, but no im_func, don't know how to create reference)ÚtargetÚ	on_delete)Úget_selfr   ÚBoundMethodWeakrefÚAttributeErrorr   ÚweakrefÚref)r   r   r   Ú	references       r   Úsafe_refr   :   sß   € ðÝ˜6Ñ"Ô"ˆð Ðõ ˜6 9Ñ-Ô-ð ?µ¸ÀÑ1LÔ1Lð ?ð ?ð5Ø7=ñ>ñ?ô ?ð ?õ +°&ÀIÐNÑNÔNˆIØÐð Ðøõ ð 'ð 'ð 'Ý�IÑÔð 	'Ý”;˜v yÑ1Ô1Ð1Ð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d„ Z	 e
e	¦  «        Z	d„ Ze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.
    Nc                 ó*  •— |                       |¦  «        }| j                             |¦  «        }|�|j                             |¦  «         |S t          t          | ¦  «                             | ¦  «        }|| j        |<    |j        ||g|¢R 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Úsuperr   Ú__new__Ú__init__)	Úclsr   r   Ú	argumentsÚnamedÚkeyÚcurrentÚbaseÚ	__class__s	           €r   r!   zBoundMethodWeakref.__new__|   s¤   ø€ ð ×Ò Ñ'Ô'ˆØÔ$×(Ò(¨Ñ-Ô-ˆØÐØÔ$×+Ò+¨IÑ6Ô6Ð6ØˆNåÕ+¨SÑ1Ô1×9Ò9¸#Ñ>Ô>ˆDØ&*ˆCÔ˜sÑ#ØˆDŒM˜& )ÐA¨iÐAÐAÐA¸5ÐAÐAÐAØˆKr	   c                 óR  — | fd„}|g| _         |                      |¦  «        | _        t          |¦  «        }t	          |¦  «        }t          j        ||¦  «        | _        t          j        ||¦  «        | _        t          |¦  «        | _
        t          |j        ¦  «        | _        dS )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        = n# t          $ r Y nw xY w|D ]ƒ}	 t          |¦  «        r ||¦  «         Œ# t          $ rY 	 t          j        ¦   «          nA# t          $ r4 t          j        ¦   «         d         }t          d|›d|›d|›�¦  «         Y nw xY wY Œ€w xY wdS )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¨A¨AÔ.ˆGØÔ% a a aÐ(ðØ”NÔ1°$´(Ð;Ð;øÝð ð ð Ø�ðøøøà#ð 
Pð 
P�ð	PÝ Ñ)Ô)ð 'Ø ˜ ™œ˜øøÝ ð Pð Pð PðPÝ!Ô+Ñ-Ô-Ð-Ð-øÝ)ð Pð Pð PÝœL™NœN¨1Ô-˜Ý˜Ø<@¸D¸DÀ(À(À(ÈAÈAð Oñ Pô Pð Pð Pð PðPøøøøøðPøøøð	
Pð 
PsB   ›. ®
;º;ÁAÁ
CÁ)A=Á<CÁ=;B;Â8CÂ:B;Â;CÃ CN)r   r   r&   r   Úget_funcr   r   Ú	weak_selfÚ	weak_funcÚstrÚ	self_nameÚ__name__Ú	func_name)r5   r   r   r9   r   r   s         r   r"   zBoundMethodWeakref.__init__’   s£   € ð  #ð 	Pð 	Pð 	Pð 	Pð& "+ ˆÔØ×%Ò% fÑ-Ô-ˆŒÝ˜6Ñ"Ô"ˆÝ˜6Ñ"Ô"ˆÝ œ W¨fÑ5Ô5ˆŒÝ œ W¨fÑ5Ô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   r:   )r#   r   s     r   r   z BoundMethodWeakref.calculate_key¾   s/   € õ •8˜FÑ#Ô#Ñ$Ô$¥b­°&Ñ)9Ô)9Ñ&:Ô&:Ð;Ð;r	   c                 óX   — d                      | j        j        | j        | j        ¦  «        S )z-Give a friendly representation of the object.z	{}({}.{}))Úformatr)   r?   r>   r@   ©r5   s    r   Ú__str__zBoundMethodWeakref.__str__Ç   s,   € à×!Ò!ØŒNÔ#ØŒNØŒNñô ð 	r	   c                 ó   —  | ¦   «         duS )z'Whether we are still a valid reference.N© rE   s    r   Ú__nonzero__zBoundMethodWeakref.__nonzero__Ñ   s   € àˆt‰vŒv˜TÐ!Ð!r	   c                 ó¤   — t          || j        ¦  «        s"t          | j        t          |¦  «        ¦  «        S t          | j        |j        ¦  «        S )zCompare with another reference.)Ú
isinstancer)   ÚcmpÚtyper&   )r5   Úothers     r   Ú__cmp__zBoundMethodWeakref.__cmp__Õ   sB   € å˜% ¤Ñ0Ô0ð 	4Ý�t”~¥t¨E¡{¤{Ñ3Ô3Ð3Ý�4”8˜UœYÑ'Ô'Ð'r	   c                 óˆ   — |                       ¦   «         }|�+|                      ¦   «         }|�|                     |¦  «        S dS )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)r;   r<   Ú__get__)r5   r   r7   s      r   r   zBoundMethodWeakref.__call__Û   sG   € ð —’Ñ!Ô!ˆØÐØ—~’~Ñ'Ô'ˆHØÐ#Ø×'Ò'¨Ñ/Ô/Ð/Øˆtr	   ©N)r?   Ú
__module__Ú__qualname__Ú__doc__r   ÚWeakValueDictionaryr   r!   r"   r   ÚclassmethodrF   Ú__repr__rI   rO   r   Ú__classcell__)r)   s   @r   r   r   X   sÒ   ø€ € € € € ðð ðB 1�WÔ0Ñ2Ô2€Nðð ð ð ð ð ð,*/ð */ð */ð */ðX<ð <ð <ð  �K Ñ.Ô.€Mðð ð ð €Hð"ð "ð "ð(ð (ð (ðð ð ð ð ð ð r	   r   rR   )rU   Úoperatorr1   r/   r   r   Ú	NameErrorÚversion_infoÚ
attrgetterr   r:   r   r   r   rH   r	   r   ú<module>r^      s!  ððF 4Ð 3à €€€Ø 
€
€
€
Ø Ð Ð Ð Ø €€€ð+Ø€H€HøØð +ð +ð +ð+ð +ð +ð +ð +ð+øøøð
 Ô�dÒÐØ"ˆxÔ" 9Ñ-Ô-€HØ"ˆxÔ" 9Ñ-Ô-€H€Hà"ˆxÔ" :Ñ.Ô.€HØ"ˆxÔ" :Ñ.Ô.€Hðð ð ð ð<Rð Rð Rð Rð R˜ñ Rô Rð Rð Rð Rs   ” —"¡"