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 gdb/python: fix a few flake8 warnings 2021-10-02 08:33:28 -04:00
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 gdb: remove unnecessary lookup_cmd when deprecating commands 2021-05-27 14:00:07 -04:00
py-block.c gdb/python: remove all uses of Py_TPFLAGS_HAVE_ITER 2021-09-09 09:50:38 +01:00
py-bpevent.c
py-breakpoint.c gdb/gdbsupport: make xstrprintf and xstrvprintf return a unique_ptr 2021-11-16 17:45:45 +00:00
py-cmd.c gdb: remove cmd_list_element::function::sfunc 2021-07-23 15:38:54 -04:00
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 gdb: remove bpstat typedef, rename bpstats to bpstat 2021-11-08 16:39:14 -05:00
py-frame.c gdb/python: add PendingFrame.level and Frame.level methods 2021-06-21 16:20:08 +01:00
py-framefilter.c Remove uses of fprintf_symbol_filtered 2021-08-02 10:48:29 -06:00
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 gdb: change thread_info::name to unique_xmalloc_ptr, add helper function 2021-09-24 17:25:55 -04:00
py-instruction.c
py-instruction.h
py-lazy-string.c
py-linetable.c gdb/python: remove all uses of Py_TPFLAGS_HAVE_ITER 2021-09-09 09:50:38 +01:00
py-membuf.c gdb/python: move gdb.Membuf support into a new file 2021-10-22 13:43:42 +01:00
py-newobjfileevent.c
py-objfile.c gdb: delay python initialisation until gdbpy_finish_initialization 2021-04-28 09:56:20 +01:00
py-param.c gdb: make string-like set show commands use std::string variable 2021-10-03 17:53:16 +01:00
py-prettyprint.c gdb: fix some indentation issues 2021-05-27 15:01:28 -04:00
py-progspace.c gdb: delay python initialisation until gdbpy_finish_initialization 2021-04-28 09:56:20 +01:00
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 gdb/python: remove all uses of Py_TPFLAGS_HAVE_ITER 2021-09-09 09:50:38 +01:00
py-signalevent.c
py-stopevent.c gdb: remove bpstat typedef, rename bpstats to bpstat 2021-11-08 16:39:14 -05:00
py-stopevent.h gdb: remove bpstat typedef, rename bpstats to bpstat 2021-11-08 16:39:14 -05:00
py-symbol.c Restore gdb.SYMBOL_LABEL_DOMAIN constant 2021-06-03 14:56:55 +02:00
py-symtab.c gdb: delay python initialisation until gdbpy_finish_initialization 2021-04-28 09:56:20 +01:00
py-threadevent.c
py-tui.c Forward mouse click to python TUI window 2021-06-04 16:18:10 +02:00
py-type.c gdb: remove TYPE_FIELD_ENUMVAL 2021-10-29 16:44:45 -04:00
py-unwind.c gdb: change functions returning value contents to use gdb::array_view 2021-10-25 14:51:44 -04:00
py-utils.c
py-value.c gdb: change functions returning value contents to use gdb::array_view 2021-10-25 14:51:44 -04:00
py-varobj.c
py-xmethods.c
python-config.py gdb: re-format Python files using black 21.4b0 2021-05-07 10:56:20 -04:00
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