FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

bpo-46417: signal uses PyStructSequence_NewType() by vstinner · Pull Request #30735 · python/cpython · GitHub

/ cpython Public
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension .c  (1) All 1 file type selected
Viewed files
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Unified
Split
Hide whitespace
Diff view
Unified
Split
Hide whitespace
16 changes: 9 additions & 7 deletions Modules/signalmodule.c
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,7 @@ typedef struct {
#ifdef MS_WINDOWS
HANDLE sigint_event;
#endif
PyTypeObject *siginfo_type;
} signal_state_t;

// State shared by all Python interpreters
Expand Down Expand Up @@ -1136,12 +1137,13 @@ static PyStructSequence_Desc struct_siginfo_desc = {
7 /* n_in_sequence */
};

static PyTypeObject SiginfoType;

static PyObject *
fill_siginfo(siginfo_t *si)
{
PyObject *result = PyStructSequence_New(&SiginfoType);
signal_state_t *state = &signal_global_state;

PyObject *result = PyStructSequence_New(state->siginfo_type);
if (!result)
return NULL;

Expand Down Expand Up @@ -1660,7 +1662,7 @@ signal_module_exec(PyObject *m)
}
#endif
#if defined(HAVE_SIGWAITINFO) || defined(HAVE_SIGTIMEDWAIT)
if (PyModule_AddType(m, &SiginfoType) < 0) {
if (PyModule_AddType(m, state->siginfo_type) < 0) {
return -1;
}
#endif
Expand Down Expand Up @@ -1758,6 +1760,7 @@ _PySignal_Fini(void)

Py_CLEAR(state->default_handler);
Py_CLEAR(state->ignore_handler);
Py_CLEAR(state->siginfo_type);
}


Expand Down Expand Up @@ -1966,10 +1969,9 @@ _PySignal_Init(int install_signal_handlers)
#endif

#if defined(HAVE_SIGWAITINFO) || defined(HAVE_SIGTIMEDWAIT)
if (SiginfoType.tp_name == NULL) {
if (PyStructSequence_InitType2(&SiginfoType, &struct_siginfo_desc) < 0) {
return -1;
}
state->siginfo_type = PyStructSequence_NewType(&struct_siginfo_desc);
if (state->siginfo_type == NULL) {
return -1;
}
#endif

Expand Down

Back | FazBrowse Home | New Git URL