Skip to content

Commit

Permalink
Inline _Py_RestoreSignals() from CPython (#604)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
befeleme authored Aug 15, 2024
1 parent deb2cf9 commit 8511ba1
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 2 deletions.
20 changes: 20 additions & 0 deletions uvloop/includes/compat.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#include <errno.h>
#include <stddef.h>
#include <signal.h>
#include <sys/socket.h>
#include <sys/un.h>
#include "Python.h"
Expand Down Expand Up @@ -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
}
4 changes: 2 additions & 2 deletions uvloop/includes/python.pxd
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -29,3 +27,5 @@ cdef extern from "includes/compat.h":
void PyOS_BeforeFork()
void PyOS_AfterFork_Parent()
void PyOS_AfterFork_Child()

void _Py_RestoreSignals()

0 comments on commit 8511ba1

Please sign in to comment.