collectd: fix build with Python 3.11

This commit is contained in:
Đoàn Trần Công Danh 2022-09-21 22:18:07 +07:00
parent 9fe1de5f02
commit cdd4be04e6
2 changed files with 52 additions and 0 deletions

View File

@ -0,0 +1,42 @@
From 17d2fbe443b656bb0f74c204eb003cea22f94e60 Mon Sep 17 00:00:00 2001
From: Paul <itsascambutmailmeanyway@gmail.com>
Date: Fri, 18 Jun 2021 14:48:29 +0200
Subject: [PATCH] ChangeLog: python: Fix compile-time errors about deprecation
via ifdefs.
---
src/python.c | 12 ++++++++++++
1 file changed, 12 insertions(+)
diff --git a/src/python.c b/src/python.c
index 119ffe21742..318883ecfff 100644
--- a/src/python.c
+++ b/src/python.c
@@ -1141,7 +1141,13 @@ static void *cpy_interactive(void *pipefd) {
#else
PyOS_AfterFork_Child();
#endif
+#if PY_VERSION_HEX < 0x03090000
+ // deprecated. Called by Py_Initialize(). Removed in Py3.11
+ // https://docs.python.org/3/c-api/init.html#c.PyEval_InitThreads
PyEval_InitThreads();
+#else
+ Py_Initialize();
+#endif
close(*(int *)pipefd);
PyRun_InteractiveLoop(stdin, "<stdin>");
PyOS_setsig(SIGINT, cur_sig);
@@ -1178,7 +1184,13 @@ static int cpy_init(void) {
;
(void)close(pipefd[0]);
} else {
+#if PY_VERSION_HEX < 0x03090000
+ // deprecated. Called by Py_Initialize(). Removed in Py3.11
+ // https://docs.python.org/3/c-api/init.html#c.PyEval_InitThreads
PyEval_InitThreads();
+#else
+ Py_Initialize();
+#endif
state = PyEval_SaveThread();
}
CPY_LOCK_THREADS

View File

@ -0,0 +1,10 @@
--- a/src/cpython.h
+++ b/src/cpython.h
@@ -26,7 +26,6 @@
/* Some python versions don't include this by default. */
-#include <longintrepr.h>
/* These two macros are basically Py_BEGIN_ALLOW_THREADS and
* Py_BEGIN_ALLOW_THREADS