The PyString API is specific to Python < 3, replaced by PyBytes and
PyUnicode in Python 3+; hence, drop the compile time check, and use the
right API depending on the Python version.
---
m4/guestfs-python.m4 | 12 ------------
python/handle.c | 6 +++---
2 files changed, 3 insertions(+), 15 deletions(-)
diff --git a/m4/guestfs-python.m4 b/m4/guestfs-python.m4
index 35dc19fa6..ac857915f 100644
--- a/m4/guestfs-python.m4
+++ b/m4/guestfs-python.m4
@@ -86,18 +86,6 @@ AS_IF([test "x$enable_python" != "xno"],[
PYTHON_EXT_SUFFIX=$python_ext_suffix
fi
AC_MSG_RESULT([$PYTHON_EXT_SUFFIX])
-
- dnl Look for some optional symbols in libpython.
- old_LIBS="$LIBS"
-
- PYTHON_BLDLIBRARY=`$PYTHON -c "import distutils.sysconfig; \
- print
(distutils.sysconfig.get_config_var('BLDLIBRARY'))"`
- AC_CHECK_LIB([c],[PyString_AsString],
- [AC_DEFINE([HAVE_PYSTRING_ASSTRING],1,
- [Found PyString_AsString in libpython.])],
- [],[$PYTHON_BLDLIBRARY])
-
- LIBS="$old_LIBS"
fi
AC_SUBST(PYTHON_PREFIX)
diff --git a/python/handle.c b/python/handle.c
index ccf6eb643..21077bba9 100644
--- a/python/handle.c
+++ b/python/handle.c
@@ -382,7 +382,7 @@ guestfs_int_py_put_table (char * const * const argv)
PyObject *
guestfs_int_py_fromstring (const char *str)
{
-#ifdef HAVE_PYSTRING_ASSTRING
+#if PY_MAJOR_VERSION < 3
return PyString_FromString (str);
#else
return PyUnicode_FromString (str);
@@ -392,7 +392,7 @@ guestfs_int_py_fromstring (const char *str)
PyObject *
guestfs_int_py_fromstringsize (const char *str, size_t size)
{
-#ifdef HAVE_PYSTRING_ASSTRING
+#if PY_MAJOR_VERSION < 3
return PyString_FromStringAndSize (str, size);
#else
return PyUnicode_FromStringAndSize (str, size);
@@ -402,7 +402,7 @@ guestfs_int_py_fromstringsize (const char *str, size_t size)
char *
guestfs_int_py_asstring (PyObject *obj)
{
-#ifdef HAVE_PYSTRING_ASSTRING
+#if PY_MAJOR_VERSION < 3
return PyString_AsString (obj);
#else
PyObject *bytes = PyUnicode_AsUTF8String (obj);
--
2.24.1