| 1926 | }; |
| 1927 | |
| 1928 | class weakref : public object { |
| 1929 | public: |
| 1930 | PYBIND11_OBJECT_CVT_DEFAULT(weakref, object, PyWeakref_Check, raw_weakref) |
| 1931 | explicit weakref(handle obj, handle callback = {}) |
| 1932 | : object(PyWeakref_NewRef(obj.ptr(), callback.ptr()), stolen_t{}) { |
| 1933 | if (!m_ptr) { |
| 1934 | if (PyErr_Occurred()) { |
| 1935 | throw error_already_set(); |
| 1936 | } |
| 1937 | pybind11_fail("Could not allocate weak reference!"); |
| 1938 | } |
| 1939 | } |
| 1940 | |
| 1941 | private: |
| 1942 | static PyObject *raw_weakref(PyObject *o) { return PyWeakref_NewRef(o, nullptr); } |
| 1943 | }; |
| 1944 | |
| 1945 | class slice : public object { |
| 1946 | public: |
no outgoing calls
no test coverage detected