[pygobject] Use GObject type checking for instance arguments



commit 9b345b153e86ca6c9b7290cf2ad3b38f6ad9d0e5
Author: Simon Feltman <sfeltman src gnome org>
Date:   Wed Feb 12 10:28:35 2014 -0800

    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 files changed, 5 insertions(+), 1 deletions(-)
---
diff --git a/gi/pygi-object.c b/gi/pygi-object.c
index 2aefee1..29cd518 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",


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]