Python 2's PyNumberMethods has nb_inplace_divide, but Python 3 does
not. This patch adds it for Python 2.
This buglet didn't cause much fallout because the only non-NULL entry
in value_object_as_number after this is for valpy_divide; and the
missing slot caused it to slide up to nb_floor_divide (where
nb_true_divide was intended).
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
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.
Are you trying to avoid a trailing comma? We already use trailing commas
in many places in common code (and have been for a long while),
so the fact that it was valid C89/C++03 doesn't really matter in practice.
(It was a common extension that later became valid in C99/C++11.)
Ulrich> Nothing defines HAVE_LIBPYTHON_2_4 on my machine; instead, we
Ulrich> seem to have
Ulrich> /* Define if Python 2.4 is being used. */
Ulrich> #define HAVE_LIBPYTHON2_4 1
Ulrich> in config.h ... Typo?
Yes, sorry about that.
I'm fixing it as appended.
Author: Tom Tromey <[hidden email]>
Date: Wed May 25 07:54:44 2016 -0600
fix spelling of HAVE_LIBPYTHON2_4 in py-value.c
Ulrich pointed out that an earlier patch had misspelled
HAVE_LIBPYTHON2_4, adding an extra "_". This caused a build failure.
This patch fixes the bug.
> Ulrich> Nothing defines HAVE_LIBPYTHON_2_4 on my machine; instead, we
> Ulrich> seem to have
> Ulrich> /* Define if Python 2.4 is being used. */
> Ulrich> #define HAVE_LIBPYTHON2_4 1
> Ulrich> in config.h ... Typo?
> Yes, sorry about that.
> I'm fixing it as appended.
Dr. Ulrich Weigand
GNU/Linux compilers and toolchain