mirror of
https://github.com/espressif/binutils-gdb.git
synced 2025-05-23 18:26:47 +08:00
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.
This commit is contained in:
@ -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;
|
||||
}
|
||||
|
Reference in New Issue
Block a user