diff options
author | Simon McVittie <smcv@collabora.com> | 2019-09-12 10:30:04 +0100 |
---|---|---|
committer | Simon McVittie <smcv@collabora.com> | 2019-09-12 10:31:17 +0100 |
commit | 9f0730c4d71d0d04ee0ed7734bc5e836fb81c2d2 (patch) | |
tree | 92c0c7d248b88a87d23c870970b80432790d0228 | |
parent | d6733481001502292e2c935718ecc8e957dd0c80 (diff) | |
download | dbus-python-9f0730c4d71d0d04ee0ed7734bc5e836fb81c2d2.tar.gz |
Revert "Consistently save/restore exception indicator when called from C code"
Saving and restoring the exception indicator breaks users of dbus-python
that rely on being able to raise SystemExit (or call sys.exit()) from a
dbus-python method, such as libsecret's test suite.
This reverts commit dbc0f7ef463922c026f1183a07368aa61ffe98dc.
Signed-off-by: Simon McVittie <smcv@collabora.com>
-rw-r--r-- | dbus_bindings/conn-methods.c | 34 | ||||
-rw-r--r-- | dbus_bindings/pending-call.c | 14 | ||||
-rw-r--r-- | dbus_bindings/server.c | 11 |
3 files changed, 16 insertions, 43 deletions
diff --git a/dbus_bindings/conn-methods.c b/dbus_bindings/conn-methods.c index ddd0766..62bdf86 100644 --- a/dbus_bindings/conn-methods.c +++ b/dbus_bindings/conn-methods.c @@ -34,12 +34,9 @@ static void _object_path_unregister(DBusConnection *conn, void *user_data) { PyGILState_STATE gil = PyGILState_Ensure(); - PyObject *et, *ev, *tb; PyObject *tuple = NULL; Connection *conn_obj = NULL; - PyObject *callable = NULL; - - PyErr_Fetch(&et, &ev, &tb); + PyObject *callable; conn_obj = (Connection *)DBusPyConnection_ExistingFromDBusConnection(conn); if (!conn_obj) goto out; @@ -62,15 +59,13 @@ _object_path_unregister(DBusConnection *conn, void *user_data) Py_XDECREF(PyObject_CallFunctionObjArgs(callable, conn_obj, NULL)); } out: - if (PyErr_Occurred()) { - PyErr_WriteUnraisable(callable); - } - Py_CLEAR(conn_obj); Py_CLEAR(tuple); /* the user_data (a Python str) is no longer ref'd by the DBusConnection */ Py_CLEAR(user_data); - PyErr_Restore(et, ev, tb); + if (PyErr_Occurred()) { + PyErr_Print(); + } PyGILState_Release(gil); } @@ -80,13 +75,10 @@ _object_path_message(DBusConnection *conn, DBusMessage *message, { DBusHandlerResult ret; PyGILState_STATE gil = PyGILState_Ensure(); - PyObject *et, *ev, *tb; Connection *conn_obj = NULL; PyObject *tuple = NULL; PyObject *msg_obj; - PyObject *callable = NULL; /* borrowed */ - - PyErr_Fetch(&et, &ev, &tb); + PyObject *callable; /* borrowed */ dbus_message_ref(message); msg_obj = DBusPyMessage_ConsumeDBusMessage(message); @@ -131,14 +123,12 @@ _object_path_message(DBusConnection *conn, DBusMessage *message, } out: - if (PyErr_Occurred()) { - PyErr_WriteUnraisable(callable); - } - Py_CLEAR(msg_obj); Py_CLEAR(conn_obj); Py_CLEAR(tuple); - PyErr_Restore(et, ev, tb); + if (PyErr_Occurred()) { + PyErr_Print(); + } PyGILState_Release(gil); return ret; } @@ -153,7 +143,6 @@ _filter_message(DBusConnection *conn, DBusMessage *message, void *user_data) { DBusHandlerResult ret; PyGILState_STATE gil = PyGILState_Ensure(); - PyObject *et, *ev, *tb; Connection *conn_obj = NULL; PyObject *callable = NULL; PyObject *msg_obj; @@ -161,8 +150,6 @@ _filter_message(DBusConnection *conn, DBusMessage *message, void *user_data) Py_ssize_t i, size; #endif - PyErr_Fetch(&et, &ev, &tb); - dbus_message_ref(message); msg_obj = DBusPyMessage_ConsumeDBusMessage(message); if (!msg_obj) { @@ -214,14 +201,9 @@ _filter_message(DBusConnection *conn, DBusMessage *message, void *user_data) ret = DBusPyConnection_HandleMessage(conn_obj, msg_obj, callable); out: - if (PyErr_Occurred()) { - PyErr_WriteUnraisable(callable); - } - Py_CLEAR(msg_obj); Py_CLEAR(conn_obj); Py_CLEAR(callable); - PyErr_Restore(et, ev, tb); PyGILState_Release(gil); return ret; } diff --git a/dbus_bindings/pending-call.c b/dbus_bindings/pending-call.c index 50b2998..636095f 100644 --- a/dbus_bindings/pending-call.c +++ b/dbus_bindings/pending-call.c @@ -79,20 +79,15 @@ _pending_call_notify_function(DBusPendingCall *pc, PyObject *list) { PyGILState_STATE gil = PyGILState_Ensure(); - PyObject *et, *ev, *tb; - PyObject *handler; - DBusMessage *msg; - - PyErr_Fetch(&et, &ev, &tb); - /* BEGIN CRITICAL SECTION * While holding the GIL, make sure the callback only gets called once * by deleting it from the 1-item list that's held by libdbus. */ - handler = PyList_GetItem(list, 0); + PyObject *handler = PyList_GetItem(list, 0); + DBusMessage *msg; if (!handler) { - PyErr_WriteUnraisable(list); + PyErr_Print(); goto release; } if (handler == Py_None) { @@ -118,7 +113,7 @@ _pending_call_notify_function(DBusPendingCall *pc, PyObject *ret = PyObject_CallFunctionObjArgs(handler, msg_obj, NULL); if (!ret) { - PyErr_WriteUnraisable(handler); + PyErr_Print(); } Py_CLEAR(ret); Py_CLEAR(msg_obj); @@ -129,7 +124,6 @@ _pending_call_notify_function(DBusPendingCall *pc, release: Py_CLEAR(handler); - PyErr_Restore(et, ev, tb); PyGILState_Release(gil); } diff --git a/dbus_bindings/server.c b/dbus_bindings/server.c index 2080d6b..dfbfa53 100644 --- a/dbus_bindings/server.c +++ b/dbus_bindings/server.c @@ -190,12 +190,9 @@ DBusPyServer_new_connection_cb(DBusServer *server, void *data UNUSED) { PyGILState_STATE gil = PyGILState_Ensure(); - PyObject *et, *ev, *tb; PyObject *self = NULL; PyObject *method = NULL; - PyErr_Fetch(&et, &ev, &tb); - self = DBusPyServer_ExistingFromDBusServer(server); if (!self) goto out; TRACE(self); @@ -227,12 +224,12 @@ DBusPyServer_new_connection_cb(DBusServer *server, } out: + Py_CLEAR(method); + Py_CLEAR(self); + if (PyErr_Occurred()) - PyErr_WriteUnraisable(method); + PyErr_Print(); - Py_CLEAR(self); - Py_CLEAR(method); - PyErr_Restore(et, ev, tb); PyGILState_Release(gil); } |