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

@ -1135,14 +1135,27 @@ static PyTypeObject test_structmembersType = {
};
static struct PyModuleDef _testcapimodule = {
PyModuleDef_HEAD_INIT,
"_testcapi",
NULL,
-1,
TestMethods,
NULL,
NULL,
NULL,
NULL
};
PyMODINIT_FUNC
init_testcapi(void)
PyInit__testcapi(void)
{
PyObject *m;
m = Py_InitModule("_testcapi", TestMethods);
m = PyModule_Create(&_testcapimodule);
if (m == NULL)
return;
return NULL;
Py_TYPE(&test_structmembersType)=&PyType_Type;
Py_INCREF(&test_structmembersType);
@ -1173,4 +1186,5 @@ init_testcapi(void)
TestError = PyErr_NewException("_testcapi.error", NULL, NULL);
Py_INCREF(TestError);
PyModule_AddObject(m, "error", TestError);
return m;
}