summaryrefslogtreecommitdiffstats
path: root/Modules/xxlimited.c
diff options
context:
space:
mode:
Diffstat (limited to 'Modules/xxlimited.c')
-rw-r--r--Modules/xxlimited.c55
1 files changed, 30 insertions, 25 deletions
diff --git a/Modules/xxlimited.c b/Modules/xxlimited.c
index 7bfcb91..604456b 100644
--- a/Modules/xxlimited.c
+++ b/Modules/xxlimited.c
@@ -222,25 +222,9 @@ static PyMethodDef xx_methods[] = {
PyDoc_STRVAR(module_doc,
"This is a template module just for instruction.");
-/* Initialization function for the module (*must* be called PyInit_xx) */
-
-
-static struct PyModuleDef xxmodule = {
- PyModuleDef_HEAD_INIT,
- "xxlimited",
- module_doc,
- -1,
- xx_methods,
- NULL,
- NULL,
- NULL,
- NULL
-};
-
-PyMODINIT_FUNC
-PyInit_xxlimited(void)
+static int
+xx_modexec(PyObject *m)
{
- PyObject *m = NULL;
PyObject *o;
/* Due to cross platform compiler issues the slots must be filled
@@ -254,11 +238,6 @@ PyInit_xxlimited(void)
if (Xxo_Type == NULL)
goto fail;
- /* Create the module and add the functions */
- m = PyModule_Create(&xxmodule);
- if (m == NULL)
- goto fail;
-
/* Add some symbolic constants to the module */
if (ErrorObject == NULL) {
ErrorObject = PyErr_NewException("xxlimited.error", NULL, NULL);
@@ -279,8 +258,34 @@ PyInit_xxlimited(void)
if (o == NULL)
goto fail;
PyModule_AddObject(m, "Null", o);
- return m;
+ return 0;
fail:
Py_XDECREF(m);
- return NULL;
+ return -1;
+}
+
+
+static PyModuleDef_Slot xx_slots[] = {
+ {Py_mod_exec, xx_modexec},
+ {0, NULL}
+};
+
+static struct PyModuleDef xxmodule = {
+ PyModuleDef_HEAD_INIT,
+ "xxlimited",
+ module_doc,
+ 0,
+ xx_methods,
+ xx_slots,
+ NULL,
+ NULL,
+ NULL
+};
+
+/* Export function for the module (*must* be called PyInit_xx) */
+
+PyMODINIT_FUNC
+PyInit_xxlimited(void)
+{
+ return PyModuleDef_Init(&xxmodule);
}