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

Function pybind11_meta_call

include/pybind11/detail/class.h:185–206  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

183
184/// metaclass `__call__` function that is used to create all pybind11 objects.
185extern "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.
209extern "C" inline void pybind11_meta_dealloc(PyObject *obj) {

Callers

nothing calls this directly

Calls 3

holder_constructedMethod · 0.80

Tested by

no test coverage detected