This is the mail archive of the mailing list for the Archer project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [patch] Python 2.4 compatibility.

On Mon, Oct 13, 2008 at 11:37 AM, Tom Tromey <> wrote:
>>>>>> "Paul" == Paul Pluzhnikov <> writes:
> Paul> Current git source fails to build with python 2.4.
> Paul> Attached patch fixes that, but I am not sure that's the best (or
> Paul> even correct) fix.
> Is the problem that Py_ssize_t is not defined?

I see in python-internal.h that Py_ssize_t is already defined for
HAVE_LIBPYTHON2_4, but that's not good enough: PyMappingMethods
uses the "wrong" type:


typedef int (*inquiry)(PyObject *);
typedef struct {
	inquiry mp_length;
	binaryfunc mp_subscript;
	objobjargproc mp_ass_subscript;
} PyMappingMethods;

> Paul> +#if PYTHON_API_VERSION <= 1012
> Paul> +  int iter;
> Paul> +#else
> Paul>    Py_ssize_t iter;
> Paul> +#endif
> Also if not, I suppose this code should just use the length size.
> The fewer conditionals, the better.

In this case, PyDict_Next() is the problem:


PyAPI_FUNC(int) PyDict_Next(
	PyObject *mp, int *pos, PyObject **key, PyObject **value);

I am not sure there is a good way to fix this, because we are
working around broken API :(

typedef int gdbpy_int_which_should_have_been_ssize_type;  // ???

Ok, how about this (not really sure this is any better :(

diff --git a/gdb/python/python-internal.h b/gdb/python/python-internal.h
index 5896907..ffca87d 100644
--- a/gdb/python/python-internal.h
+++ b/gdb/python/python-internal.h
@@ -43,6 +43,14 @@ typedef Py_intptr_t Py_ssize_t;
 #error "Unable to find usable Python.h"

+typedef int PyDict_Next_position_type;
+typedef int PyObject_Inquiry_return_type;
+typedef Py_ssize_t PyDict_Next_position_type;
+typedef Py_ssize_t PyObject_Inquiry_return_type;
 #include "command.h"

 struct block;

Perhaps the better solution is to require python >= 2.5 ?

Paul Pluzhnikov

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]