python: Include <Python.h> in one place.

Previously to work around some problems in Python 2 header files we
had to include <Python.h> 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.
This commit is contained in:
Richard W.M. Jones
2019-09-02 08:55:00 +01:00
parent 2581d3c25e
commit 451e6a7b97
2 changed files with 3 additions and 24 deletions

View File

@@ -44,6 +44,9 @@ let rec generate_python_actions_h () =
#include \"guestfs.h\"
#include \"guestfs-utils.h\"
#define PY_SSIZE_T_CLEAN 1
#include <Python.h>
#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 <Python.h>
#include <config.h>
#include <stdio.h>
@@ -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 <Python.h>
#include <config.h>
/* 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 <Python.h>
#include <config.h>
#include <stdio.h>

View File

@@ -22,12 +22,6 @@
* F<python/actions-*.c>).
*/
/* This has to be included first, else definitions conflict with
* glibc header files. Python is broken.
*/
#define PY_SSIZE_T_CLEAN 1
#include <Python.h>
#include <config.h>
#include <stdio.h>