aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--gdb/NEWS3
-rw-r--r--gdb/python/py-arch.c11
-rw-r--r--gdb/testsuite/gdb.python/py-arch.exp16
3 files changed, 22 insertions, 8 deletions
diff --git a/gdb/NEWS b/gdb/NEWS
index 20837bb..b96ac5e 100644
--- a/gdb/NEWS
+++ b/gdb/NEWS
@@ -69,6 +69,9 @@
** New class gdb.missing_objfile.MissingObjfileHandler which can be
sub-classed to create handlers for missing objfiles.
+ ** The 'signed' argument to gdb.Architecture.integer_type() will no
+ longer accept non-bool types.
+
* Debugger Adapter Protocol changes
** The "scopes" request will now return a scope holding global
diff --git a/gdb/python/py-arch.c b/gdb/python/py-arch.c
index d73d7fc..f7e35a4 100644
--- a/gdb/python/py-arch.c
+++ b/gdb/python/py-arch.c
@@ -269,15 +269,16 @@ archpy_integer_type (PyObject *self, PyObject *args, PyObject *kw)
{
static const char *keywords[] = { "size", "signed", NULL };
int size;
- PyObject *is_signed_obj = nullptr;
+ PyObject *is_signed_obj = Py_True;
- if (!gdb_PyArg_ParseTupleAndKeywords (args, kw, "i|O", keywords,
- &size, &is_signed_obj))
+ if (!gdb_PyArg_ParseTupleAndKeywords (args, kw, "i|O!", keywords,
+ &size,
+ &PyBool_Type, &is_signed_obj))
return nullptr;
/* Assume signed by default. */
- bool is_signed = (is_signed_obj == nullptr
- || PyObject_IsTrue (is_signed_obj));
+ gdb_assert (PyBool_Check (is_signed_obj));
+ bool is_signed = is_signed_obj == Py_True;
struct gdbarch *gdbarch;
ARCHPY_REQUIRE_VALID (self, gdbarch);
diff --git a/gdb/testsuite/gdb.python/py-arch.exp b/gdb/testsuite/gdb.python/py-arch.exp
index aef4186..14802ec 100644
--- a/gdb/testsuite/gdb.python/py-arch.exp
+++ b/gdb/testsuite/gdb.python/py-arch.exp
@@ -70,9 +70,7 @@ if { ![is_address_zero_readable] } {
foreach size {0 1 2 3 4 8 16} {
foreach sign_data {{"" True} \
{", True" True} \
- {", False" False} \
- {", None" False} \
- {", \"blah\"" True}} {
+ {", False" False}} {
set sign [lindex $sign_data 0]
# GDB's 0 bit type is always signed.
if { $size == 0 } {
@@ -94,6 +92,18 @@ gdb_test "python arch.integer_type(95)" \
".*ValueError.* no integer type of that size is available.*" \
"call integer_type with invalid size"
+foreach_with_prefix test_data { {None None} \
+ {"\"blah\"" str} \
+ {1 int} } {
+ set bad_sign [lindex $test_data 0]
+ set bad_type [lindex $test_data 1]
+ gdb_test "python arch.integer_type(8, $bad_sign)" \
+ [multi_line \
+ "Python Exception <class 'TypeError'>: argument 2 must be bool, not $bad_type" \
+ "Error occurred in Python: argument 2 must be bool, not $bad_type"] \
+ "check 'signed' argument can handle non-bool type $bad_type"
+}
+
# Test for gdb.architecture_names(). First we're going to grab the
# complete list of architecture names using the 'complete' command.
set arch_names []