This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
FYI: remove some unnecessary PyErr_SetString calls
- From: Tom Tromey <tromey at redhat dot com>
- To: gdb-patches at sourceware dot org
- Date: Fri, 17 May 2013 10:51:26 -0600
- Subject: FYI: remove some unnecessary PyErr_SetString calls
I'm checking this in.
I noticed that in a couple of places, gdb calls PyErr_SetString if
PyObject_New failed. However, this is not needed, and is perhaps
actively confusing, because PyObject_New has already set the exception.
Built and regtested on x86-64 Fedora 18.
Tom
2013-05-17 Tom Tromey <tromey@redhat.com>
* python/py-inferior.c (infpy_read_memory): Don't call
PyErr_SetString if PyObject_New fails.
* python/py-frame.c (frame_info_to_frame_object): Don't call
PyErr_SetString if PyObject_New fails.
diff --git a/gdb/python/py-frame.c b/gdb/python/py-frame.c
index e2eb9c5..9342f45 100644
--- a/gdb/python/py-frame.c
+++ b/gdb/python/py-frame.c
@@ -304,11 +304,7 @@ frame_info_to_frame_object (struct frame_info *frame)
frame_obj = PyObject_New (frame_object, &frame_object_type);
if (frame_obj == NULL)
- {
- PyErr_SetString (PyExc_MemoryError,
- _("Could not allocate frame object."));
- return NULL;
- }
+ return NULL;
TRY_CATCH (except, RETURN_MASK_ALL)
{
diff --git a/gdb/python/py-inferior.c b/gdb/python/py-inferior.c
index 4af7131..cee3a0d 100644
--- a/gdb/python/py-inferior.c
+++ b/gdb/python/py-inferior.c
@@ -445,8 +445,6 @@ infpy_read_memory (PyObject *self, PyObject *args, PyObject *kw)
if (membuf_obj == NULL)
{
xfree (buffer);
- PyErr_SetString (PyExc_MemoryError,
- _("Could not allocate memory buffer object."));
return NULL;
}