a XC?h8T ã @ sÒ d Z ddlmZmZmZmZmZmZmZm Z ddl mZmZ ddl Z ddlZddlZeefZg d¢Ze j e¡ e j e¡ G dd„ deƒZG dd „ d e jƒZG d d„ deƒZG dd „ d e jƒZG dd„ dƒZdS )z|Weak reference support for Python. This module is an implementation of PEP 205: https://www.python.org/dev/peps/pep-0205/ é )ÚgetweakrefcountÚgetweakrefsÚrefÚproxyÚCallableProxyTypeÚ ProxyTypeÚ ReferenceTypeÚ_remove_dead_weakref)ÚWeakSetÚ_IterationGuardN) r r r r ÚWeakKeyDictionaryr r r Ú ProxyTypesÚWeakValueDictionaryr Ú WeakMethodÚfinalizec sD e Zd ZdZdZddd„Z‡ fdd„Zdd „ Zd d„ Ze j Z ‡ ZS ) r z— 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| z|j }|j}W n& ty6 td t|ƒ¡ƒd ‚Y n0 ‡ ‡fdd„}t | ||¡}t||ƒ|_t|ƒ|_ d|_ t|ƒ‰|S )Nz)argument should be a bound method, not {}c s&