static int module___init___impl(PyModuleObject *self, PyObject *name, PyObject *doc) /*[clinic end generated code: output=e7e721c26ce7aad7 input=57f9e177401e5e1e]*/ { PyObject *dict = self->md_dict; if (dict == NULL) { dict = PyDict_New(); if (dict == NULL) return -1; self->md_dict = dict; } if (module_init_dict(self, dict, name, doc) < 0) return -1; return 0; }
static int module_init(PyModuleObject *m, PyObject *args, PyObject *kwds) { static char *kwlist[] = {"name", "doc", NULL}; PyObject *dict, *name = Py_None, *doc = Py_None; if (!PyArg_ParseTupleAndKeywords(args, kwds, "U|O:module.__init__", kwlist, &name, &doc)) return -1; dict = m->md_dict; if (dict == NULL) { dict = PyDict_New(); if (dict == NULL) return -1; m->md_dict = dict; } if (module_init_dict(m, dict, name, doc) < 0) return -1; return 0; }
PyObject * PyModule_NewObject(PyObject *name) { PyModuleObject *m; m = PyObject_GC_New(PyModuleObject, &PyModule_Type); if (m == NULL) return NULL; m->md_def = NULL; m->md_state = NULL; m->md_weaklist = NULL; m->md_name = NULL; m->md_dict = PyDict_New(); if (module_init_dict(m, m->md_dict, name, NULL) != 0) goto fail; PyObject_GC_Track(m); return (PyObject *)m; fail: Py_DECREF(m); return NULL; }