From 451e6a7b971f16223927cc77a7b80a0022488e83 Mon Sep 17 00:00:00 2001 From: "Richard W.M. Jones" Date: Mon, 2 Sep 2019 08:55:00 +0100 Subject: [PATCH] python: Include in one place. Previously to work around some problems in Python 2 header files we had to include before any other config file. For Python 3 which is all we really care about now this is no longer needed. We can move the include from three files into the local "actions.h" file, bringing all the Python definitions and workarounds into a single place. --- generator/python.ml | 21 +++------------------ python/handle.c | 6 ------ 2 files changed, 3 insertions(+), 24 deletions(-) diff --git a/generator/python.ml b/generator/python.ml index 74acf5de8..ccf684693 100644 --- a/generator/python.ml +++ b/generator/python.ml @@ -44,6 +44,9 @@ let rec generate_python_actions_h () = #include \"guestfs.h\" #include \"guestfs-utils.h\" +#define PY_SSIZE_T_CLEAN 1 +#include + #if PY_VERSION_HEX < 0x02050000 typedef int Py_ssize_t; #define PY_SSIZE_T_MAX INT_MAX @@ -134,12 +137,6 @@ and generate_python_structs () = generate_header CStyle LGPLv2plus; pr "\ -/* This has to be included first, else definitions conflict with - * glibc header files. Python is broken. - */ -#define PY_SSIZE_T_CLEAN 1 -#include - #include #include @@ -272,12 +269,6 @@ and generate_python_actions actions () = generate_header CStyle LGPLv2plus; pr "\ -/* This has to be included first, else definitions conflict with - * glibc header files. Python is broken. - */ -#define PY_SSIZE_T_CLEAN 1 -#include - #include /* It is safe to call deprecated functions from this file. */ @@ -569,12 +560,6 @@ and generate_python_module () = generate_header CStyle LGPLv2plus; pr "\ -/* This has to be included first, else definitions conflict with - * glibc header files. Python is broken. - */ -#define PY_SSIZE_T_CLEAN 1 -#include - #include #include diff --git a/python/handle.c b/python/handle.c index adba1b823..ffd0794d8 100644 --- a/python/handle.c +++ b/python/handle.c @@ -22,12 +22,6 @@ * F). */ -/* This has to be included first, else definitions conflict with - * glibc header files. Python is broken. - */ -#define PY_SSIZE_T_CLEAN 1 -#include - #include #include