Skip to content

Commit

Permalink
Inline _Py_RestoreSignals() from CPython
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
  • Loading branch information
befeleme committed Apr 30, 2024
1 parent 6c770dc commit 1b9e60d
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
Expand Up @@ -4,6 +4,7 @@
#include <sys/un.h>
#include "Python.h"
#include "uv.h"
#include <signal.h>


#ifndef EWOULDBLOCK
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 1b9e60d

Please sign in to comment.