diff options
Diffstat (limited to 'gdb/python/py-prettyprint.c')
-rw-r--r-- | gdb/python/py-prettyprint.c | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/gdb/python/py-prettyprint.c b/gdb/python/py-prettyprint.c index 00fe7a9..dea1319 100644 --- a/gdb/python/py-prettyprint.c +++ b/gdb/python/py-prettyprint.c @@ -348,8 +348,13 @@ print_string_repr (PyObject *printer, const char *hint, struct type *type; make_cleanup_py_decref (string); +#ifdef IS_PY3K + output = (gdb_byte *) PyBytes_AS_STRING (string); + length = PyBytes_GET_SIZE (string); +#else output = PyString_AsString (string); length = PyString_Size (string); +#endif type = builtin_type (gdbarch)->builtin_char; if (hint && !strcmp (hint, "string")) @@ -383,6 +388,7 @@ print_string_repr (PyObject *printer, const char *hint, return result; } +#ifndef IS_PY3K static void py_restore_tstate (void *p) { @@ -458,6 +464,7 @@ push_dummy_python_frame (void) make_cleanup (py_restore_tstate, frame->f_back); return (PyObject *) frame; } +#endif /* Helper for apply_val_pretty_printer that formats children of the printer, if any exist. If is_py_none is true, then nothing has @@ -471,7 +478,10 @@ print_children (PyObject *printer, const char *hint, { int is_map, is_array, done_flag, pretty; unsigned int i; - PyObject *children, *iter, *frame; + PyObject *children, *iter; +#ifndef IS_PY3K + PyObject *frame; +#endif struct cleanup *cleanups; if (! PyObject_HasAttr (printer, gdbpy_children_cst)) @@ -515,6 +525,7 @@ print_children (PyObject *printer, const char *hint, /* Manufacture a dummy Python frame to work around Python 2.4 bug, where it insists on having a non-NULL tstate->frame when a generator is called. */ +#ifndef IS_PY3K frame = push_dummy_python_frame (); if (!frame) { @@ -522,6 +533,7 @@ print_children (PyObject *printer, const char *hint, goto done; } make_cleanup_py_decref (frame); +#endif done_flag = 0; for (i = 0; i < options->print_max; ++i) |