From 9b345b153e86ca6c9b7290cf2ad3b38f6ad9d0e5 Mon Sep 17 00:00:00 2001 From: Simon Feltman Date: Wed, 12 Feb 2014 10:28:35 -0800 Subject: Use GObject type checking for instance arguments Add a g_type_is_a check to interface/object instance arguments in addition to the Python IsInstance check. This loosens restrictions on overrides which don't use gi.overrides.override() and is needed to keep API compatibility which broke with commit: https://git.gnome.org/browse/pygobject/commit/?id=d5925b76 https://bugzilla.gnome.org/show_bug.cgi?id=724009 --- gi/pygi-object.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/gi/pygi-object.c b/gi/pygi-object.c index 2aefee1d..29cd518a 100644 --- a/gi/pygi-object.c +++ b/gi/pygi-object.c @@ -129,13 +129,17 @@ _pygi_marshal_from_py_interface_object (PyGIInvokeState *state, gpointer *cleanup_data) { gboolean res = FALSE; + GObject *gobj = NULL; + PyGIInterfaceCache *iface_cache = (PyGIInterfaceCache *)arg_cache; if (py_arg == Py_None) { arg->v_pointer = NULL; return TRUE; } - if (!PyObject_IsInstance (py_arg, ( (PyGIInterfaceCache *)arg_cache)->py_type)) { + gobj = pygobject_get (py_arg); + if (!PyObject_IsInstance (py_arg, iface_cache->py_type) && + !g_type_is_a (G_OBJECT_TYPE (gobj), iface_cache->g_type)) { PyObject *module = PyObject_GetAttrString(py_arg, "__module__"); PyErr_Format (PyExc_TypeError, "argument %s: Expected %s, but got %s%s%s", -- cgit v1.2.1