From: Manoj Srivastava Date: Thu, 17 Jan 2019 19:08:56 +0000 (-0800) Subject: [python-3.7-fix]: Allow compilation with Python 3.7 X-Git-Url: https://git.octo.it/?p=collectd.git;a=commitdiff_plain;h=7e2f3e27e92640b1728a5d434b706e5c6a6ec704 [python-3.7-fix]: Allow compilation with Python 3.7 PyOS_AfterFork() is deprecated in favour of the new functions PyOS_BeforeFork(), PyOS_AfterFork_Parent() and PyOS_AfterFork_Child(). (Contributed by Antoine Pitrou in bpo-16500.) Since the -Werror=deprecated-declarations flag is on, the fact that PyOS_AfterFork is deprecated now results in a warning, and since all warnings being treated as errors, collectd fails to compile. This commit detects when we have python 3.7 or newer, and uses the new replacement function. Signed-off-by: Manoj Srivastava --- diff --git a/src/python.c b/src/python.c index 2c62146d..2f08bd34 100644 --- a/src/python.c +++ b/src/python.c @@ -1133,7 +1133,11 @@ static void *cpy_interactive(void *pipefd) { cpy_log_exception("interactive session init"); } cur_sig = PyOS_setsig(SIGINT, python_sigint_handler); +#if PY_VERSION_HEX < 0x03070000 PyOS_AfterFork(); +#else + PyOS_AfterFork_Child(); +#endif PyEval_InitThreads(); close(*(int *)pipefd); PyRun_InteractiveLoop(stdin, "");