Implement PEP 3121: new module initialization and finalization API.

This commit is contained in:
Martin v. Löwis 2008-06-11 05:26:20 +00:00
parent cdf94635d7
commit 1a21451b1d
113 changed files with 2230 additions and 855 deletions

View file

@ -47,14 +47,26 @@ static PyMethodDef symtable_methods[] = {
{NULL, NULL} /* sentinel */
};
static struct PyModuleDef symtablemodule = {
PyModuleDef_HEAD_INIT,
"_symtable",
NULL,
-1,
symtable_methods,
NULL,
NULL,
NULL,
NULL
};
PyMODINIT_FUNC
init_symtable(void)
PyInit__symtable(void)
{
PyObject *m;
m = Py_InitModule("_symtable", symtable_methods);
m = PyModule_Create(&symtablemodule);
if (m == NULL)
return;
return NULL;
PyModule_AddIntConstant(m, "USE", USE);
PyModule_AddIntConstant(m, "DEF_GLOBAL", DEF_GLOBAL);
PyModule_AddIntConstant(m, "DEF_LOCAL", DEF_LOCAL);
@ -80,4 +92,9 @@ init_symtable(void)
PyModule_AddIntConstant(m, "GLOBAL_IMPLICIT", GLOBAL_IMPLICIT);
PyModule_AddIntConstant(m, "FREE", FREE);
PyModule_AddIntConstant(m, "CELL", CELL);
if (PyErr_Occurred()) {
Py_DECREF(m);
m = 0;
}
return m;
}