aboutsummaryrefslogtreecommitdiff
path: root/gdb/python/py-utils.c
diff options
context:
space:
mode:
authorPedro Alves <palves@redhat.com>2013-05-21 20:52:30 +0000
committerPedro Alves <palves@redhat.com>2013-05-21 20:52:30 +0000
commit1915daebe6683fb1cdd42c87a6db5532a396bbc6 (patch)
treebfa6dede3c6bd8ed9c72fce2ae57e1b8ce4046b7 /gdb/python/py-utils.c
parent52c935b6f53a31185e201524b479e18f3b925981 (diff)
downloadgdb-1915daebe6683fb1cdd42c87a6db5532a396bbc6.zip
gdb-1915daebe6683fb1cdd42c87a6db5532a396bbc6.tar.gz
gdb-1915daebe6683fb1cdd42c87a6db5532a396bbc6.tar.bz2
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 <palves@redhat.com> * 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.
Diffstat (limited to 'gdb/python/py-utils.c')
-rw-r--r--gdb/python/py-utils.c11
1 files changed, 2 insertions, 9 deletions
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;
}