

def _deref_with_release(ptr, release):
    result = ptr[0]
    result.__ref__ = weakref.ref(result, (lambda dead: release(ptr)))
    return result

dataset/ETHPy150Open enthought/comtypes/comtypes/typeinfo.py _deref_with_release/original