summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVictor Stinner <vstinner@python.org>2020-09-04 14:51:05 +0200
committerGitHub <noreply@github.com>2020-09-04 14:51:05 +0200
commit4b8032e5a4994a7902076efa72fca1e2c85d8b7f (patch)
treec8fa71748e52980541b23ae5698b77bf75ee3f58
parent54a66ade2067c373d31003ad260e1b7d14c81564 (diff)
downloadcpython-git-4b8032e5a4994a7902076efa72fca1e2c85d8b7f.tar.gz
bpo-41713: _signal doesn't use multi-phase init (GH-22087)
Partially revert commit 71d1bd9569c8a497e279f2fea6fe47cd70a87ea3: don't use multi-phase initialization (PEP 489) for the _signal extension module.
-rw-r--r--Misc/NEWS.d/next/Core and Builtins/2020-09-01-17-07-20.bpo-1635741.7wSuCc.rst1
-rw-r--r--Modules/signalmodule.c20
2 files changed, 13 insertions, 8 deletions
diff --git a/Misc/NEWS.d/next/Core and Builtins/2020-09-01-17-07-20.bpo-1635741.7wSuCc.rst b/Misc/NEWS.d/next/Core and Builtins/2020-09-01-17-07-20.bpo-1635741.7wSuCc.rst
deleted file mode 100644
index ff7cb35286..0000000000
--- a/Misc/NEWS.d/next/Core and Builtins/2020-09-01-17-07-20.bpo-1635741.7wSuCc.rst
+++ /dev/null
@@ -1 +0,0 @@
-Port the :mod:`_signal` extension module to multi-phase initialization (:pep:`489`).
diff --git a/Modules/signalmodule.c b/Modules/signalmodule.c
index 262f2b66a5..3440894b21 100644
--- a/Modules/signalmodule.c
+++ b/Modules/signalmodule.c
@@ -1649,26 +1649,32 @@ signal_exec(PyObject *m)
return 0;
}
-static PyModuleDef_Slot signal_slots[] = {
- {Py_mod_exec, signal_exec},
- {0, NULL}
-};
static struct PyModuleDef signalmodule = {
PyModuleDef_HEAD_INIT,
"_signal",
.m_doc = module_doc,
- .m_size = 0,
+ .m_size = -1,
.m_methods = signal_methods,
- .m_slots = signal_slots
};
+
PyMODINIT_FUNC
PyInit__signal(void)
{
- return PyModuleDef_Init(&signalmodule);
+ PyObject *mod = PyModule_Create(&signalmodule);
+ if (mod == NULL) {
+ return NULL;
+ }
+
+ if (signal_exec(mod) < 0) {
+ Py_DECREF(mod);
+ return NULL;
+ }
+ return mod;
}
+
static void
finisignal(void)
{