@@ -1329,7 +1329,7 @@ static struct PyModuleDef signalmodule = {
13291329PyMODINIT_FUNC
13301330PyInit__signal (void )
13311331{
1332- PyObject * m , * d , * x ;
1332+ PyObject * m , * d ;
13331333 int i ;
13341334
13351335 /* Create the module and add the functions */
@@ -1350,13 +1350,17 @@ PyInit__signal(void)
13501350 /* Add some symbolic constants to the module */
13511351 d = PyModule_GetDict (m );
13521352
1353- x = DefaultHandler = PyLong_FromVoidPtr ((void * )SIG_DFL );
1354- if (PyModule_AddObject (m , "SIG_DFL" , x ))
1353+ DefaultHandler = PyLong_FromVoidPtr ((void * )SIG_DFL );
1354+ if (!DefaultHandler ||
1355+ PyDict_SetItemString (d , "SIG_DFL" , DefaultHandler ) < 0 ) {
13551356 goto finally ;
1357+ }
13561358
1357- x = IgnoreHandler = PyLong_FromVoidPtr ((void * )SIG_IGN );
1358- if (PyModule_AddObject (m , "SIG_IGN" , x ))
1359+ IgnoreHandler = PyLong_FromVoidPtr ((void * )SIG_IGN );
1360+ if (!IgnoreHandler ||
1361+ PyDict_SetItemString (d , "SIG_IGN" , IgnoreHandler ) < 0 ) {
13591362 goto finally ;
1363+ }
13601364
13611365 if (PyModule_AddIntMacro (m , NSIG ))
13621366 goto finally ;
@@ -1374,8 +1378,8 @@ PyInit__signal(void)
13741378 goto finally ;
13751379#endif
13761380
1377- x = IntHandler = PyDict_GetItemString (d , "default_int_handler" );
1378- if (!x )
1381+ IntHandler = PyDict_GetItemString (d , "default_int_handler" );
1382+ if (!IntHandler )
13791383 goto finally ;
13801384 Py_INCREF (IntHandler );
13811385
@@ -1568,8 +1572,10 @@ PyInit__signal(void)
15681572#if defined (HAVE_SETITIMER ) || defined (HAVE_GETITIMER )
15691573 ItimerError = PyErr_NewException ("signal.ItimerError" ,
15701574 PyExc_OSError , NULL );
1571- if (PyModule_AddObject (m , "ItimerError" , ItimerError ))
1575+ if (!ItimerError ||
1576+ PyDict_SetItemString (d , "ItimerError" , ItimerError ) < 0 ) {
15721577 goto finally ;
1578+ }
15731579#endif
15741580
15751581#ifdef CTRL_C_EVENT
@@ -1615,6 +1621,9 @@ finisignal(void)
16151621 Py_CLEAR (IntHandler );
16161622 Py_CLEAR (DefaultHandler );
16171623 Py_CLEAR (IgnoreHandler );
1624+ #ifdef HAVE_GETITIMER
1625+ Py_CLEAR (ItimerError );
1626+ #endif
16181627}
16191628
16201629
0 commit comments