Skip to content

Commit 7df5b2d

Browse files
committed
Inline _Py_RestoreSignals() from CPython
private _Py_RestoreSignals() has been moved to CPython internals as of Python 3.13 See: python/cpython#106400
1 parent 6c770dc commit 7df5b2d

File tree

2 files changed

+29
-2
lines changed

2 files changed

+29
-2
lines changed

uvloop/includes/compat.h

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,3 +83,30 @@ int Context_Exit(PyObject *ctx) {
8383
}
8484

8585
#endif
86+
87+
/* inlined from cpython/Modules/signalmodule.c
88+
* https://github.com/python/cpython/blob/v3.13.0a6/Modules/signalmodule.c#L1931-L1951
89+
* private _Py_RestoreSignals has been moved to CPython internals in Python 3.13
90+
* https://github.com/python/cpython/pull/106400 */
91+
92+
/* Restore signals that the interpreter has called SIG_IGN on to SIG_DFL.
93+
*
94+
* All of the code in this function must only use async-signal-safe functions,
95+
* listed at `man 7 signal` or
96+
* http://www.opengroup.org/onlinepubs/009695399/functions/xsh_chap02_04.html.
97+
*
98+
* If this function is updated, update also _posix_spawn() of subprocess.py.
99+
*/
100+
void
101+
_Py_RestoreSignals(void)
102+
{
103+
#ifdef SIGPIPE
104+
PyOS_setsig(SIGPIPE, SIG_DFL);
105+
#endif
106+
#ifdef SIGXFZ
107+
PyOS_setsig(SIGXFZ, SIG_DFL);
108+
#endif
109+
#ifdef SIGXFSZ
110+
PyOS_setsig(SIGXFSZ, SIG_DFL);
111+
#endif
112+
}

uvloop/includes/python.pxd

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,6 @@ cdef extern from "Python.h":
1111
object PyUnicode_EncodeFSDefault(object)
1212
void PyErr_SetInterrupt() nogil
1313

14-
void _Py_RestoreSignals()
15-
1614
object PyMemoryView_FromMemory(char *mem, ssize_t size, int flags)
1715
object PyMemoryView_FromObject(object obj)
1816
int PyMemoryView_Check(object obj)
@@ -29,3 +27,5 @@ cdef extern from "includes/compat.h":
2927
void PyOS_BeforeFork()
3028
void PyOS_AfterFork_Parent()
3129
void PyOS_AfterFork_Child()
30+
31+
void _Py_RestoreSignals()

0 commit comments

Comments
 (0)