This is the mail archive of the
archer@sourceware.org
mailing list for the Archer project.
[patch] Python 2.4 compatibility.
- From: ppluzhnikov at google dot com (Paul Pluzhnikov)
- To: archer at sourceware dot org
- Cc: ppluzhnikov at google dot com
- Date: Mon, 13 Oct 2008 11:17:29 -0700 (PDT)
- Subject: [patch] Python 2.4 compatibility.
- Dkim-signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d=google.com; s=beta;t=1223921851; bh=Mm3iKbN33HFS1+PnKyUAeHUpNdM=;h=DomainKey-Signature:To:Cc:Subject:Message-Id:Date:From; b=UAy5SeVWAj7Q5wsBythkW2zLoykkrBeq8zXqSAlr77C3r9BcKWmT7fcxNk8MvwUUkK240Q+10us+mkHmYVCspw==
- Domainkey-signature: a=rsa-sha1; s=beta; d=google.com; c=nofws; q=dns;h=to:cc:subject:message-id:date:from;b=tyZlsjpUP4OQFyt7awZ8cgnMhPx6Vx5AleHrvbKz6Gl2+IZOopHc13GmkLTuApyjL1a+QIf1fix0Q3D1zPHVUQ==
Greetings,
Current git source fails to build with python 2.4.
Attached patch fixes that, but I am not sure that's the best (or
even correct) fix.
Thanks,
--
Paul Pluzhnikov
2008-10-13 Paul Pluzhnikov <ppluzhnikov@google.com>
* gdb/python/python.c (find_pretty_printer): Python2.4 compatibility.
* gdb/python/python-value.c (valpy_length): Likewise.
commit 57d9ef09e581a214ff9ae2abfb19805ce9cd0847
Author: Paul Pluzhnikov <ppluzhnikov@google.com>
Date: Mon Oct 13 10:38:08 2008 -0700
Made code compile with python2.4 headers.
diff --git a/gdb/python/python-value.c b/gdb/python/python-value.c
index 02c3fec..38faeaf 100644
--- a/gdb/python/python-value.c
+++ b/gdb/python/python-value.c
@@ -60,7 +60,12 @@ typedef struct {
static void valpy_dealloc (PyObject *obj);
static PyObject *valpy_new (PyTypeObject *subtype, PyObject *args,
PyObject *keywords);
-static Py_ssize_t valpy_length (PyObject *self);
+#if PYTHON_API_VERSION <= 1012
+typedef int length_t;
+#else
+typedef Py_ssize_t length_t;
+#endif
+static length_t valpy_length (PyObject *self);
static PyObject *valpy_getitem (PyObject *self, PyObject *key);
static int valpy_setitem (PyObject *self, PyObject *key, PyObject *value);
static PyObject *valpy_str (PyObject *self);
@@ -279,7 +284,7 @@ valpy_cast (PyObject *self, PyObject *args)
return value_to_value_object (res_val);
}
-static Py_ssize_t
+static length_t
valpy_length (PyObject *self)
{
/* We don't support getting the number of elements in a struct / class. */
diff --git a/gdb/python/python.c b/gdb/python/python.c
index 20bd1a9..3f76772 100644
--- a/gdb/python/python.c
+++ b/gdb/python/python.c
@@ -667,7 +667,11 @@ static PyObject *
find_pretty_printer (struct type *type, PyObject **dictp, char *dict_name)
{
PyObject *dict, *key, *func, *found = NULL;
+#if PYTHON_API_VERSION <= 1012
+ int iter;
+#else
Py_ssize_t iter;
+#endif
char *type_name = NULL;
volatile struct gdb_exception except;