î
ªÍ Xc  ã               @   s0   d  Z  d d l m Z Gd d „  d e ƒ Z d S)aO  
weakref_backports is a partial backport of the weakref module for python
versions below 3.4.

Copyright (C) 2013 Python Software Foundation, see LICENSE.python for details.

The following changes were made to the original sources during backporting:

 * Added `self` to `super` calls.
 * Removed `from None` when raising exceptions.

é    )Úrefc                   s^   e  Z d  Z d Z d Z d d d „ Z ‡  f d	 d
 †  Z d d „  Z d d „  Z e	 j
 Z
 ‡  S)Ú
WeakMethodz—
    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__Nc                sª   y | j  } | j } Wn- t k
 rE t d j t | ƒ ƒ ƒ ‚ Yn X‡  ‡ f d d †  } t j |  | | ƒ } t | | ƒ | _ t | ƒ | _	 d | _
 t | ƒ ‰ | S)Nz)argument should be a bound method, not {}c                s;   ˆ ƒ  } | j  r7 d | _  ˆ  d  k	 r7 ˆ  | ƒ q7 n  d  S)NF)r   )ÚargÚself)ÚcallbackÚself_wr© úO/home/ubuntu/projects/ifolica/build/django/django/dispatch/weakref_backports.pyÚ_cb   s
    			zWeakMethod.__new__.<locals>._cbT)Ú__self__Ú__func__ÚAttributeErrorÚ	TypeErrorÚformatÚtyper   Ú__new__r   r   r   )ÚclsÚmethr
   ÚobjÚfuncr   r	   r   )r
   r   r   r      s    			zWeakMethod.__new__c                sM   t  t |  ƒ j ƒ  } |  j ƒ  } | d  k s9 | d  k r= d  S|  j | | ƒ S)N)Úsuperr   Ú__call__r   r   )r	   r   r   )Ú	__class__r   r   r   .   s
    zWeakMethod.__call__c             C   sS   t  | t ƒ rO |  j s# | j r- |  | k St j |  | ƒ oN |  j | j k Sd S)NF)Ú
isinstancer   r   r   Ú__eq__r   )r	   Úotherr   r   r   r   5   s
    
"zWeakMethod.__eq__c             C   sS   t  | t ƒ rO |  j s# | j r- |  | k	 St j |  | ƒ pN |  j | j k Sd S)NT)r   r   r   r   Ú__ne__r   )r	   r   r   r   r   r    <   s
    
"zWeakMethod.__ne__)z	_func_refz
_meth_typez_alivez__weakref__)Ú__name__Ú
__module__Ú__qualname__Ú__doc__Ú	__slots__r   r   r   r    r   Ú__hash__r   r   )r   r   r      s   r   N)r$   Úweakrefr   r   r   r   r   r   Ú<module>   s   