[pygobject] marshal-cleanup: save and restore exception around cleanup
- From: Christoph Reiter <creiter src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [pygobject] marshal-cleanup: save and restore exception around cleanup
- Date: Mon, 12 Mar 2018 06:32:28 +0000 (UTC)
commit 7399496b808be05a419063dfc925e09e40c9c09b
Author: Christoph Reiter <reiter christoph gmail com>
Date: Sat Mar 10 20:03:33 2018 +0100
marshal-cleanup: save and restore exception around cleanup
With Python 3.7 some Python API in the cleanup path clears exceptions
which makes us return NULL in the end without an error set.
Make if safe to call the cleanup functions with an error set by
saving and restoring exceptions.
gi/pygi-marshal-cleanup.c | 24 ++++++++++++++++++++++++
1 file changed, 24 insertions(+)
---
diff --git a/gi/pygi-marshal-cleanup.c b/gi/pygi-marshal-cleanup.c
index ddda5943..96bbad60 100644
--- a/gi/pygi-marshal-cleanup.c
+++ b/gi/pygi-marshal-cleanup.c
@@ -93,6 +93,11 @@ pygi_marshal_cleanup_args_from_py_marshal_success (PyGIInvokeState *state,
PyGICallableCache *cache)
{
gssize i;
+ PyObject *error_type, *error_value, *error_traceback;
+ gboolean have_error = !!PyErr_Occurred ();
+
+ if (have_error)
+ PyErr_Fetch (&error_type, &error_value, &error_traceback);
for (i = 0; (gsize)i < _pygi_callable_cache_args_len (cache); i++) {
PyGIArgCache *arg_cache = _pygi_callable_cache_get_arg (cache, i);
@@ -112,6 +117,9 @@ pygi_marshal_cleanup_args_from_py_marshal_success (PyGIInvokeState *state,
state->args[i].arg_cleanup_data = NULL;
}
}
+
+ if (have_error)
+ PyErr_Restore (error_type, error_value, error_traceback);
}
void
@@ -120,6 +128,11 @@ pygi_marshal_cleanup_args_to_py_marshal_success (PyGIInvokeState *state,
{
GSList *cache_item;
guint i = 0;
+ PyObject *error_type, *error_value, *error_traceback;
+ gboolean have_error = !!PyErr_Occurred ();
+
+ if (have_error)
+ PyErr_Fetch (&error_type, &error_value, &error_traceback);
/* clean up the return if available */
if (cache->return_cache != NULL) {
@@ -156,6 +169,9 @@ pygi_marshal_cleanup_args_to_py_marshal_success (PyGIInvokeState *state,
i++;
cache_item = cache_item->next;
}
+
+ if (have_error)
+ PyErr_Restore (error_type, error_value, error_traceback);
}
void
@@ -164,6 +180,11 @@ pygi_marshal_cleanup_args_from_py_parameter_fail (PyGIInvokeState *state,
gssize failed_arg_index)
{
gssize i;
+ PyObject *error_type, *error_value, *error_traceback;
+ gboolean have_error = !!PyErr_Occurred ();
+
+ if (have_error)
+ PyErr_Fetch (&error_type, &error_value, &error_traceback);
state->failed = TRUE;
@@ -195,6 +216,9 @@ pygi_marshal_cleanup_args_from_py_parameter_fail (PyGIInvokeState *state,
}
state->args[i].arg_cleanup_data = NULL;
}
+
+ if (have_error)
+ PyErr_Restore (error_type, error_value, error_traceback);
}
void
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]