diff options
author | Martin v. Löwis <martin@v.loewis.de> | 2008-06-11 05:26:20 (GMT) |
---|---|---|
committer | Martin v. Löwis <martin@v.loewis.de> | 2008-06-11 05:26:20 (GMT) |
commit | 1a21451b1d73b65af949193208372e86bf308411 (patch) | |
tree | 8e98d7be9e249b011ae9380479656e5284ec0234 /Modules/_lsprof.c | |
parent | cdf94635d7e364f9ce1905bafa5b540f4d16147c (diff) | |
download | cpython-1a21451b1d73b65af949193208372e86bf308411.zip cpython-1a21451b1d73b65af949193208372e86bf308411.tar.gz cpython-1a21451b1d73b65af949193208372e86bf308411.tar.bz2 |
Implement PEP 3121: new module initialization and finalization API.
Diffstat (limited to 'Modules/_lsprof.c')
-rw-r--r-- | Modules/_lsprof.c | 22 |
1 files changed, 18 insertions, 4 deletions
diff --git a/Modules/_lsprof.c b/Modules/_lsprof.c index e0446ec..69ecaf1 100644 --- a/Modules/_lsprof.c +++ b/Modules/_lsprof.c @@ -857,16 +857,29 @@ static PyMethodDef moduleMethods[] = { {NULL, NULL} }; + +static struct PyModuleDef _lsprofmodule = { + PyModuleDef_HEAD_INIT, + "_lsprof", + "Fast profiler", + -1, + moduleMethods, + NULL, + NULL, + NULL, + NULL +}; + PyMODINIT_FUNC -init_lsprof(void) +PyInit__lsprof(void) { PyObject *module, *d; - module = Py_InitModule3("_lsprof", moduleMethods, "Fast profiler"); + module = PyModule_Create(&_lsprofmodule); if (module == NULL) - return; + return NULL; d = PyModule_GetDict(module); if (PyType_Ready(&PyProfiler_Type) < 0) - return; + return NULL; PyDict_SetItemString(d, "Profiler", (PyObject *)&PyProfiler_Type); if (!initialized) { @@ -883,4 +896,5 @@ init_lsprof(void) (PyObject*) &StatsSubEntryType); empty_tuple = PyTuple_New(0); initialized = 1; + return module; } |