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

@ -233,7 +233,7 @@ cmdpy_completer_handle_brkchars (struct cmd_list_element *command,
if (resultobj == NULL)
return;
if (PyInt_Check (resultobj.get ()))
if (PyLong_Check (resultobj.get ()))
{
/* User code may also return one of the completion constants,
thus requesting that sort of completion. We are only
@ -277,7 +277,7 @@ cmdpy_completer (struct cmd_list_element *command,
if (resultobj == NULL)
return;
if (PyInt_Check (resultobj.get ()))
if (PyLong_Check (resultobj.get ()))
{
/* User code may also return one of the completion constants,
thus requesting that sort of completion. */
@ -592,10 +592,10 @@ gdbpy_initialize_commands (void)
(PyObject *) &cmdpy_object_type) < 0)
return -1;
invoke_cst = PyString_FromString ("invoke");
invoke_cst = PyUnicode_FromString ("invoke");
if (invoke_cst == NULL)
return -1;
complete_cst = PyString_FromString ("complete");
complete_cst = PyUnicode_FromString ("complete");
if (complete_cst == NULL)
return -1;
@ -684,7 +684,7 @@ gdbpy_string_to_argv (PyObject *self, PyObject *args)
for (char *arg : c_argv)
{
gdbpy_ref<> argp (PyString_FromString (arg));
gdbpy_ref<> argp (PyUnicode_FromString (arg));
if (argp == NULL
|| PyList_Append (py_argv.get (), argp.get ()) < 0)