From 18d9769dc32fe65867ff904db7636b1255f8d59c Mon Sep 17 00:00:00 2001 From: "Richard W.M. Jones" Date: Thu, 20 Nov 2025 20:56:34 +0000 Subject: [PATCH] python: Include first Python is broken and requires that we include before all other headers so it can make inadvisable definitions of _POSIX_C_SOURCE and other things. This wasn't a problem before, but a recent change to glibc makes this necessary now. See also a similar commit in nbdkit: https://gitlab.com/nbdkit/nbdkit/-/commit/f924c3c34be8352070b99c7b02fd200088b2a885 I also removed the -Wcast-align suppression as that is no longer needed. --- generator/python.ml | 25 +++++++++++++++---------- python/handle.c | 4 ++++ 2 files changed, 19 insertions(+), 10 deletions(-) diff --git a/generator/python.ml b/generator/python.ml index d712e21af..3be24e8c7 100644 --- a/generator/python.ml +++ b/generator/python.ml @@ -43,13 +43,6 @@ let rec generate_python_actions_h () = #include "guestfs.h" #include "guestfs-stringlists-utils.h" -#define PY_SSIZE_T_CLEAN 1 - -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wcast-align" -#include -#pragma GCC diagnostic pop - static inline guestfs_h * get_handle (PyObject *obj) { @@ -117,7 +110,11 @@ extern char *guestfs_int_py_asstring (PyObject *obj); and generate_python_structs () = generate_header CStyle LGPLv2plus; - pr {|#include + pr {|/* This must be included first. */ +#define PY_SSIZE_T_CLEAN 1 +#include + +#include #include #include @@ -252,7 +249,11 @@ and generate_python_structs () = and generate_python_actions actions () = generate_header CStyle LGPLv2plus; - pr {|#include + pr {|/* This must be included first. */ +#define PY_SSIZE_T_CLEAN 1 +#include + +#include /* It is safe to call deprecated functions from this file. */ #define GUESTFS_NO_WARN_DEPRECATED @@ -523,7 +524,11 @@ and generate_python_actions actions () = and generate_python_module () = generate_header CStyle LGPLv2plus; - pr {|#include + pr {|/* This must be included first. */ +#define PY_SSIZE_T_CLEAN 1 +#include + +#include #include #include diff --git a/python/handle.c b/python/handle.c index fcfcb5c30..9b1d01f5a 100644 --- a/python/handle.c +++ b/python/handle.c @@ -22,6 +22,10 @@ * F). */ +/* This must be included first. */ +#define PY_SSIZE_T_CLEAN 1 +#include + #include #include