From 5aee45879681a7a76754a25b3f4f96b4529f7ae3 Mon Sep 17 00:00:00 2001 From: Simon Marchi Date: Mon, 21 Mar 2022 10:07:41 -0400 Subject: 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 --- gdb/python/py-arch.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) (limited to 'gdb/python/py-arch.c') diff --git a/gdb/python/py-arch.c b/gdb/python/py-arch.c index cc217df..d8098a2 100644 --- a/gdb/python/py-arch.c +++ b/gdb/python/py-arch.c @@ -109,7 +109,7 @@ archpy_name (PyObject *self, PyObject *args) ARCHPY_REQUIRE_VALID (self, gdbarch); name = (gdbarch_bfd_arch_info (gdbarch))->printable_name; - return PyString_FromString (name); + return PyUnicode_FromString (name); } /* Implementation of @@ -167,7 +167,7 @@ archpy_disassemble (PyObject *self, PyObject *args, PyObject *kw) } if (count_obj) { - count = PyInt_AsLong (count_obj); + count = PyLong_AsLong (count_obj); if (PyErr_Occurred () || count < 0) { PyErr_SetString (PyExc_TypeError, @@ -216,9 +216,8 @@ archpy_disassemble (PyObject *self, PyObject *args, PyObject *kw) if (pc_obj == nullptr) return nullptr; - gdbpy_ref<> asm_obj (PyString_FromString (!stb.empty () - ? stb.c_str () - : "")); + gdbpy_ref<> asm_obj + (PyUnicode_FromString (!stb.empty () ? stb.c_str () : "")); if (asm_obj == nullptr) return nullptr; @@ -341,7 +340,7 @@ gdbpy_all_architecture_names (PyObject *self, PyObject *args) std::vector name_list = gdbarch_printable_names (); for (const char *name : name_list) { - gdbpy_ref <> py_name (PyString_FromString (name)); + gdbpy_ref <> py_name (PyUnicode_FromString (name)); if (py_name == nullptr) return nullptr; if (PyList_Append (list.get (), py_name.get ()) < 0) -- cgit v1.1