Skip to content

Commit 8511ba1

Browse files
authored
Inline _Py_RestoreSignals() from CPython (#604)
private _Py_RestoreSignals() has been moved to CPython internals as of Python 3.13 See: python/cpython#106400 Its implementation has been the same in all supported by uvloop Pythons (3.8+), so the inlining was not conditionalized.
1 parent deb2cf9 commit 8511ba1

File tree

2 files changed

+22
-2
lines changed

2 files changed

+22
-2
lines changed

uvloop/includes/compat.h

+20
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
#include <errno.h>
22
#include <stddef.h>
3+
#include <signal.h>
34
#include <sys/socket.h>
45
#include <sys/un.h>
56
#include "Python.h"
@@ -83,3 +84,22 @@ int Context_Exit(PyObject *ctx) {
8384
}
8485

8586
#endif
87+
88+
/* inlined from cpython/Modules/signalmodule.c
89+
* https://github.com/python/cpython/blob/v3.13.0a6/Modules/signalmodule.c#L1931-L1951
90+
* private _Py_RestoreSignals has been moved to CPython internals in Python 3.13
91+
* https://github.com/python/cpython/pull/106400 */
92+
93+
void
94+
_Py_RestoreSignals(void)
95+
{
96+
#ifdef SIGPIPE
97+
PyOS_setsig(SIGPIPE, SIG_DFL);
98+
#endif
99+
#ifdef SIGXFZ
100+
PyOS_setsig(SIGXFZ, SIG_DFL);
101+
#endif
102+
#ifdef SIGXFSZ
103+
PyOS_setsig(SIGXFSZ, SIG_DFL);
104+
#endif
105+
}

uvloop/includes/python.pxd

+2-2
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)