Blame SOURCES/604.patch

8e5576
From 118f595c322e387aa4b816d11fa7930f57537278 Mon Sep 17 00:00:00 2001
8e5576
From: Karolina Surma <ksurma@redhat.com>
8e5576
Date: Tue, 30 Apr 2024 14:22:08 +0200
8e5576
Subject: [PATCH] Inline _Py_RestoreSignals() from CPython
8e5576
8e5576
private _Py_RestoreSignals() has been moved to CPython internals as of Python 3.13
8e5576
See: https://github.com/python/cpython/pull/106400
8e5576
Its implementation has been the same in all supported by uvloop Pythons
8e5576
(3.8+), so the inlining was not conditionalized.
8e5576
---
8e5576
 uvloop/includes/compat.h   | 20 ++++++++++++++++++++
8e5576
 uvloop/includes/python.pxd |  4 ++--
8e5576
 2 files changed, 22 insertions(+), 2 deletions(-)
8e5576
8e5576
diff --git a/uvloop/includes/compat.h b/uvloop/includes/compat.h
8e5576
index 7ae39e73..0c408c9e 100644
8e5576
--- a/uvloop/includes/compat.h
8e5576
+++ b/uvloop/includes/compat.h
8e5576
@@ -1,5 +1,6 @@
8e5576
 #include <errno.h>
8e5576
 #include <stddef.h>
8e5576
+#include <signal.h>
8e5576
 #include <sys/socket.h>
8e5576
 #include <sys/un.h>
8e5576
 #include "Python.h"
8e5576
@@ -83,3 +84,22 @@ int Context_Exit(PyObject *ctx) {
8e5576
 }
8e5576
 
8e5576
 #endif
8e5576
+
8e5576
+/* inlined from cpython/Modules/signalmodule.c
8e5576
+ * https://github.com/python/cpython/blob/v3.13.0a6/Modules/signalmodule.c#L1931-L1951
8e5576
+ * private _Py_RestoreSignals has been moved to CPython internals in Python 3.13
8e5576
+ * https://github.com/python/cpython/pull/106400 */
8e5576
+
8e5576
+void
8e5576
+_Py_RestoreSignals(void)
8e5576
+{
8e5576
+#ifdef SIGPIPE
8e5576
+    PyOS_setsig(SIGPIPE, SIG_DFL);
8e5576
+#endif
8e5576
+#ifdef SIGXFZ
8e5576
+    PyOS_setsig(SIGXFZ, SIG_DFL);
8e5576
+#endif
8e5576
+#ifdef SIGXFSZ
8e5576
+    PyOS_setsig(SIGXFSZ, SIG_DFL);
8e5576
+#endif
8e5576
+}
8e5576
diff --git a/uvloop/includes/python.pxd b/uvloop/includes/python.pxd
8e5576
index 454d5c77..94007e53 100644
8e5576
--- a/uvloop/includes/python.pxd
8e5576
+++ b/uvloop/includes/python.pxd
8e5576
@@ -11,8 +11,6 @@ cdef extern from "Python.h":
8e5576
     object PyUnicode_EncodeFSDefault(object)
8e5576
     void PyErr_SetInterrupt() nogil
8e5576
 
8e5576
-    void _Py_RestoreSignals()
8e5576
-
8e5576
     object PyMemoryView_FromMemory(char *mem, ssize_t size, int flags)
8e5576
     object PyMemoryView_FromObject(object obj)
8e5576
     int PyMemoryView_Check(object obj)
8e5576
@@ -29,3 +27,5 @@ cdef extern from "includes/compat.h":
8e5576
     void PyOS_BeforeFork()
8e5576
     void PyOS_AfterFork_Parent()
8e5576
     void PyOS_AfterFork_Child()
8e5576
+
8e5576
+    void _Py_RestoreSignals()