diff options
| author | Martin v. Löwis <martin@v.loewis.de> | 2008-06-11 05:26:20 +0000 |
|---|---|---|
| committer | Martin v. Löwis <martin@v.loewis.de> | 2008-06-11 05:26:20 +0000 |
| commit | 1a21451b1d73b65af949193208372e86bf308411 (patch) | |
| tree | 8e98d7be9e249b011ae9380479656e5284ec0234 /Modules/_threadmodule.c | |
| parent | cdf94635d7e364f9ce1905bafa5b540f4d16147c (diff) | |
| download | cpython-git-1a21451b1d73b65af949193208372e86bf308411.tar.gz | |
Implement PEP 3121: new module initialization and finalization API.
Diffstat (limited to 'Modules/_threadmodule.c')
| -rw-r--r-- | Modules/_threadmodule.c | 26 |
1 files changed, 20 insertions, 6 deletions
diff --git a/Modules/_threadmodule.c b/Modules/_threadmodule.c index 5b8fc9861f..0fe9a763cd 100644 --- a/Modules/_threadmodule.c +++ b/Modules/_threadmodule.c @@ -687,21 +687,34 @@ A lock is not owned by the thread that locked it; another thread may\n\ 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 @@ init_thread(void) Py_INCREF(&localtype); if (PyModule_AddObject(m, "_local", (PyObject *)&localtype) < 0) - return; + return NULL; /* Initialize the C thread library */ PyThread_init_thread(); + return m; } |
