You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
68 lines
2.1 KiB
68 lines
2.1 KiB
2 weeks ago
|
From 118f595c322e387aa4b816d11fa7930f57537278 Mon Sep 17 00:00:00 2001
|
||
|
From: Karolina Surma <ksurma@redhat.com>
|
||
|
Date: Tue, 30 Apr 2024 14:22:08 +0200
|
||
|
Subject: [PATCH] Inline _Py_RestoreSignals() from CPython
|
||
|
|
||
|
private _Py_RestoreSignals() has been moved to CPython internals as of Python 3.13
|
||
|
See: https://github.com/python/cpython/pull/106400
|
||
|
Its implementation has been the same in all supported by uvloop Pythons
|
||
|
(3.8+), so the inlining was not conditionalized.
|
||
|
---
|
||
|
uvloop/includes/compat.h | 20 ++++++++++++++++++++
|
||
|
uvloop/includes/python.pxd | 4 ++--
|
||
|
2 files changed, 22 insertions(+), 2 deletions(-)
|
||
|
|
||
|
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 <errno.h>
|
||
|
#include <stddef.h>
|
||
|
+#include <signal.h>
|
||
|
#include <sys/socket.h>
|
||
|
#include <sys/un.h>
|
||
|
#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()
|