Skip to content

bpo-24011: Use PyModule_AddIntMacro in PyInit__signal() #12765

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Apr 22, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 5 additions & 7 deletions Modules/signalmodule.c
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down Expand Up @@ -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
Expand Down