]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commit
gdb/python: remove some additional PyObject_IsTrue calls
authorAndrew Burgess <aburgess@redhat.com>
Sun, 10 Nov 2024 14:34:58 +0000 (14:34 +0000)
committerAndrew Burgess <aburgess@redhat.com>
Thu, 14 Nov 2024 19:34:43 +0000 (19:34 +0000)
commitd8a2c719dace17e329d329dc2e38fbddb95fef11
tree3f358a1ab409142a4a5d8f14807dfc060f01fa38
parentdcf4c484539a9ab5fdd0c5ddf43617986480b9bc
gdb/python: remove some additional PyObject_IsTrue calls

After the previous commit I audited all our uses of PyObject_IsTrue
looking for places where we were missing an error check.  I did find
some that are missing error checks in places where we really should
have error checks, and I'll fix those in later commits.

This commit however, focuses on those locations where PyObject_IsTrue
is called, there is no error check, and the error check isn't really
necessary because we already know that the object we are dealing with
is of type PyBool_Type.

Inline with the previous commit, in these cases I have removed the
PyObject_IsTrue call, and replaced it with a comparison against
Py_True.  In one location where it is not obvious that the object we
have is PyBool_Type I've added an assert, but in the other cases the
comparison to Py_True immediately follows a PyBool_Check call, so an
assert would be redundant.

I've added a test for the gdb.Value.format_string styling argument
being passed a non-bool value as this wasn't previously being tested,
though this new test will pass before and after this commit.

There should be no functional change after this commit.

Approved-By: Tom Tromey <tom@tromey.com>
gdb/python/py-disasm.c
gdb/python/py-value.c
gdb/testsuite/gdb.python/py-format-string.exp