def __getref__(self): ref = self.__ref__() if ref is None: raise weakref.ReferenceError('weakly-referenced object no longer exists') return ref