PyMODINIT_FUNC PyInit__testmultiphase_negative_size(PyObject *spec) { return PyModuleDef_Init(&def_negative_size); }
PyMODINIT_FUNC PyInit__testmultiphase_bad_slot_negative(PyObject *spec) { return PyModuleDef_Init(&def_bad_negative); }
PyMODINIT_FUNC PyInit__testmultiphase_create_int_with_state(PyObject *spec) { return PyModuleDef_Init(&def_create_int_with_state); }
PyMODINIT_FUNC PyInit__testconsole(PyObject *spec) { return PyModuleDef_Init(&testconsole_def); }
PyMODINIT_FUNC PyInit__testmultiphase_null_slots(PyObject *spec) { return PyModuleDef_Init(&null_slots_def); }
PyMODINIT_FUNC PyInit__testmultiphase_nonmodule_with_exec_slots(PyObject *spec) { return PyModuleDef_Init(&def_nonmodule_with_exec_slots); }
PyMODINIT_FUNC PyInit__testmultiphase_exec_raise(PyObject *mod) { return PyModuleDef_Init(&def_exec_raise); }
PyMODINIT_FUNC PyInit__testmultiphase(PyObject *spec) { return PyModuleDef_Init(&main_def); }
PyMODINIT_FUNC PyInit__testmultiphase_nonmodule(PyObject *spec) { return PyModuleDef_Init(&def_nonmodule); }
PyMODINIT_FUNC PyInit__cstruct(void) { return PyModuleDef_Init(&moduledef); }
PyMODINIT_FUNC PyInit_atexit(void) { return PyModuleDef_Init(&atexitmodule); }
PyObject * PyModule_FromDefAndSpec2(struct PyModuleDef* def, PyObject *spec, int module_api_version) { PyModuleDef_Slot* cur_slot; PyObject *(*create)(PyObject *, PyModuleDef*) = NULL; PyObject *nameobj; PyObject *m = NULL; int has_execution_slots = 0; const char *name; int ret; PyModuleDef_Init(def); nameobj = PyObject_GetAttrString(spec, "name"); if (nameobj == NULL) { return NULL; } name = PyUnicode_AsUTF8(nameobj); if (name == NULL) { goto error; } if (!check_api_version(name, module_api_version)) { goto error; } if (def->m_size < 0) { PyErr_Format( PyExc_SystemError, "module %s: m_size may not be negative for multi-phase initialization", name); goto error; } for (cur_slot = def->m_slots; cur_slot && cur_slot->slot; cur_slot++) { if (cur_slot->slot == Py_mod_create) { if (create) { PyErr_Format( PyExc_SystemError, "module %s has multiple create slots", name); goto error; } create = cur_slot->value; } else if (cur_slot->slot < 0 || cur_slot->slot > _Py_mod_LAST_SLOT) { PyErr_Format( PyExc_SystemError, "module %s uses unknown slot ID %i", name, cur_slot->slot); goto error; } else { has_execution_slots = 1; } } if (create) { m = create(spec, def); if (m == NULL) { if (!PyErr_Occurred()) { PyErr_Format( PyExc_SystemError, "creation of module %s failed without setting an exception", name); } goto error; } else { if (PyErr_Occurred()) { PyErr_Format(PyExc_SystemError, "creation of module %s raised unreported exception", name); goto error; } } } else { m = PyModule_NewObject(nameobj); if (m == NULL) { goto error; } } if (PyModule_Check(m)) { ((PyModuleObject*)m)->md_state = NULL; ((PyModuleObject*)m)->md_def = def; } else { if (def->m_size > 0 || def->m_traverse || def->m_clear || def->m_free) { PyErr_Format( PyExc_SystemError, "module %s is not a module object, but requests module state", name); goto error; } if (has_execution_slots) { PyErr_Format( PyExc_SystemError, "module %s specifies execution slots, but did not create " "a ModuleType instance", name); goto error; } } if (def->m_methods != NULL) { ret = _add_methods_to_object(m, nameobj, def->m_methods); if (ret != 0) { goto error; } } if (def->m_doc != NULL) { ret = PyModule_SetDocString(m, def->m_doc); if (ret != 0) { goto error; } } Py_DECREF(nameobj); return m; error: Py_DECREF(nameobj); Py_XDECREF(m); return NULL; }
PyObject * PyModule_Create2(struct PyModuleDef* module, int module_api_version) { const char* name; PyModuleObject *m; PyInterpreterState *interp = PyThreadState_Get()->interp; if (interp->modules == NULL) Py_FatalError("Python import machinery not initialized"); if (!PyModuleDef_Init(module)) return NULL; name = module->m_name; if (!check_api_version(name, module_api_version)) { return NULL; } if (module->m_slots) { PyErr_Format( PyExc_SystemError, "module %s: PyModule_Create is incompatible with m_slots", name); return NULL; } /* Make sure name is fully qualified. This is a bit of a hack: when the shared library is loaded, the module name is "package.module", but the module calls PyModule_Create*() with just "module" for the name. The shared library loader squirrels away the true name of the module in _Py_PackageContext, and PyModule_Create*() will substitute this (if the name actually matches). */ if (_Py_PackageContext != NULL) { const char *p = strrchr(_Py_PackageContext, '.'); if (p != NULL && strcmp(module->m_name, p+1) == 0) { name = _Py_PackageContext; _Py_PackageContext = NULL; } } if ((m = (PyModuleObject*)PyModule_New(name)) == NULL) return NULL; if (module->m_size > 0) { m->md_state = PyMem_MALLOC(module->m_size); if (!m->md_state) { PyErr_NoMemory(); Py_DECREF(m); return NULL; } memset(m->md_state, 0, module->m_size); } if (module->m_methods != NULL) { if (PyModule_AddFunctions((PyObject *) m, module->m_methods) != 0) { Py_DECREF(m); return NULL; } } if (module->m_doc != NULL) { if (PyModule_SetDocString((PyObject *) m, module->m_doc) != 0) { Py_DECREF(m); return NULL; } } m->md_def = module; return (PyObject*)m; }
PyMODINIT_FUNC PyInit_xx(void) { return PyModuleDef_Init(&xxmodule); }
PyMODINIT_FUNC PyInit__testmultiphase_export_unreported_exception(PyObject *spec) { PyErr_SetString(PyExc_SystemError, "bad export function"); return PyModuleDef_Init(&main_def); }
PyMODINIT_FUNC PyInitU__testmultiphase_zkouka_naten_evc07gi8e(PyObject *spec) { return PyModuleDef_Init(&def_nonascii_latin); }
PyMODINIT_FUNC PyInit__testmultiphase_create_raise(PyObject *spec) { return PyModuleDef_Init(&def_create_raise); }
PyMODINIT_FUNC PyInitU_eckzbwbhc6jpgzcx415x(PyObject *spec) { return PyModuleDef_Init(&def_nonascii_kana); }
PyMODINIT_FUNC PyInit__testmultiphase_exec_err(PyObject *spec) { return PyModuleDef_Init(&def_exec_err); }
PyMODINIT_FUNC PyInit_x(PyObject *spec) { return PyModuleDef_Init(&main_def); }
PyMODINIT_FUNC PyInit__testmultiphase_exec_unreported_exception(PyObject *spec) { return PyModuleDef_Init(&def_exec_unreported_exception); }
PyMODINIT_FUNC PyInit_xxsubtype(void) { return PyModuleDef_Init(&xxsubtypemodule); }