python: Drop support for Python 2.

Python 2 reached end of life on 2020-01-01:
https://python3statement.org/
https://pythonclock.org/

The minimum version required is now Python 3.4 (since that is the
version in Debian oldoldstable), but 3.6 is the minimum version that
I actually test.
This commit is contained in:
Richard W.M. Jones
2020-07-06 12:02:01 +01:00
parent 38e2ad1fbc
commit 403d17a876
4 changed files with 24 additions and 69 deletions

View File

@@ -384,30 +384,18 @@ guestfs_int_py_put_table (char * const * const argv)
PyObject *
guestfs_int_py_fromstring (const char *str)
{
#if PY_MAJOR_VERSION < 3
return PyString_FromString (str);
#else
return PyUnicode_FromString (str);
#endif
}
PyObject *
guestfs_int_py_fromstringsize (const char *str, size_t size)
{
#if PY_MAJOR_VERSION < 3
return PyString_FromStringAndSize (str, size);
#else
return PyUnicode_FromStringAndSize (str, size);
#endif
}
char *
guestfs_int_py_asstring (PyObject *obj)
{
#if PY_MAJOR_VERSION < 3
return PyString_AsString (obj);
#else
PyObject *bytes = PyUnicode_AsUTF8String (obj);
return PyBytes_AS_STRING (bytes);
#endif
}