bpo-1635741 port signalmodule to multi-phase init (PEP 489)#22049
Conversation
|
@vstinner @shihai1991 I split this from the other PR |
| return -1; | ||
| } | ||
| Py_INCREF((PyObject*) &SiginfoType); | ||
| PyModule_AddObject(m, "struct_siginfo", (PyObject*) &SiginfoType); |
There was a problem hiding this comment.
Please check for error. On error, DECREF is needed.
| @@ -0,0 +1,2 @@ | |||
| Port the :mod:`signalmodule` extension module to multi-phase initialization | |||
There was a problem hiding this comment.
The module is called "_signal":
| Port the :mod:`signalmodule` extension module to multi-phase initialization | |
| Port the :mod:`_signal` extension module to multi-phase initialization | |
| /* add the functions */ | ||
| #if defined(HAVE_SIGWAITINFO) || defined(HAVE_SIGTIMEDWAIT) | ||
| if (!initialized) { | ||
| if (PyStructSequence_InitType2(&SiginfoType, &struct_siginfo_desc) < 0) |
There was a problem hiding this comment.
I would be nice to convert the static type SiginfoType to a heap type, but it can be done later.
There was a problem hiding this comment.
@vstinner what is the procedure for types defined using PyStructSequence_InitType2?
| return -1; | ||
| } | ||
| Py_INCREF((PyObject*) &SiginfoType); | ||
| PyModule_AddObject(m, "struct_siginfo", (PyObject*) &SiginfoType); |
There was a problem hiding this comment.
Maybe you can use PyModule_AddType() in here?
There was a problem hiding this comment.
@shihai1991 good idea, this simplifies the error handling too.
|
This change introduced a regression: https://bugs.python.org/issue41713 |
|
I partially reverted this change with PR #22087 to quickly fix https://bugs.python.org/issue41713. |
https://bugs.python.org/issue1635741