def __new__(cls, meth, callback=None):
            try:
                obj = meth.__self__
                func = meth.__func__
            except __HOLE__:
                raise TypeError("argument should be a bound method, not {}"
                                .format(type(meth)))

            def _cb(arg):
                # The self-weakref trick is needed to avoid creating a
                # reference cycle.
                self = self_wr()
                if self._alive:
                    self._alive = False
                    if callback is not None:
                        callback(self)
            self = ref.__new__(cls, obj, _cb)
            self._func_ref = ref(func, _cb)
            self._meth_type = type(meth)
            self._alive = True
            self_wr = ref(self)
            return self
dataset/ETHPy150Open OpenCobolIDE/OpenCobolIDE/open_cobol_ide/extlibs/pyqode/core/api/client.py/WeakMethod.__new__