mirror of
https://github.com/libguestfs/libguestfs.git
synced 2026-03-21 22:53:37 +00:00
python: remove compile time check for PyString_AsString
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.
This commit is contained in:
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user