binutils-gdb/gdb/python
Tom Tromey ddae946278 Fix PR python/17386 - add __index__ method to gdb.Value
This patch fixes PR python/17386.

The bug is that gdb.Value does not implement the Python __index__
method.  This method is needed to convert a Python object to an index
and is used by various operations in Python, such as indexing an
array.

The fix is to implement the nb_index method for gdb.Value.

nb_index was added in Python 2.5.  I don't have a good way to test
Python 2.4, but I made an attempt to accomodate it.

I chose to use valpy_long in all cases because this simplifies porting
to Python 3, and because there didn't seem to be any harm.

Built and regtested on x86-64 Fedora 23.

2016-05-24  Tom Tromey  <tom@tromey.com>

	PR python/17386:
	* python/py-value.c (value_object_as_number): Add
	nb_inplace_floor_divide, nb_inplace_true_divide, nb_index.

2016-05-24  Tom Tromey  <tom@tromey.com>

	PR python/17386:
	* gdb.python/py-value.exp (test_value_numeric_ops): Add tests that
	use value as an index.
2016-05-24 10:05:59 -06:00
..
lib/gdb Add $_as_string convenience function 2016-03-10 17:12:30 -05:00
py-arch.c
py-auto-load.c
py-block.c
py-bpevent.c
py-breakpoint.c Fix PR python/17981 2016-05-24 09:55:01 -06:00
py-cmd.c
py-continueevent.c
py-event.c
py-event.h
py-events.h
py-evtregistry.c
py-evts.c remove trivialy unused variables 2016-05-07 20:12:53 -04:00
py-exitedevent.c
py-finishbreakpoint.c remove trivialy unused variables 2016-05-07 20:12:53 -04:00
py-frame.c
py-framefilter.c remove trivialy unused variables 2016-05-07 20:12:53 -04:00
py-function.c
py-gdb-readline.c
py-inferior.c remove trivialy unused variables 2016-05-07 20:12:53 -04:00
py-infevents.c remove trivialy unused variables 2016-05-07 20:12:53 -04:00
py-infthread.c remove trivialy unused variables 2016-05-07 20:12:53 -04:00
py-lazy-string.c
py-linetable.c remove trivialy unused variables 2016-05-07 20:12:53 -04:00
py-newobjfileevent.c
py-objfile.c Fix PR python/19438, PR python/18393 - initialize dictionaries 2016-05-23 10:08:34 -06:00
py-param.c
py-prettyprint.c
py-progspace.c Fix PR python/19438, PR python/18393 - initialize dictionaries 2016-05-23 10:08:34 -06:00
py-signalevent.c
py-stopevent.c
py-stopevent.h
py-symbol.c
py-symtab.c remove trivialy unused variables 2016-05-07 20:12:53 -04:00
py-threadevent.c
py-type.c
py-unwind.c remove trivialy unused variables 2016-05-07 20:12:53 -04:00
py-utils.c python/py-utils.c (host_string_to_python_string): New function. 2016-03-29 23:48:35 -07:00
py-value.c Fix PR python/17386 - add __index__ method to gdb.Value 2016-05-24 10:05:59 -06:00
py-varobj.c remove trivialy unused variables 2016-05-07 20:12:53 -04:00
py-xmethods.c
python-config.py
python-internal.h python/py-utils.c (host_string_to_python_string): New function. 2016-03-29 23:48:35 -07:00
python.c Fix gdb/python/python.c use-after-free 2016-05-03 12:16:56 +01:00
python.h