Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Inline _Py_RestoreSignals() from CPython #604

Merged
merged 2 commits into from
Aug 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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()
Loading