diff options
author | Simon Marchi <simon.marchi@efficios.com> | 2022-03-21 10:07:41 -0400 |
---|---|---|
committer | Simon Marchi <simon.marchi@efficios.com> | 2022-03-23 07:42:57 -0400 |
commit | 5aee45879681a7a76754a25b3f4f96b4529f7ae3 (patch) | |
tree | 04698477d38cf45871c7542eea6ce6a8d2b46a18 /gdb/python/python.c | |
parent | edae3fd6600f10f9e16dc017b705959f541ed19a (diff) | |
download | gdb-5aee45879681a7a76754a25b3f4f96b4529f7ae3.zip gdb-5aee45879681a7a76754a25b3f4f96b4529f7ae3.tar.gz gdb-5aee45879681a7a76754a25b3f4f96b4529f7ae3.tar.bz2 |
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
Diffstat (limited to 'gdb/python/python.c')
-rw-r--r-- | gdb/python/python.c | 26 |
1 files changed, 13 insertions, 13 deletions
diff --git a/gdb/python/python.c b/gdb/python/python.c index dc4edaa..f0d788b 100644 --- a/gdb/python/python.c +++ b/gdb/python/python.c @@ -685,7 +685,7 @@ execute_gdb_command (PyObject *self, PyObject *args, PyObject *kw) } if (to_string) - return PyString_FromString (to_string_res.c_str ()); + return PyUnicode_FromString (to_string_res.c_str ()); Py_RETURN_NONE; } @@ -931,7 +931,7 @@ gdbpy_decode_line (PyObject *self, PyObject *args) if (arg != NULL && strlen (arg) > 0) { - unparsed.reset (PyString_FromString (arg)); + unparsed.reset (PyUnicode_FromString (arg)); if (unparsed == NULL) return NULL; } @@ -1093,7 +1093,7 @@ gdbpy_before_prompt_hook (const struct extension_language_defn *extlang, if (PyCallable_Check (hook.get ())) { - gdbpy_ref<> current_prompt (PyString_FromString (current_gdb_prompt)); + gdbpy_ref<> current_prompt (PyUnicode_FromString (current_gdb_prompt)); if (current_prompt == NULL) { gdbpy_print_stack (); @@ -1112,7 +1112,7 @@ gdbpy_before_prompt_hook (const struct extension_language_defn *extlang, /* Return type should be None, or a String. If it is None, fall through, we will not set a prompt. If it is a string, set PROMPT. Anything else, set an exception. */ - if (result != Py_None && ! PyString_Check (result.get ())) + if (result != Py_None && !PyUnicode_Check (result.get ())) { PyErr_Format (PyExc_RuntimeError, _("Return from prompt_hook must " \ @@ -1171,7 +1171,7 @@ gdbpy_colorize (const std::string &filename, const std::string &contents) if (!PyCallable_Check (hook.get ())) return {}; - gdbpy_ref<> fname_arg (PyString_FromString (filename.c_str ())); + gdbpy_ref<> fname_arg (PyUnicode_FromString (filename.c_str ())); if (fname_arg == nullptr) { gdbpy_print_stack (); @@ -1385,7 +1385,7 @@ gdbpy_format_address (PyObject *self, PyObject *args, PyObject *kw) /* Format the address, and return it as a string. */ string_file buf; print_address (gdbarch, addr, &buf); - return PyString_FromString (buf.c_str ()); + return PyUnicode_FromString (buf.c_str ()); } @@ -2081,22 +2081,22 @@ do_start_initialization () #include "py-event-types.def" #undef GDB_PY_DEFINE_EVENT_TYPE - gdbpy_to_string_cst = PyString_FromString ("to_string"); + gdbpy_to_string_cst = PyUnicode_FromString ("to_string"); if (gdbpy_to_string_cst == NULL) return false; - gdbpy_children_cst = PyString_FromString ("children"); + gdbpy_children_cst = PyUnicode_FromString ("children"); if (gdbpy_children_cst == NULL) return false; - gdbpy_display_hint_cst = PyString_FromString ("display_hint"); + gdbpy_display_hint_cst = PyUnicode_FromString ("display_hint"); if (gdbpy_display_hint_cst == NULL) return false; - gdbpy_doc_cst = PyString_FromString ("__doc__"); + gdbpy_doc_cst = PyUnicode_FromString ("__doc__"); if (gdbpy_doc_cst == NULL) return false; - gdbpy_enabled_cst = PyString_FromString ("enabled"); + gdbpy_enabled_cst = PyUnicode_FromString ("enabled"); if (gdbpy_enabled_cst == NULL) return false; - gdbpy_value_cst = PyString_FromString ("value"); + gdbpy_value_cst = PyUnicode_FromString ("value"); if (gdbpy_value_cst == NULL) return false; @@ -2311,7 +2311,7 @@ do_initialize (const struct extension_language_defn *extlang) } if (sys_path && PyList_Check (sys_path)) { - gdbpy_ref<> pythondir (PyString_FromString (gdb_pythondir.c_str ())); + gdbpy_ref<> pythondir (PyUnicode_FromString (gdb_pythondir.c_str ())); if (pythondir == NULL || PyList_Insert (sys_path, 0, pythondir.get ())) return false; } |