diff --git a/uvloop/includes/compat.h b/uvloop/includes/compat.h index 7ae39e73..0c408c9e 100644 --- a/uvloop/includes/compat.h +++ b/uvloop/includes/compat.h @@ -1,5 +1,6 @@ #include #include +#include #include #include #include "Python.h" @@ -83,3 +84,22 @@ int Context_Exit(PyObject *ctx) { } #endif + +/* inlined from cpython/Modules/signalmodule.c + * https://github.com/python/cpython/blob/v3.13.0a6/Modules/signalmodule.c#L1931-L1951 + * private _Py_RestoreSignals has been moved to CPython internals in Python 3.13 + * https://github.com/python/cpython/pull/106400 */ + +void +_Py_RestoreSignals(void) +{ +#ifdef SIGPIPE + PyOS_setsig(SIGPIPE, SIG_DFL); +#endif +#ifdef SIGXFZ + PyOS_setsig(SIGXFZ, SIG_DFL); +#endif +#ifdef SIGXFSZ + PyOS_setsig(SIGXFSZ, SIG_DFL); +#endif +} diff --git a/uvloop/includes/python.pxd b/uvloop/includes/python.pxd index 454d5c77..94007e53 100644 --- a/uvloop/includes/python.pxd +++ b/uvloop/includes/python.pxd @@ -11,8 +11,6 @@ cdef extern from "Python.h": object PyUnicode_EncodeFSDefault(object) void PyErr_SetInterrupt() nogil - void _Py_RestoreSignals() - object PyMemoryView_FromMemory(char *mem, ssize_t size, int flags) object PyMemoryView_FromObject(object obj) int PyMemoryView_Check(object obj) @@ -29,3 +27,5 @@ cdef extern from "includes/compat.h": void PyOS_BeforeFork() void PyOS_AfterFork_Parent() void PyOS_AfterFork_Child() + + void _Py_RestoreSignals()