MCPcopy Create free account
hub / github.com/pybind/pybind11 / weakref

Method weakref

include/pybind11/pytypes.h:1986–1994  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1984public:
1985 PYBIND11_OBJECT_CVT_DEFAULT(weakref, object, PyWeakref_Check, raw_weakref)
1986 explicit weakref(handle obj, handle callback = {})
1987 : object(PyWeakref_NewRef(obj.ptr(), callback.ptr()), stolen_t{}) {
1988 if (!m_ptr) {
1989 if (PyErr_Occurred()) {
1990 throw error_already_set();
1991 }
1992 pybind11_fail("Could not allocate weak reference!");
1993 }
1994 }
1995
1996private:
1997 static PyObject *raw_weakref(PyObject *o) { return PyWeakref_NewRef(o, nullptr); }

Callers

nothing calls this directly

Calls 1

ptrMethod · 0.80

Tested by

no test coverage detected