diff --git a/generator/python.ml b/generator/python.ml index 86b70b2de..06728235f 100644 --- a/generator/python.ml +++ b/generator/python.ml @@ -44,13 +44,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) { @@ -119,6 +112,10 @@ and generate_python_structs () = generate_header CStyle LGPLv2plus; pr "\ +/* This must be included first. */ +#define PY_SSIZE_T_CLEAN 1 +#include + #include #include @@ -255,6 +252,10 @@ and generate_python_actions actions () = generate_header CStyle LGPLv2plus; pr "\ +/* This must be included first. */ +#define PY_SSIZE_T_CLEAN 1 +#include + #include /* It is safe to call deprecated functions from this file. */ @@ -527,6 +528,10 @@ and generate_python_module () = generate_header CStyle LGPLv2plus; pr "\ +/* This must be included first. */ +#define PY_SSIZE_T_CLEAN 1 +#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