From c3728416fb147ebc4be19c7e5566addb8485fdda Mon Sep 17 00:00:00 2001 From: Pino Toscano Date: Thu, 9 Jan 2020 17:29:15 +0100 Subject: [PATCH] python: assume support for Capsules They were introduced in Python 2.7 and 3.1, so we can assume they exist (as Python 2.7 is the minimum version required, and 3.0 is long gone). --- generator/python.ml | 16 ---------------- m4/guestfs-python.m4 | 4 ---- 2 files changed, 20 deletions(-) diff --git a/generator/python.ml b/generator/python.ml index 750d9c675..2a1a48fc0 100644 --- a/generator/python.ml +++ b/generator/python.ml @@ -51,35 +51,19 @@ let rec generate_python_actions_h () = #include #pragma GCC diagnostic pop -#ifndef HAVE_PYCAPSULE_NEW -typedef struct { - PyObject_HEAD - guestfs_h *g; -} Pyguestfs_Object; -#endif - static inline guestfs_h * get_handle (PyObject *obj) { assert (obj); assert (obj != Py_None); -#ifndef HAVE_PYCAPSULE_NEW - return ((Pyguestfs_Object *) obj)->g; -#else return (guestfs_h*) PyCapsule_GetPointer(obj, \"guestfs_h\"); -#endif } static inline PyObject * put_handle (guestfs_h *g) { assert (g); -#ifndef HAVE_PYCAPSULE_NEW - return - PyCObject_FromVoidPtrAndDesc ((void *) g, (char *) \"guestfs_h\", NULL); -#else return PyCapsule_New ((void *) g, \"guestfs_h\", NULL); -#endif } extern void guestfs_int_py_extend_module (PyObject *module); diff --git a/m4/guestfs-python.m4 b/m4/guestfs-python.m4 index 1d7849894..35dc19fa6 100644 --- a/m4/guestfs-python.m4 +++ b/m4/guestfs-python.m4 @@ -92,10 +92,6 @@ AS_IF([test "x$enable_python" != "xno"],[ PYTHON_BLDLIBRARY=`$PYTHON -c "import distutils.sysconfig; \ print (distutils.sysconfig.get_config_var('BLDLIBRARY'))"` - AC_CHECK_LIB([c],[PyCapsule_New], - [AC_DEFINE([HAVE_PYCAPSULE_NEW],1, - [Found PyCapsule_New in libpython.])], - [],[$PYTHON_BLDLIBRARY]) AC_CHECK_LIB([c],[PyString_AsString], [AC_DEFINE([HAVE_PYSTRING_ASSTRING],1, [Found PyString_AsString in libpython.])],