diff --git a/gdb/python/py-arch.c b/gdb/python/py-arch.c index aa9a652ef26..824ad0bfeab 100644 --- a/gdb/python/py-arch.c +++ b/gdb/python/py-arch.c @@ -276,12 +276,17 @@ static PyObject * archpy_integer_type (PyObject *self, PyObject *args, PyObject *kw) { static const char *keywords[] = { "size", "signed", NULL }; - int size, is_signed = 1; + int size; + PyObject *is_signed_obj = nullptr; - if (!gdb_PyArg_ParseTupleAndKeywords (args, kw, "i|p", keywords, - &size, &is_signed)) + if (!gdb_PyArg_ParseTupleAndKeywords (args, kw, "i|O", keywords, + &size, &is_signed_obj)) return nullptr; + /* Assume signed by default. */ + bool is_signed = (is_signed_obj == nullptr + || PyObject_IsTrue (is_signed_obj)); + 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 f3bf01d2828..14dc1bf85ee 100644 --- a/gdb/testsuite/gdb.python/py-arch.exp +++ b/gdb/testsuite/gdb.python/py-arch.exp @@ -64,7 +64,7 @@ if { ![is_address_zero_readable] } { } foreach size {0 1 2 3 4 8 16} { - foreach sign {"" ", True" ", False"} { + foreach sign {"" ", True" ", False" ", None" ", \"blah\""} { set fullsize [expr 8 * $size] gdb_test_no_output "python t = arch.integer_type($fullsize$sign)" \ "get integer type for $size$sign"