aboutsummaryrefslogtreecommitdiff
path: root/gdb/python
diff options
context:
space:
mode:
Diffstat (limited to 'gdb/python')
-rw-r--r--gdb/python/py-arch.c11
-rw-r--r--gdb/python/py-breakpoint.c12
-rw-r--r--gdb/python/py-cmd.c10
-rw-r--r--gdb/python/py-connection.c10
-rw-r--r--gdb/python/py-frame.c2
-rw-r--r--gdb/python/py-inferior.c6
-rw-r--r--gdb/python/py-infthread.c4
-rw-r--r--gdb/python/py-lazy-string.c2
-rw-r--r--gdb/python/py-membuf.c8
-rw-r--r--gdb/python/py-micmd.c8
-rw-r--r--gdb/python/py-objfile.c6
-rw-r--r--gdb/python/py-param.c16
-rw-r--r--gdb/python/py-record-btrace.c8
-rw-r--r--gdb/python/py-record-full.c4
-rw-r--r--gdb/python/py-record.c2
-rw-r--r--gdb/python/py-registers.c6
-rw-r--r--gdb/python/py-signalevent.c2
-rw-r--r--gdb/python/py-symbol.c6
-rw-r--r--gdb/python/py-symtab.c6
-rw-r--r--gdb/python/py-type.c12
-rw-r--r--gdb/python/py-unwind.c6
-rw-r--r--gdb/python/py-utils.c8
-rw-r--r--gdb/python/py-xmethods.c6
-rw-r--r--gdb/python/python-internal.h22
-rw-r--r--gdb/python/python.c26
25 files changed, 93 insertions, 116 deletions
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 ()
- : "<unknown>"));
+ gdbpy_ref<> asm_obj
+ (PyUnicode_FromString (!stb.empty () ? stb.c_str () : "<unknown>"));
if (asm_obj == nullptr)
return nullptr;
@@ -341,7 +340,7 @@ gdbpy_all_architecture_names (PyObject *self, PyObject *args)
std::vector<const char *> 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)
diff --git a/gdb/python/py-breakpoint.c b/gdb/python/py-breakpoint.c
index 2fc2037..5891c3a 100644
--- a/gdb/python/py-breakpoint.c
+++ b/gdb/python/py-breakpoint.c
@@ -224,7 +224,7 @@ bppy_set_thread (PyObject *self, PyObject *newvalue, void *closure)
_("Cannot delete `thread' attribute."));
return -1;
}
- else if (PyInt_Check (newvalue))
+ else if (PyLong_Check (newvalue))
{
if (! gdb_py_int_as_long (newvalue, &id))
return -1;
@@ -266,7 +266,7 @@ bppy_set_task (PyObject *self, PyObject *newvalue, void *closure)
_("Cannot delete `task' attribute."));
return -1;
}
- else if (PyInt_Check (newvalue))
+ else if (PyLong_Check (newvalue))
{
if (! gdb_py_int_as_long (newvalue, &id))
return -1;
@@ -341,7 +341,7 @@ bppy_set_ignore_count (PyObject *self, PyObject *newvalue, void *closure)
_("Cannot delete `ignore_count' attribute."));
return -1;
}
- else if (! PyInt_Check (newvalue))
+ else if (!PyLong_Check (newvalue))
{
PyErr_SetString (PyExc_TypeError,
_("The value of `ignore_count' must be an integer."));
@@ -780,9 +780,9 @@ bppy_init (PyObject *self, PyObject *args, PyObject *kwargs)
if (lineobj != NULL)
{
- if (PyInt_Check (lineobj))
- line = xstrprintf ("%ld", PyInt_AsLong (lineobj));
- else if (PyString_Check (lineobj))
+ if (PyLong_Check (lineobj))
+ line = xstrprintf ("%ld", PyLong_AsLong (lineobj));
+ else if (PyUnicode_Check (lineobj))
line = python_string_to_host_string (lineobj);
else
{
diff --git a/gdb/python/py-cmd.c b/gdb/python/py-cmd.c
index b51b05c..c0a98544 100644
--- a/gdb/python/py-cmd.c
+++ b/gdb/python/py-cmd.c
@@ -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)
diff --git a/gdb/python/py-connection.c b/gdb/python/py-connection.c
index 4cdd6ab..8466041 100644
--- a/gdb/python/py-connection.c
+++ b/gdb/python/py-connection.c
@@ -204,12 +204,12 @@ connpy_repr (PyObject *obj)
process_stratum_target *target = self->target;
if (target == nullptr)
- return PyString_FromFormat ("<%s (invalid)>", Py_TYPE (obj)->tp_name);
+ return PyUnicode_FromFormat ("<%s (invalid)>", Py_TYPE (obj)->tp_name);
- return PyString_FromFormat ("<%s num=%d, what=\"%s\">",
- Py_TYPE (obj)->tp_name,
- target->connection_number,
- make_target_connection_string (target).c_str ());
+ return PyUnicode_FromFormat ("<%s num=%d, what=\"%s\">",
+ Py_TYPE (obj)->tp_name,
+ target->connection_number,
+ make_target_connection_string (target).c_str ());
}
/* Implementation of gdb.TargetConnection.is_valid() -> Boolean. Returns
diff --git a/gdb/python/py-frame.c b/gdb/python/py-frame.c
index 0cab8e1..bf9eba8 100644
--- a/gdb/python/py-frame.c
+++ b/gdb/python/py-frame.c
@@ -80,7 +80,7 @@ static PyObject *
frapy_str (PyObject *self)
{
const frame_id &fid = ((frame_object *) self)->frame_id;
- return PyString_FromString (fid.to_string ().c_str ());
+ return PyUnicode_FromString (fid.to_string ().c_str ());
}
/* Implementation of gdb.Frame.is_valid (self) -> Boolean.
diff --git a/gdb/python/py-inferior.c b/gdb/python/py-inferior.c
index 46f0c9f..ebcd5b0 100644
--- a/gdb/python/py-inferior.c
+++ b/gdb/python/py-inferior.c
@@ -753,10 +753,10 @@ infpy_repr (PyObject *obj)
inferior *inf = self->inferior;
if (inf == nullptr)
- return PyString_FromString ("<gdb.Inferior (invalid)>");
+ return PyUnicode_FromString ("<gdb.Inferior (invalid)>");
- return PyString_FromFormat ("<gdb.Inferior num=%d, pid=%d>",
- inf->num, inf->pid);
+ return PyUnicode_FromFormat ("<gdb.Inferior num=%d, pid=%d>",
+ inf->num, inf->pid);
}
diff --git a/gdb/python/py-infthread.c b/gdb/python/py-infthread.c
index c94d5b0..34f6052 100644
--- a/gdb/python/py-infthread.c
+++ b/gdb/python/py-infthread.c
@@ -73,7 +73,7 @@ thpy_get_name (PyObject *self, void *ignore)
if (name == NULL)
Py_RETURN_NONE;
- return PyString_FromString (name);
+ return PyUnicode_FromString (name);
}
/* Return a string containing target specific additional information about
@@ -101,7 +101,7 @@ thpy_get_details (PyObject *self, void *ignore)
if (extra_info == nullptr)
Py_RETURN_NONE;
- return PyString_FromString (extra_info);
+ return PyUnicode_FromString (extra_info);
}
static int
diff --git a/gdb/python/py-lazy-string.c b/gdb/python/py-lazy-string.c
index 69b1bc5..c49987e 100644
--- a/gdb/python/py-lazy-string.c
+++ b/gdb/python/py-lazy-string.c
@@ -73,7 +73,7 @@ stpy_get_encoding (PyObject *self, void *closure)
/* An encoding can be set to NULL by the user, so check before
attempting a Python FromString call. If NULL return Py_None. */
if (self_string->encoding)
- result = PyString_FromString (self_string->encoding);
+ result = PyUnicode_FromString (self_string->encoding);
else
{
result = Py_None;
diff --git a/gdb/python/py-membuf.c b/gdb/python/py-membuf.c
index 348dfa3..d2a059a 100644
--- a/gdb/python/py-membuf.c
+++ b/gdb/python/py-membuf.c
@@ -73,11 +73,11 @@ mbpy_str (PyObject *self)
{
membuf_object *membuf_obj = (membuf_object *) self;
- return PyString_FromFormat (_("Memory buffer for address %s, \
+ return PyUnicode_FromFormat (_("Memory buffer for address %s, \
which is %s bytes long."),
- paddress (gdbpy_enter::get_gdbarch (),
- membuf_obj->addr),
- pulongest (membuf_obj->length));
+ paddress (gdbpy_enter::get_gdbarch (),
+ membuf_obj->addr),
+ pulongest (membuf_obj->length));
}
static int
diff --git a/gdb/python/py-micmd.c b/gdb/python/py-micmd.c
index a194798..a0c3071 100644
--- a/gdb/python/py-micmd.c
+++ b/gdb/python/py-micmd.c
@@ -185,7 +185,7 @@ static gdb::unique_xmalloc_ptr<char>
py_object_to_mi_key (PyObject *key_obj)
{
/* The key must be a string. */
- if (!PyString_Check (key_obj))
+ if (!PyUnicode_Check (key_obj))
{
gdbpy_ref<> key_repr (PyObject_Repr (key_obj));
gdb::unique_xmalloc_ptr<char> key_repr_string;
@@ -261,7 +261,7 @@ serialize_mi_result_1 (PyObject *result, const char *field_name)
serialize_mi_result_1 (value, key_string.get ());
}
}
- else if (PySequence_Check (result) && !PyString_Check (result))
+ else if (PySequence_Check (result) && !PyUnicode_Check (result))
{
ui_out_emit_list list_emitter (uiout, field_name);
Py_ssize_t len = PySequence_Size (result);
@@ -607,7 +607,7 @@ gdbpy_initialize_micommands ()
< 0)
return -1;
- invoke_cst = PyString_FromString ("invoke");
+ invoke_cst = PyUnicode_FromString ("invoke");
if (invoke_cst == nullptr)
return -1;
@@ -636,7 +636,7 @@ micmdpy_get_name (PyObject *self, void *closure)
gdb_assert (micmd_obj->mi_command_name != nullptr);
std::string name_str = string_printf ("-%s", micmd_obj->mi_command_name);
- return PyString_FromString (name_str.c_str ());
+ return PyUnicode_FromString (name_str.c_str ());
}
/* Get the gdb.MICommand.installed property. Returns true if this MI
diff --git a/gdb/python/py-objfile.c b/gdb/python/py-objfile.c
index 8c56879..3e3270e 100644
--- a/gdb/python/py-objfile.c
+++ b/gdb/python/py-objfile.c
@@ -510,10 +510,10 @@ objfpy_repr (PyObject *self_)
objfile *obj = self->objfile;
if (obj == nullptr)
- return PyString_FromString ("<gdb.Objfile (invalid)>");
+ return PyUnicode_FromString ("<gdb.Objfile (invalid)>");
- return PyString_FromFormat ("<gdb.Objfile filename=%s>",
- objfile_name (obj));
+ return PyUnicode_FromFormat ("<gdb.Objfile filename=%s>",
+ objfile_name (obj));
}
/* Subroutine of gdbpy_lookup_objfile_by_build_id to simplify it.
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<char> 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<char> 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;
diff --git a/gdb/python/py-record-btrace.c b/gdb/python/py-record-btrace.c
index bee17e0..8540101 100644
--- a/gdb/python/py-record-btrace.c
+++ b/gdb/python/py-record-btrace.c
@@ -471,9 +471,9 @@ btpy_list_slice (PyObject *self, PyObject *value)
const Py_ssize_t length = btpy_list_length (self);
Py_ssize_t start, stop, step, slicelength;
- if (PyInt_Check (value))
+ if (PyLong_Check (value))
{
- Py_ssize_t index = PyInt_AsSsize_t (value);
+ Py_ssize_t index = PyLong_AsSsize_t (value);
/* Emulate Python behavior for negative indices. */
if (index < 0)
@@ -607,7 +607,7 @@ btpy_list_richcompare (PyObject *self, PyObject *other, int op)
PyObject *
recpy_bt_method (PyObject *self, void *closure)
{
- return PyString_FromString ("btrace");
+ return PyUnicode_FromString ("btrace");
}
/* Implementation of
@@ -628,7 +628,7 @@ recpy_bt_format (PyObject *self, void *closure)
if (config == NULL)
Py_RETURN_NONE;
- return PyString_FromString (btrace_format_short_string (config->format));
+ return PyUnicode_FromString (btrace_format_short_string (config->format));
}
/* Implementation of
diff --git a/gdb/python/py-record-full.c b/gdb/python/py-record-full.c
index 1caec73..ecae08b 100644
--- a/gdb/python/py-record-full.c
+++ b/gdb/python/py-record-full.c
@@ -26,7 +26,7 @@
PyObject *
recpy_full_method (PyObject *self, void *closure)
{
- return PyString_FromString ("full");
+ return PyUnicode_FromString ("full");
}
/* Implementation of
@@ -35,5 +35,5 @@ recpy_full_method (PyObject *self, void *closure)
PyObject *
recpy_full_format (PyObject *self, void *closure)
{
- return PyString_FromString ("full");
+ return PyUnicode_FromString ("full");
}
diff --git a/gdb/python/py-record.c b/gdb/python/py-record.c
index a4ab293..51084df 100644
--- a/gdb/python/py-record.c
+++ b/gdb/python/py-record.c
@@ -474,7 +474,7 @@ recpy_gap_reason_string (PyObject *self, void *closure)
{
const recpy_gap_object * const obj = (const recpy_gap_object *) self;
- return PyString_FromString (obj->reason_string);
+ return PyUnicode_FromString (obj->reason_string);
}
/* Record method list. */
diff --git a/gdb/python/py-registers.c b/gdb/python/py-registers.c
index b3f784e..eab88a3 100644
--- a/gdb/python/py-registers.c
+++ b/gdb/python/py-registers.c
@@ -138,7 +138,7 @@ gdbpy_reggroup_to_string (PyObject *self)
struct reggroup *reggroup = group->reggroup;
const char *name = reggroup_name (reggroup);
- return PyString_FromString (name);
+ return PyUnicode_FromString (name);
}
/* Implement gdb.RegisterGroup.name (self) -> String.
@@ -196,7 +196,7 @@ gdbpy_register_descriptor_to_string (PyObject *self)
int regnum = reg->regnum;
const char *name = gdbarch_register_name (gdbarch, regnum);
- return PyString_FromString (name);
+ return PyUnicode_FromString (name);
}
/* Implement gdb.RegisterDescriptor.name attribute get function. Return a
@@ -391,7 +391,7 @@ gdbpy_parse_register_id (struct gdbarch *gdbarch, PyObject *pyo_reg_id,
}
}
/* The register could be its internal GDB register number. */
- else if (PyInt_Check (pyo_reg_id))
+ else if (PyLong_Check (pyo_reg_id))
{
long value;
if (gdb_py_int_as_long (pyo_reg_id, &value) && (int) value == value)
diff --git a/gdb/python/py-signalevent.c b/gdb/python/py-signalevent.c
index e349f61..69eeebb 100644
--- a/gdb/python/py-signalevent.c
+++ b/gdb/python/py-signalevent.c
@@ -31,7 +31,7 @@ create_signal_event_object (enum gdb_signal stop_signal)
const char *signal_name = gdb_signal_to_name (stop_signal);
- gdbpy_ref<> signal_name_obj (PyString_FromString (signal_name));
+ gdbpy_ref<> signal_name_obj (PyUnicode_FromString (signal_name));
if (signal_name_obj == NULL)
return NULL;
if (evpy_add_attribute (signal_event_obj.get (),
diff --git a/gdb/python/py-symbol.c b/gdb/python/py-symbol.c
index 819a51f..12c97bf 100644
--- a/gdb/python/py-symbol.c
+++ b/gdb/python/py-symbol.c
@@ -60,7 +60,7 @@ sympy_str (PyObject *self)
SYMPY_REQUIRE_VALID (self, symbol);
- result = PyString_FromString (symbol->print_name ());
+ result = PyUnicode_FromString (symbol->print_name ());
return result;
}
@@ -101,7 +101,7 @@ sympy_get_name (PyObject *self, void *closure)
SYMPY_REQUIRE_VALID (self, symbol);
- return PyString_FromString (symbol->natural_name ());
+ return PyUnicode_FromString (symbol->natural_name ());
}
static PyObject *
@@ -111,7 +111,7 @@ sympy_get_linkage_name (PyObject *self, void *closure)
SYMPY_REQUIRE_VALID (self, symbol);
- return PyString_FromString (symbol->linkage_name ());
+ return PyUnicode_FromString (symbol->linkage_name ());
}
static PyObject *
diff --git a/gdb/python/py-symtab.c b/gdb/python/py-symtab.c
index cb28264..bfda599 100644
--- a/gdb/python/py-symtab.c
+++ b/gdb/python/py-symtab.c
@@ -93,7 +93,7 @@ stpy_str (PyObject *self)
STPY_REQUIRE_VALID (self, symtab);
- result = PyString_FromString (symtab_to_filename_for_display (symtab));
+ result = PyUnicode_FromString (symtab_to_filename_for_display (symtab));
return result;
}
@@ -234,8 +234,8 @@ salpy_str (PyObject *self)
filename = symtab_to_filename_for_display (symtab);
}
- return PyString_FromFormat ("symbol and line for %s, line %d", filename,
- sal->line);
+ return PyUnicode_FromFormat ("symbol and line for %s, line %d", filename,
+ sal->line);
}
static void
diff --git a/gdb/python/py-type.c b/gdb/python/py-type.c
index 8838884..5352ead 100644
--- a/gdb/python/py-type.c
+++ b/gdb/python/py-type.c
@@ -209,7 +209,7 @@ convert_field (struct type *type, int field)
if (field_name[0] != '\0')
{
- arg.reset (PyString_FromString (type->field (field).name ()));
+ arg.reset (PyUnicode_FromString (type->field (field).name ()));
if (arg == NULL)
return NULL;
}
@@ -261,7 +261,7 @@ field_name (struct type *type, int field)
gdbpy_ref<> result;
if (type->field (field).name ())
- result.reset (PyString_FromString (type->field (field).name ()));
+ result.reset (PyUnicode_FromString (type->field (field).name ()));
else
result = gdbpy_ref<>::new_reference (Py_None);
@@ -399,9 +399,9 @@ typy_get_name (PyObject *self, void *closure)
{
std::string name = ada_decode (type->name (), false);
if (!name.empty ())
- return PyString_FromString (name.c_str ());
+ return PyUnicode_FromString (name.c_str ());
}
- return PyString_FromString (type->name ());
+ return PyUnicode_FromString (type->name ());
}
/* Return the type's tag, or None. */
@@ -418,7 +418,7 @@ typy_get_tag (PyObject *self, void *closure)
if (tagname == nullptr)
Py_RETURN_NONE;
- return PyString_FromString (tagname);
+ return PyUnicode_FromString (tagname);
}
/* Return the type's objfile, or None. */
@@ -539,7 +539,7 @@ typy_array_1 (PyObject *self, PyObject *args, int is_vector)
if (n2_obj)
{
- if (!PyInt_Check (n2_obj))
+ if (!PyLong_Check (n2_obj))
{
PyErr_SetString (PyExc_RuntimeError,
_("Array bound must be an integer"));
diff --git a/gdb/python/py-unwind.c b/gdb/python/py-unwind.c
index 36f42cb..dd43901 100644
--- a/gdb/python/py-unwind.c
+++ b/gdb/python/py-unwind.c
@@ -213,7 +213,7 @@ unwind_infopy_str (PyObject *self)
stb.puts (")");
}
- return PyString_FromString (stb.c_str ());
+ return PyUnicode_FromString (stb.c_str ());
}
/* Create UnwindInfo instance for given PendingFrame and frame ID.
@@ -349,7 +349,7 @@ pending_framepy_str (PyObject *self)
const char *pc_str = NULL;
if (frame == NULL)
- return PyString_FromString ("Stale PendingFrame instance");
+ return PyUnicode_FromString ("Stale PendingFrame instance");
try
{
sp_str = core_addr_to_string_nz (get_frame_sp (frame));
@@ -360,7 +360,7 @@ pending_framepy_str (PyObject *self)
GDB_PY_HANDLE_EXCEPTION (except);
}
- return PyString_FromFormat ("SP=%s,PC=%s", sp_str, pc_str);
+ return PyUnicode_FromFormat ("SP=%s,PC=%s", sp_str, pc_str);
}
/* Implementation of gdb.PendingFrame.read_register (self, reg) -> gdb.Value.
diff --git a/gdb/python/py-utils.c b/gdb/python/py-utils.c
index e7b147c..72b7eaa 100644
--- a/gdb/python/py-utils.c
+++ b/gdb/python/py-utils.c
@@ -152,8 +152,8 @@ python_string_to_host_string (PyObject *obj)
gdbpy_ref<>
host_string_to_python_string (const char *str)
{
- return gdbpy_ref<> (PyString_Decode (str, strlen (str), host_charset (),
- NULL));
+ return gdbpy_ref<> (PyUnicode_Decode (str, strlen (str), host_charset (),
+ NULL));
}
/* Return true if OBJ is a Python string or unicode object, false
@@ -294,13 +294,13 @@ gdb_py_object_from_ulongest (ULONGEST l)
return gdbpy_ref<> (PyLong_FromUnsignedLong (l));
}
-/* Like PyInt_AsLong, but returns 0 on failure, 1 on success, and puts
+/* Like PyLong_AsLong, but returns 0 on failure, 1 on success, and puts
the value into an out parameter. */
int
gdb_py_int_as_long (PyObject *obj, long *result)
{
- *result = PyInt_AsLong (obj);
+ *result = PyLong_AsLong (obj);
return ! (*result == -1 && PyErr_Occurred ());
}
diff --git a/gdb/python/py-xmethods.c b/gdb/python/py-xmethods.c
index 9d58249..1467e52 100644
--- a/gdb/python/py-xmethods.c
+++ b/gdb/python/py-xmethods.c
@@ -103,7 +103,7 @@ invoke_match_method (PyObject *matcher, PyObject *py_obj_type,
if (match_method == NULL)
return NULL;
- gdbpy_ref<> py_xmethod_name (PyString_FromString (xmethod_name));
+ gdbpy_ref<> py_xmethod_name (PyUnicode_FromString (xmethod_name));
if (py_xmethod_name == NULL)
return NULL;
@@ -601,12 +601,12 @@ python_xmethod_worker::python_xmethod_worker (PyObject *py_worker,
int
gdbpy_initialize_xmethods (void)
{
- py_match_method_name = PyString_FromString (match_method_name);
+ py_match_method_name = PyUnicode_FromString (match_method_name);
if (py_match_method_name == NULL)
return -1;
py_get_arg_types_method_name
- = PyString_FromString (get_arg_types_method_name);
+ = PyUnicode_FromString (get_arg_types_method_name);
if (py_get_arg_types_method_name == NULL)
return -1;
diff --git a/gdb/python/python-internal.h b/gdb/python/python-internal.h
index ccf440c..d947b96 100644
--- a/gdb/python/python-internal.h
+++ b/gdb/python/python-internal.h
@@ -89,15 +89,6 @@
#define Py_TPFLAGS_CHECKTYPES 0
-#define PyInt_Check PyLong_Check
-#define PyInt_AsLong PyLong_AsLong
-#define PyInt_AsSsize_t PyLong_AsSsize_t
-
-#define PyString_FromString PyUnicode_FromString
-#define PyString_Decode PyUnicode_Decode
-#define PyString_FromFormat PyUnicode_FromFormat
-#define PyString_Check PyUnicode_Check
-
/* If Python.h does not define WITH_THREAD, then the various
GIL-related functions will not be defined. However,
PyGILState_STATE will be. */
@@ -141,19 +132,6 @@ typedef long Py_hash_t;
#define PyMem_RawMalloc PyMem_Malloc
#endif
-/* Python 2.6 did not wrap Py_DECREF in 'do {...} while (0)', leading
- to 'suggest explicit braces to avoid ambiguous ‘else’' gcc errors.
- Wrap it ourselves, so that callers don't need to care. */
-
-static inline void
-gdb_Py_DECREF (void *op) /* ARI: editCase function */
-{
- Py_DECREF (op);
-}
-
-#undef Py_DECREF
-#define Py_DECREF(op) gdb_Py_DECREF (op)
-
/* PyObject_CallMethod's 'method' and 'format' parameters were missing
the 'const' qualifier before Python 3.4. Hence, we wrap the
function in our own version to avoid errors with string literals.
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;
}