diff options
author | Joannah Nanjekye <33177550+nanjekyejoannah@users.noreply.github.com> | 2019-04-22 01:47:06 (GMT) |
---|---|---|
committer | Berker Peksag <berker.peksag@gmail.com> | 2019-04-22 01:47:06 (GMT) |
commit | 9541bd321a94f13dc41163a5d7a1a847816fac84 (patch) | |
tree | 0c044df21bead4dbccba0d96bf7b4ff68516ac00 /Modules/signalmodule.c | |
parent | 5ebfa840a1c9967da299356733da41b532688988 (diff) | |
download | cpython-9541bd321a94f13dc41163a5d7a1a847816fac84.zip cpython-9541bd321a94f13dc41163a5d7a1a847816fac84.tar.gz cpython-9541bd321a94f13dc41163a5d7a1a847816fac84.tar.bz2 |
bpo-24011: Use PyModule_Add{Object,IntMacro} in PyInit__signal() (GH-12765)
Diffstat (limited to 'Modules/signalmodule.c')
-rw-r--r-- | Modules/signalmodule.c | 12 |
1 files changed, 5 insertions, 7 deletions
diff --git a/Modules/signalmodule.c b/Modules/signalmodule.c index 4590017..8c5a0d0 100644 --- a/Modules/signalmodule.c +++ b/Modules/signalmodule.c @@ -1350,17 +1350,15 @@ PyInit__signal(void) d = PyModule_GetDict(m); x = DefaultHandler = PyLong_FromVoidPtr((void *)SIG_DFL); - if (!x || PyDict_SetItemString(d, "SIG_DFL", x) < 0) + if (PyModule_AddObject(m, "SIG_DFL", x)) goto finally; x = IgnoreHandler = PyLong_FromVoidPtr((void *)SIG_IGN); - if (!x || PyDict_SetItemString(d, "SIG_IGN", x) < 0) + if (PyModule_AddObject(m, "SIG_IGN", x)) goto finally; - x = PyLong_FromLong((long)NSIG); - if (!x || PyDict_SetItemString(d, "NSIG", x) < 0) + if (PyModule_AddIntMacro(m, NSIG)) goto finally; - Py_DECREF(x); #ifdef SIG_BLOCK if (PyModule_AddIntMacro(m, SIG_BLOCK)) @@ -1569,8 +1567,8 @@ PyInit__signal(void) #if defined (HAVE_SETITIMER) || defined (HAVE_GETITIMER) ItimerError = PyErr_NewException("signal.ItimerError", PyExc_OSError, NULL); - if (ItimerError != NULL) - PyDict_SetItemString(d, "ItimerError", ItimerError); + if (PyModule_AddObject(m, "ItimerError", ItimerError)) + goto finally; #endif #ifdef CTRL_C_EVENT |