| 183 | |
| 184 | /// metaclass `__call__` function that is used to create all pybind11 objects. |
| 185 | extern "C" inline PyObject *pybind11_meta_call(PyObject *type, PyObject *args, PyObject *kwargs) { |
| 186 | |
| 187 | // use the default metaclass call to create/initialize the object |
| 188 | PyObject *self = PyType_Type.tp_call(type, args, kwargs); |
| 189 | if (self == nullptr) { |
| 190 | return nullptr; |
| 191 | } |
| 192 | |
| 193 | // Ensure that the base __init__ function(s) were called |
| 194 | values_and_holders vhs(self); |
| 195 | for (const auto &vh : vhs) { |
| 196 | if (!vh.holder_constructed() && !vhs.is_redundant_value_and_holder(vh)) { |
| 197 | PyErr_Format(PyExc_TypeError, |
| 198 | "%.200s.__init__() must be called when overriding __init__", |
| 199 | get_fully_qualified_tp_name(vh.type->type).c_str()); |
| 200 | Py_DECREF(self); |
| 201 | return nullptr; |
| 202 | } |
| 203 | } |
| 204 | |
| 205 | return self; |
| 206 | } |
| 207 | |
| 208 | /// Cleanup the type-info for a pybind11-registered type. |
| 209 | extern "C" inline void pybind11_meta_dealloc(PyObject *obj) { |
nothing calls this directly
no test coverage detected