diff options
| author | Simon McVittie <simon.mcvittie@collabora.co.uk> | 2006-12-18 20:33:56 +0000 |
|---|---|---|
| committer | Simon McVittie <simon.mcvittie@collabora.co.uk> | 2006-12-18 20:33:56 +0000 |
| commit | e6eb7b5307da2a446e1c8c6b0cb6b11fc6705b00 (patch) | |
| tree | 3315ae510245c0a0b4d791b7c1d73f1bc01afdce /_dbus_bindings/exceptions.c | |
| parent | 73457d0e435f4a9be9a9980fb06dd004b87c6647 (diff) | |
| download | dbus-python-e6eb7b5307da2a446e1c8c6b0cb6b11fc6705b00.tar.gz | |
Switch to autotools and test with Python 2.5 as well as 2.4.
In the process:
HACKING.txt: update
include/dbus-python.h: add some typedefs to make it saner
bus.c, conn.c, conn-methods.c: further alter docstrings to keep epydoc happy
exceptions.c: create exceptions in a more longwinded way for Python 2.5 compatibility
message-get-args.c, bus/__init__.py: tweak docstrings
dbus/introspect_parser.py: make docstring valid reStructuredText
run-test.sh: simplify, since configure now does some of the work
test/*.py: use paths from run-test.sh, cope with out-of-tree builds
test-standalone.py: carry out additional sanity checks
Diffstat (limited to '_dbus_bindings/exceptions.c')
| -rw-r--r-- | _dbus_bindings/exceptions.c | 39 |
1 files changed, 29 insertions, 10 deletions
diff --git a/_dbus_bindings/exceptions.c b/_dbus_bindings/exceptions.c index ffe8fe9..efa3df2 100644 --- a/_dbus_bindings/exceptions.c +++ b/_dbus_bindings/exceptions.c @@ -31,7 +31,8 @@ PyDoc_STRVAR(DBusException__doc__, "Represents any D-Bus-related error."); PyObject * DBusPyException_ConsumeError(DBusError *error) { - PyErr_Format(DBusPyException, "%s: %s", error->name, error->message); + PyErr_Format(DBusPyException, "%s: %s", + error->name, error->message); dbus_error_free(error); return NULL; } @@ -39,16 +40,34 @@ DBusPyException_ConsumeError(DBusError *error) dbus_bool_t dbus_py_init_exception_types(void) { - PyObject *docstring; + PyObject *bases; + PyObject *dict = PyDict_New(); + PyObject *name; - /* We call it dbus.DBusException because that's where you should import it - from. */ - DBusPyException = PyErr_NewException("dbus.DBusException", NULL, NULL); - if (!DBusPyException) return 0; - docstring = PyString_FromString(DBusException__doc__); - if (!docstring) return 0; - if (PyObject_SetAttrString(DBusPyException, "__doc__", docstring)) return 0; - Py_DECREF(docstring); + if (!dict) + return 0; + if (PyDict_SetItemString(dict, "__doc__", + PyString_FromString(DBusException__doc__)) < 0) + return 0; + if (PyDict_SetItemString(dict, "__module__", + PyString_FromString("dbus")) < 0) + return 0; + bases = Py_BuildValue("(O)", (PyObject *)PyExc_Exception); + if (!bases) { + Py_DECREF(dict); + return 0; + } + name = PyString_FromString("DBusException"); + if (!name) { + Py_DECREF(dict); + Py_DECREF(bases); + return 0; + } + DBusPyException = PyClass_New(bases, dict, name); + Py_DECREF(bases); + Py_DECREF(dict); + if (!DBusPyException) + return 0; return 1; } |
