gdb/python: remove Python 2/3 compatibility macros

New in this version:

 - Rebase on master, fix a few more issues that appeared.

python-internal.h contains a number of macros that helped make the code
work with both Python 2 and 3.  Remove them and adjust the code to use
the Python 3 functions.

Change-Id: I99a3d80067fb2d65de4f69f6473ba6ffd16efb2d
This commit is contained in:
Simon Marchi 2022-03-21 10:07:41 -04:00
parent edae3fd660
commit 5aee458796
25 changed files with 93 additions and 116 deletions

View file

@ -152,8 +152,8 @@ python_string_to_host_string (PyObject *obj)
gdbpy_ref<>
host_string_to_python_string (const char *str)
{
return gdbpy_ref<> (PyString_Decode (str, strlen (str), host_charset (),
NULL));
return gdbpy_ref<> (PyUnicode_Decode (str, strlen (str), host_charset (),
NULL));
}
/* Return true if OBJ is a Python string or unicode object, false
@ -294,13 +294,13 @@ gdb_py_object_from_ulongest (ULONGEST l)
return gdbpy_ref<> (PyLong_FromUnsignedLong (l));
}
/* Like PyInt_AsLong, but returns 0 on failure, 1 on success, and puts
/* Like PyLong_AsLong, but returns 0 on failure, 1 on success, and puts
the value into an out parameter. */
int
gdb_py_int_as_long (PyObject *obj, long *result)
{
*result = PyInt_AsLong (obj);
*result = PyLong_AsLong (obj);
return ! (*result == -1 && PyErr_Occurred ());
}