diff options
author | Christoph Reiter <reiter.christoph@gmail.com> | 2018-03-11 13:13:30 +0100 |
---|---|---|
committer | Christoph Reiter <reiter.christoph@gmail.com> | 2018-03-11 13:30:17 +0100 |
commit | 288ad4c7e0a13a43992014f5fff55636c7c8fcfd (patch) | |
tree | 86b5fe0e2b2aecd7f49c729cf1be50bf165dbec4 /gi/pygi-struct.c | |
parent | 4208d1eab0da81a64f5fe0346e540140bd56072b (diff) | |
download | pygobject-288ad4c7e0a13a43992014f5fff55636c7c8fcfd.tar.gz |
_struct_dealloc: handle being called with an error set
With Python 3.7 it gets called with an error set and tp_dealloc
implementations need to handle that.
Fix by saving and restoring the error.
Diffstat (limited to 'gi/pygi-struct.c')
-rw-r--r-- | gi/pygi-struct.c | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/gi/pygi-struct.c b/gi/pygi-struct.c index 4d5b5411..e2906e0a 100644 --- a/gi/pygi-struct.c +++ b/gi/pygi-struct.c @@ -61,7 +61,14 @@ out: static void _struct_dealloc (PyGIStruct *self) { - GIBaseInfo *info = _struct_get_info ( (PyObject *) self ); + GIBaseInfo *info; + PyObject *error_type, *error_value, *error_traceback; + gboolean have_error = !!PyErr_Occurred (); + + if (have_error) + PyErr_Fetch (&error_type, &error_value, &error_traceback); + + info = _struct_get_info ( (PyObject *) self ); if (info != NULL && g_struct_info_is_foreign ( (GIStructInfo *) info)) { pygi_struct_foreign_release (info, pyg_pointer_get_ptr (self)); @@ -73,6 +80,9 @@ _struct_dealloc (PyGIStruct *self) g_base_info_unref (info); } + if (have_error) + PyErr_Restore (error_type, error_value, error_traceback); + Py_TYPE (self)->tp_free ((PyObject *)self); } |