From 1a21451b1d73b65af949193208372e86bf308411 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20v=2E=20L=C3=B6wis?= Date: Wed, 11 Jun 2008 05:26:20 +0000 Subject: Implement PEP 3121: new module initialization and finalization API. --- Modules/sha512module.c | 25 +++++++++++++++++-------- 1 file changed, 17 insertions(+), 8 deletions(-) (limited to 'Modules/sha512module.c') diff --git a/Modules/sha512module.c b/Modules/sha512module.c index 3fe5a1b2fc..472b158080 100644 --- a/Modules/sha512module.c +++ b/Modules/sha512module.c @@ -748,20 +748,29 @@ static struct PyMethodDef SHA_functions[] = { #define insint(n,v) { PyModule_AddIntConstant(m,n,v); } + +static struct PyModuleDef _sha512module = { + PyModuleDef_HEAD_INIT, + "_sha512", + NULL, + -1, + SHA_functions, + NULL, + NULL, + NULL, + NULL +}; + PyMODINIT_FUNC -init_sha512(void) +PyInit__sha512(void) { - PyObject *m; - Py_TYPE(&SHA384type) = &PyType_Type; if (PyType_Ready(&SHA384type) < 0) - return; + return NULL; Py_TYPE(&SHA512type) = &PyType_Type; if (PyType_Ready(&SHA512type) < 0) - return; - m = Py_InitModule("_sha512", SHA_functions); - if (m == NULL) - return; + return NULL; + return PyModule_Create(&_sha512module); } #endif -- cgit v1.2.1