diff options
author | Christoph Reiter <reiter.christoph@gmail.com> | 2018-03-31 14:00:48 +0200 |
---|---|---|
committer | Christoph Reiter <reiter.christoph@gmail.com> | 2018-03-31 14:00:48 +0200 |
commit | fe74a5a989a8bd9b8b69ab1d160bc7215a6c6bbf (patch) | |
tree | 0dc301753bd798a6002824459144badaecbc8a6c | |
parent | 91450f356945a2e99506ec03276fc1d179c894ae (diff) | |
download | pygobject-fe74a5a989a8bd9b8b69ab1d160bc7215a6c6bbf.tar.gz |
struct: fetch the base info from the struct type and not the instance
We need the base info in the struct tp_dealloc and PyPy doesn't like
when the instance escapes there by passing it to some Python API.
Since the base info is stored on the class anyway get it from there instead.
This allows the test suite to run without crashes under PyPy.
-rw-r--r-- | gi/pygi-struct.c | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/gi/pygi-struct.c b/gi/pygi-struct.c index 0160b2fd..3c0c89fd 100644 --- a/gi/pygi-struct.c +++ b/gi/pygi-struct.c @@ -31,12 +31,12 @@ static GIBaseInfo * -_struct_get_info (PyObject *self) +_struct_get_info (PyTypeObject *type) { PyObject *py_info; GIBaseInfo *info = NULL; - py_info = PyObject_GetAttrString (self, "__info__"); + py_info = PyObject_GetAttrString ((PyObject *)type, "__info__"); if (py_info == NULL) { return NULL; } @@ -68,7 +68,7 @@ _struct_dealloc (PyGIStruct *self) if (have_error) PyErr_Fetch (&error_type, &error_value, &error_traceback); - info = _struct_get_info ( (PyObject *) self ); + info = _struct_get_info (Py_TYPE (self)); if (info != NULL && g_struct_info_is_foreign ( (GIStructInfo *) info)) { pygi_struct_foreign_release (info, pyg_pointer_get_ptr (self)); @@ -102,7 +102,7 @@ _struct_new (PyTypeObject *type, return NULL; } - info = _struct_get_info ( (PyObject *) type ); + info = _struct_get_info ( type ); if (info == NULL) { if (PyErr_ExceptionMatches (PyExc_AttributeError)) { PyErr_Format (PyExc_TypeError, "missing introspection information"); @@ -212,7 +212,7 @@ _struct_repr(PyGIStruct *self) GIBaseInfo *info; PyGPointer *pointer = (PyGPointer *)self; - info = _struct_get_info ((PyObject *)self); + info = _struct_get_info (Py_TYPE (self)); if (info == NULL) return NULL; |