MCPcopy Index your code
hub / github.com/python/cpython / __init__

Method __init__

Lib/weakref.py:470–485  ·  view source on GitHub ↗
(self, obj, func, /, *args, **kwargs)

Source from the content-addressed store, hash-verified

468 __slots__ = ("weakref", "func", "args", "kwargs", "atexit", "index")
469
470 def __init__(self, obj, func, /, *args, **kwargs):
471 if not self._registered_with_atexit:
472 # We may register the exit function more than once because
473 # of a thread race, but that is harmless
474 import atexit
475 atexit.register(self._exitfunc)
476 finalize._registered_with_atexit = True
477 info = self._Info()
478 info.weakref = ref(obj, self)
479 info.func = func
480 info.args = args
481 info.kwargs = kwargs or None
482 info.atexit = True
483 info.index = next(self._index_iter)
484 self._registry[self] = info
485 finalize._dirty = True
486
487 def __call__(self, _=None):
488 """If alive then mark as dead and return func(*args, **kwargs);

Callers

nothing calls this directly

Calls 1

registerMethod · 0.45

Tested by

no test coverage detected