Mercurial > cpython-lru_cache-weakref
diff Modules/_threadmodule.c @ 47580:94f64f11fdd0
Implement PEP 3121: new module initialization and finalization API.
| author | Martin v. Löwis <martin@v.loewis.de> |
|---|---|
| date | Wed, 11 Jun 2008 05:26:20 +0000 |
| parents | afbde360dd1a |
| children | e29b4ce641f9 |
line wrap: on
line diff
--- a/Modules/_threadmodule.c Wed Jun 11 03:41:00 2008 +0000 +++ b/Modules/_threadmodule.c Wed Jun 11 05:26:20 2008 +0000 @@ -687,21 +687,34 @@ unlock it. A thread attempting to lock a lock that it has already locked\n\ will block until another thread unlocks it. Deadlocks may ensue."); +static struct PyModuleDef threadmodule = { + PyModuleDef_HEAD_INIT, + "_thread", + thread_doc, + -1, + thread_methods, + NULL, + NULL, + NULL, + NULL +}; + + PyMODINIT_FUNC -init_thread(void) +PyInit__thread(void) { PyObject *m, *d; /* Initialize types: */ if (PyType_Ready(&localtype) < 0) - return; + return NULL; if (PyType_Ready(&Locktype) < 0) - return; + return NULL; /* Create the module and add the functions */ - m = Py_InitModule3("_thread", thread_methods, thread_doc); + m = PyModule_Create(&threadmodule); if (m == NULL) - return; + return NULL; /* Add a symbolic constant */ d = PyModule_GetDict(m); @@ -713,8 +726,9 @@ Py_INCREF(&localtype); if (PyModule_AddObject(m, "_local", (PyObject *)&localtype) < 0) - return; + return NULL; /* Initialize the C thread library */ PyThread_init_thread(); + return m; }
