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-param.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) (limited to 'gdb/python/py-param.c') diff --git a/gdb/python/py-param.c b/gdb/python/py-param.c index 6be771c..d0dd2a9 100644 --- a/gdb/python/py-param.c +++ b/gdb/python/py-param.c @@ -125,7 +125,7 @@ static PyObject *show_doc_cst; static PyObject * get_attr (PyObject *obj, PyObject *attr_name) { - if (PyString_Check (attr_name) + if (PyUnicode_Check (attr_name) && ! PyUnicode_CompareWithASCIIString (attr_name, "value")) { parmpy_object *self = (parmpy_object *) obj; @@ -243,7 +243,7 @@ set_parameter_value (parmpy_object *self, PyObject *value) long l; int ok; - if (! PyInt_Check (value)) + if (!PyLong_Check (value)) { PyErr_SetString (PyExc_RuntimeError, _("The value must be integer.")); @@ -308,7 +308,7 @@ set_parameter_value (parmpy_object *self, PyObject *value) static int set_attr (PyObject *obj, PyObject *attr_name, PyObject *val) { - if (PyString_Check (attr_name) + if (PyUnicode_Check (attr_name) && ! PyUnicode_CompareWithASCIIString (attr_name, "value")) { if (!val) @@ -447,7 +447,7 @@ get_set_value (const char *args, int from_tty, gdb::unique_xmalloc_ptr set_doc_string; gdbpy_enter enter_py; - gdbpy_ref<> set_doc_func (PyString_FromString ("get_set_string")); + gdbpy_ref<> set_doc_func (PyUnicode_FromString ("get_set_string")); if (set_doc_func == NULL) { @@ -482,7 +482,7 @@ get_show_value (struct ui_file *file, int from_tty, gdb::unique_xmalloc_ptr show_doc_string; gdbpy_enter enter_py; - gdbpy_ref<> show_doc_func (PyString_FromString ("get_show_string")); + gdbpy_ref<> show_doc_func (PyUnicode_FromString ("get_show_string")); if (show_doc_func == NULL) { @@ -492,7 +492,7 @@ get_show_value (struct ui_file *file, int from_tty, if (PyObject_HasAttr (obj, show_doc_func.get ())) { - gdbpy_ref<> val_obj (PyString_FromString (value)); + gdbpy_ref<> val_obj (PyUnicode_FromString (value)); if (val_obj == NULL) { @@ -835,10 +835,10 @@ gdbpy_initialize_parameters (void) if (PyType_Ready (&parmpy_object_type) < 0) return -1; - set_doc_cst = PyString_FromString ("set_doc"); + set_doc_cst = PyUnicode_FromString ("set_doc"); if (! set_doc_cst) return -1; - show_doc_cst = PyString_FromString ("show_doc"); + show_doc_cst = PyUnicode_FromString ("show_doc"); if (! show_doc_cst) return -1; -- cgit v1.1