@@ -1329,7 +1329,7 @@ static struct PyModuleDef signalmodule = {
1329
1329
PyMODINIT_FUNC
1330
1330
PyInit__signal (void )
1331
1331
{
1332
- PyObject * m , * d , * x ;
1332
+ PyObject * m , * d ;
1333
1333
int i ;
1334
1334
1335
1335
/* Create the module and add the functions */
@@ -1350,13 +1350,17 @@ PyInit__signal(void)
1350
1350
/* Add some symbolic constants to the module */
1351
1351
d = PyModule_GetDict (m );
1352
1352
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 ) {
1355
1356
goto finally ;
1357
+ }
1356
1358
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 ) {
1359
1362
goto finally ;
1363
+ }
1360
1364
1361
1365
if (PyModule_AddIntMacro (m , NSIG ))
1362
1366
goto finally ;
@@ -1374,8 +1378,8 @@ PyInit__signal(void)
1374
1378
goto finally ;
1375
1379
#endif
1376
1380
1377
- x = IntHandler = PyDict_GetItemString (d , "default_int_handler" );
1378
- if (!x )
1381
+ IntHandler = PyDict_GetItemString (d , "default_int_handler" );
1382
+ if (!IntHandler )
1379
1383
goto finally ;
1380
1384
Py_INCREF (IntHandler );
1381
1385
@@ -1568,8 +1572,10 @@ PyInit__signal(void)
1568
1572
#if defined (HAVE_SETITIMER ) || defined (HAVE_GETITIMER )
1569
1573
ItimerError = PyErr_NewException ("signal.ItimerError" ,
1570
1574
PyExc_OSError , NULL );
1571
- if (PyModule_AddObject (m , "ItimerError" , ItimerError ))
1575
+ if (!ItimerError ||
1576
+ PyDict_SetItemString (d , "ItimerError" , ItimerError ) < 0 ) {
1572
1577
goto finally ;
1578
+ }
1573
1579
#endif
1574
1580
1575
1581
#ifdef CTRL_C_EVENT
@@ -1615,6 +1621,9 @@ finisignal(void)
1615
1621
Py_CLEAR (IntHandler );
1616
1622
Py_CLEAR (DefaultHandler );
1617
1623
Py_CLEAR (IgnoreHandler );
1624
+ #ifdef HAVE_GETITIMER
1625
+ Py_CLEAR (ItimerError );
1626
+ #endif
1618
1627
}
1619
1628
1620
1629
0 commit comments