3
š(ƒhc  ã               @   s$   d Z ddlmZ G d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                   sD   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
‡  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}W n& tk
r6   tdjt|ƒƒƒ‚Y nX ‡ ‡fdd„}tj| ||ƒ}t||ƒ|_t|ƒ|_	d|_
t|ƒ‰|S )Nz)argument should be a bound method, not {}c                s&   ˆƒ }|j r"d|_ ˆ d k	r"ˆ |ƒ d S )NF)r   )ÚargÚself)ÚcallbackÚself_wr© úE/tmp/pip-install-q3hcpn_q/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                s6   t t| ƒjƒ }| jƒ }|d ks&|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   s>   t |tƒr:| j s|j r"| |kS tj| |ƒo8| j|jkS dS )NF)Ú
isinstancer   r   r   Ú__eq__r   )r	   Úotherr   r   r   r   5   s
    
zWeakMethod.__eq__c             C   s>   t |tƒr:| j s|j r"| |k	S tj| |ƒp8| j|jkS dS )NT)r   r   r   r   Ú__ne__r   )r	   r   r   r   r   r    <   s
    
zWeakMethod.__ne__)r   r   r   r   )N)Ú__name__Ú
__module__Ú__qualname__Ú__doc__Ú	__slots__r   r   r   r    r   Ú__hash__Ú__classcell__r   r   )r   r   r      s   
r   N)r$   Úweakrefr   r   r   r   r   r   Ú<module>   s   