diff options
author | Simon McVittie <simon.mcvittie@collabora.co.uk> | 2006-12-12 19:44:41 +0000 |
---|---|---|
committer | Simon McVittie <simon.mcvittie@collabora.co.uk> | 2006-12-12 19:44:41 +0000 |
commit | 883b24563b5f9bf406fcde5edb19caabbc812ac2 (patch) | |
tree | c8bc65d224db9d9f100f8a188cbb54e4ca17e84d /_dbus_bindings/debug.c | |
parent | b7d21102b99e717e3b4f103d71ce96e8f056cfd4 (diff) | |
download | dbus-python-883b24563b5f9bf406fcde5edb19caabbc812ac2.tar.gz |
Add assertion macros and supporting functions
Diffstat (limited to '_dbus_bindings/debug.c')
-rw-r--r-- | _dbus_bindings/debug.c | 38 |
1 files changed, 36 insertions, 2 deletions
diff --git a/_dbus_bindings/debug.c b/_dbus_bindings/debug.c index 5dbe356..16138e9 100644 --- a/_dbus_bindings/debug.c +++ b/_dbus_bindings/debug.c @@ -22,8 +22,42 @@ * */ +#include "dbus_bindings-internal.h" +#include <stdlib.h> + +void +_dbus_py_assertion_failed(const char *assertion) +{ + PyErr_SetString(PyExc_AssertionError, assertion); +#if 1 || defined(USING_DBG) || defined(FATAL_ASSERTIONS) + /* print the Python stack, and dump core so we can see the C stack too */ + PyErr_Print(); + abort(); +#endif +} + #ifdef USING_DBG -void _dbus_py_dbg_exc(void) +void +_dbus_py_whereami(void) +{ + PyObject *c, *v, *t; + /* This is a little mad. We want to get the traceback without + clearing the error indicator, if any. */ + PyErr_Fetch(&c, &v, &t); /* 3 new refs */ + Py_XINCREF(c); Py_XINCREF(v); Py_XINCREF(t); /* now we own 6 refs */ + PyErr_Restore(c, v, t); /* steals 3 refs */ + + if (!PyErr_Occurred()) { + PyErr_SetString(PyExc_AssertionError, + "No error, but plz provide traceback kthx"); + } + PyErr_Print(); + + PyErr_Restore(c, v, t); /* steals another 3 refs */ +} + +void +_dbus_py_dbg_exc(void) { PyObject *c, *v, *t; /* This is a little mad. We want to get the traceback without @@ -35,7 +69,7 @@ void _dbus_py_dbg_exc(void) PyErr_Restore(c, v, t); /* steals another 3 refs */ } -static void +void _dbus_py_dbg_dump_message(DBusMessage *message) { const char *s; |