[Libguestfs] [PATCH 3/7] python: assume support for Capsules

Pino Toscano ptoscano at redhat.com
Thu Jan 9 17:37:46 UTC 2020


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 <Python.h>
 #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.])],
-- 
2.24.1




More information about the Libguestfs mailing list