summaryrefslogtreecommitdiffstats
path: root/Modules/signalmodule.c
diff options
context:
space:
mode:
authorMartin v. Löwis <martin@v.loewis.de>2008-06-11 05:26:20 (GMT)
committerMartin v. Löwis <martin@v.loewis.de>2008-06-11 05:26:20 (GMT)
commit1a21451b1d73b65af949193208372e86bf308411 (patch)
tree8e98d7be9e249b011ae9380479656e5284ec0234 /Modules/signalmodule.c
parentcdf94635d7e364f9ce1905bafa5b540f4d16147c (diff)
downloadcpython-1a21451b1d73b65af949193208372e86bf308411.zip
cpython-1a21451b1d73b65af949193208372e86bf308411.tar.gz
cpython-1a21451b1d73b65af949193208372e86bf308411.tar.bz2
Implement PEP 3121: new module initialization and finalization API.
Diffstat (limited to 'Modules/signalmodule.c')
-rw-r--r--Modules/signalmodule.c34
1 files changed, 25 insertions, 9 deletions
diff --git a/Modules/signalmodule.c b/Modules/signalmodule.c
index eb4c25a..15cd964 100644
--- a/Modules/signalmodule.c
+++ b/Modules/signalmodule.c
@@ -516,8 +516,20 @@ ITIMER_PROF -- decrements both when the process is executing and\n\
A signal handler function is called with two arguments:\n\
the first is the signal number, the second is the interrupted stack frame.");
+static struct PyModuleDef signalmodule = {
+ PyModuleDef_HEAD_INIT,
+ "signal",
+ module_doc,
+ -1,
+ signal_methods,
+ NULL,
+ NULL,
+ NULL,
+ NULL
+};
+
PyMODINIT_FUNC
-initsignal(void)
+PyInit_signal(void)
{
PyObject *m, *d, *x;
int i;
@@ -528,9 +540,9 @@ initsignal(void)
#endif
/* Create the module and add the functions */
- m = Py_InitModule3("signal", signal_methods, module_doc);
+ m = PyModule_Create(&signalmodule);
if (m == NULL)
- return;
+ return NULL;
/* Add some symbolic constants to the module */
d = PyModule_GetDict(m);
@@ -787,12 +799,13 @@ initsignal(void)
PyDict_SetItemString(d, "ItimerError", ItimerError);
#endif
- if (!PyErr_Occurred())
- return;
+ if (PyErr_Occurred()) {
+ Py_DECREF(m);
+ m = NULL;
+ }
- /* Check for errors */
finally:
- return;
+ return m;
}
static void
@@ -893,8 +906,11 @@ PyErr_SetInterrupt(void)
void
PyOS_InitInterrupts(void)
{
- initsignal();
- _PyImport_FixupExtension("signal", "signal");
+ PyObject *m = PyInit_signal();
+ if (m) {
+ _PyImport_FixupExtension(m, "signal", "signal");
+ Py_DECREF(m);
+ }
}
void