From 1915daebe6683fb1cdd42c87a6db5532a396bbc6 Mon Sep 17 00:00:00 2001 From: Pedro Alves Date: Tue, 21 May 2013 20:52:30 +0000 Subject: Centralize workaround for Python 2.6's Py_DECREF. Wrap/redefine Py_DECREF ourselves, avoiding the need for uses to care about extra braces due to the fact that Python only started wrapping Py_DECREF in 'do {} while (0)' after 2.6. gdb/ 2013-05-21 Pedro Alves * python/py-utils.c (py_decref): Remove extra braces. (gdb_pymodule_addobject): Remove extra braces. * python-internal.h (gdb_Py_DECREF): New static inline function. (Py_DECREF): Redefine as calling gdb_Py_DECREF. --- gdb/python/py-utils.c | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) (limited to 'gdb/python/py-utils.c') diff --git a/gdb/python/py-utils.c b/gdb/python/py-utils.c index e78dee0..80bacf7 100644 --- a/gdb/python/py-utils.c +++ b/gdb/python/py-utils.c @@ -31,12 +31,8 @@ py_decref (void *p) { PyObject *py = p; - /* Note that we need the extra braces in this 'if' to avoid a - warning from gcc. */ if (py) - { - Py_DECREF (py); - } + Py_DECREF (py); } /* Return a new cleanup which will decrement the Python object's @@ -443,9 +439,6 @@ gdb_pymodule_addobject (PyObject *module, const char *name, PyObject *object) Py_INCREF (object); result = PyModule_AddObject (module, name, object); if (result < 0) - { - /* Python 2.6 did not wrap Py_DECREF in do { } while (0);. */ - Py_DECREF (object); - } + Py_DECREF (object); return result; } -- cgit v1.1