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/_randommodule.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/_randommodule.c')
-rw-r--r-- | Modules/_randommodule.c | 22 |
1 files changed, 18 insertions, 4 deletions
diff --git a/Modules/_randommodule.c b/Modules/_randommodule.c index 77b238d..4cdd98d 100644 --- a/Modules/_randommodule.c +++ b/Modules/_randommodule.c @@ -496,16 +496,30 @@ static PyTypeObject Random_Type = { PyDoc_STRVAR(module_doc, "Module implements the Mersenne Twister random number generator."); + +static struct PyModuleDef _randommodule = { + PyModuleDef_HEAD_INIT, + "_random", + module_doc, + -1, + NULL, + NULL, + NULL, + NULL, + NULL +}; + PyMODINIT_FUNC -init_random(void) +PyInit__random(void) { PyObject *m; if (PyType_Ready(&Random_Type) < 0) - return; - m = Py_InitModule3("_random", NULL, module_doc); + return NULL; + m = PyModule_Create(&_randommodule); if (m == NULL) - return; + return NULL; Py_INCREF(&Random_Type); PyModule_AddObject(m, "Random", (PyObject *)&Random_Type); + return m; } |