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