binutils-gdb/gdb/python
Andrew Burgess 90fe61ced1 gdb/python: don't use the 'p' format for parsing args
When running the gdb.python/py-arch.exp tests on a GDB built
against Python 2 I ran into some errors.  The problem is that this
test script exercises the gdb.Architecture.integer_type method, and
this method uses 'p' as an argument format specifier in a call to
gdb_PyArg_ParseTupleAndKeywords.

Unfortunately this specified was only added in Python 3.3, so will
cause an error for earlier versions of Python.

This commit switches to use the 'O' specifier to collect a PyObject,
and then uses PyObject_IsTrue to convert the object to a boolean.

An earlier version of this patch incorrectly switched from using 'p'
to use 'i', however, it was pointed out during review that this would
cause some changes in behaviour, for example both of these will work
with 'p', but not with 'i':

  gdb.selected_inferior().architecture().integer_type(32, None)
  gdb.selected_inferior().architecture().integer_type(32, "foo")

The new approach of using 'O' works fine with these cases.  I've added
some new tests to cover both of the above.

There should be no user visible changes after this commit.
2021-11-30 15:46:09 +00:00
..
lib/gdb
py-all-events.def gdb/python: introduce gdb.TargetConnection object type 2021-11-30 12:10:33 +00:00
py-arch.c gdb/python: don't use the 'p' format for parsing args 2021-11-30 15:46:09 +00:00
py-auto-load.c
py-block.c
py-bpevent.c
py-breakpoint.c
py-cmd.c
py-connection.c gdb/python: add gdb.RemoteTargetConnection.send_packet 2021-11-30 12:10:40 +00:00
py-continueevent.c
py-event-types.def gdb/python: introduce gdb.TargetConnection object type 2021-11-30 12:10:33 +00:00
py-event.c
py-event.h
py-events.h
py-evtregistry.c
py-evts.c
py-exitedevent.c
py-finishbreakpoint.c
py-frame.c
py-framefilter.c
py-function.c
py-gdb-readline.c
py-inferior.c gdb/python: introduce gdb.TargetConnection object type 2021-11-30 12:10:33 +00:00
py-infevents.c
py-infthread.c
py-instruction.c
py-instruction.h
py-lazy-string.c
py-linetable.c
py-membuf.c
py-newobjfileevent.c
py-objfile.c
py-param.c
py-prettyprint.c
py-progspace.c
py-record-btrace.c
py-record-btrace.h
py-record-full.c
py-record-full.h
py-record.c
py-record.h
py-ref.h
py-registers.c
py-signalevent.c
py-stopevent.c
py-stopevent.h
py-symbol.c
py-symtab.c
py-threadevent.c
py-tui.c
py-type.c
py-unwind.c
py-utils.c
py-value.c
py-varobj.c
py-xmethods.c
python-config.py
python-internal.h gdb/python: introduce gdb.TargetConnection object type 2021-11-30 12:10:33 +00:00
python.c gdb/python: introduce gdb.TargetConnection object type 2021-11-30 12:10:33 +00:00
python.h