diff options
author | Tom Tromey <tom@tromey.com> | 2023-12-22 11:43:26 -0700 |
---|---|---|
committer | Tom Tromey <tom@tromey.com> | 2024-03-14 08:57:00 -0600 |
commit | b0e7d28eae1fa1a91932e47d8cf5decf96c2bc59 (patch) | |
tree | 91e5771f2592527303d2fcfc38dc3a87cb738f07 /gdb/python/py-value.c | |
parent | 9a03f2185347bd8f20da9bf535bc68a8d0f18ce8 (diff) | |
download | binutils-b0e7d28eae1fa1a91932e47d8cf5decf96c2bc59.zip binutils-b0e7d28eae1fa1a91932e47d8cf5decf96c2bc59.tar.gz binutils-b0e7d28eae1fa1a91932e47d8cf5decf96c2bc59.tar.bz2 |
Remove 'if' from GDB_PY_HANDLE_EXCEPTION
This removes the embedded 'if' from GDB_PY_HANDLE_EXCEPTION and
GDB_PY_SET_HANDLE_EXCEPTION. I believe this 'if' was necessary with
the old gdb try/catch macros, but it no longer is: these should only
ever be called from a 'catch' block, where it's already known that an
exception was thrown.
Simon pointed out, though, that in a few spots, these were in facts
called outside of 'catch' blocks. This patch cleans up these spots.
I also found one spot where a redundant 'return nullptr' could be
removed.
Diffstat (limited to 'gdb/python/py-value.c')
-rw-r--r-- | gdb/python/py-value.c | 16 |
1 files changed, 5 insertions, 11 deletions
diff --git a/gdb/python/py-value.c b/gdb/python/py-value.c index 89ca098..ff7943d 100644 --- a/gdb/python/py-value.c +++ b/gdb/python/py-value.c @@ -1046,7 +1046,6 @@ get_field_type (PyObject *field) static PyObject * valpy_getitem (PyObject *self, PyObject *key) { - struct gdb_exception except; value_object *self_value = (value_object *) self; gdb::unique_xmalloc_ptr<char> field; struct type *base_class_type = NULL, *field_type = NULL; @@ -1178,11 +1177,9 @@ valpy_getitem (PyObject *self, PyObject *key) } catch (gdb_exception &ex) { - except = std::move (ex); + GDB_PY_HANDLE_EXCEPTION (ex); } - GDB_PY_HANDLE_EXCEPTION (except); - return result; } @@ -1678,7 +1675,6 @@ valpy_absolute (PyObject *self) static int valpy_nonzero (PyObject *self) { - struct gdb_exception except; value_object *self_value = (value_object *) self; struct type *type; int nonzero = 0; /* Appease GCC warning. */ @@ -1698,14 +1694,12 @@ valpy_nonzero (PyObject *self) } catch (gdb_exception &ex) { - except = std::move (ex); + /* This is not documented in the Python documentation, but if + this function fails, return -1 as slot_nb_nonzero does (the + default Python nonzero function). */ + GDB_PY_SET_HANDLE_EXCEPTION (ex); } - /* This is not documented in the Python documentation, but if this - function fails, return -1 as slot_nb_nonzero does (the default - Python nonzero function). */ - GDB_PY_SET_HANDLE_EXCEPTION (except); - return nonzero; } |