mirror of
https://github.com/espressif/binutils-gdb.git
synced 2025-06-05 06:23:58 +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:
@ -1,3 +1,10 @@
|
|||||||
|
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.
|
||||||
|
|
||||||
2013-05-21 Philippe Waroquiers <philippe.waroquiers@skynet.be>
|
2013-05-21 Philippe Waroquiers <philippe.waroquiers@skynet.be>
|
||||||
|
|
||||||
* breakpoints.c (detach_breakpoints): Do not
|
* breakpoints.c (detach_breakpoints): Do not
|
||||||
|
@ -31,12 +31,8 @@ py_decref (void *p)
|
|||||||
{
|
{
|
||||||
PyObject *py = p;
|
PyObject *py = p;
|
||||||
|
|
||||||
/* Note that we need the extra braces in this 'if' to avoid a
|
|
||||||
warning from gcc. */
|
|
||||||
if (py)
|
if (py)
|
||||||
{
|
Py_DECREF (py);
|
||||||
Py_DECREF (py);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Return a new cleanup which will decrement the Python object's
|
/* 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);
|
Py_INCREF (object);
|
||||||
result = PyModule_AddObject (module, name, object);
|
result = PyModule_AddObject (module, name, object);
|
||||||
if (result < 0)
|
if (result < 0)
|
||||||
{
|
Py_DECREF (object);
|
||||||
/* Python 2.6 did not wrap Py_DECREF in do { } while (0);. */
|
|
||||||
Py_DECREF (object);
|
|
||||||
}
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
@ -169,6 +169,18 @@ typedef unsigned long gdb_py_ulongest;
|
|||||||
|
|
||||||
#endif /* HAVE_LONG_LONG */
|
#endif /* HAVE_LONG_LONG */
|
||||||
|
|
||||||
|
/* Python 2.6 did not wrap Py_DECREF in 'do {...} while (0)', leading
|
||||||
|
to 'suggest explicit braces to avoid ambiguous ‘else’' gcc errors.
|
||||||
|
Wrap it ourselves, so that callers don't need to care. */
|
||||||
|
|
||||||
|
static inline void
|
||||||
|
gdb_Py_DECREF (void *op)
|
||||||
|
{
|
||||||
|
Py_DECREF (op);
|
||||||
|
}
|
||||||
|
|
||||||
|
#undef Py_DECREF
|
||||||
|
#define Py_DECREF(op) gdb_Py_DECREF (op)
|
||||||
|
|
||||||
/* In order to be able to parse symtab_and_line_to_sal_object function
|
/* In order to be able to parse symtab_and_line_to_sal_object function
|
||||||
a real symtab_and_line structure is needed. */
|
a real symtab_and_line structure is needed. */
|
||||||
|
Reference in New Issue
Block a user