diff options
author | DongHun Kwak <dh0128.kwak@samsung.com> | 2017-07-12 08:50:39 +0900 |
---|---|---|
committer | DongHun Kwak <dh0128.kwak@samsung.com> | 2017-07-12 08:50:42 +0900 |
commit | f3eae5a895fc60cb99c0c366bdd011018ce3bc7b (patch) | |
tree | 05145bd5ec6ec44e6cb9d5604ade02923e66d6a0 /gi | |
parent | 942efc88315506d2a299ae79d05fa8dfe00f8166 (diff) | |
download | pygobject2-upstream.tar.gz pygobject2-upstream.tar.bz2 pygobject2-upstream.zip |
Imported Upstream version 3.9.92upstream/3.9.92upstream
Change-Id: I568bb088bda84501eabdd8ad9d0224c88b73695e
Signed-off-by: DongHun Kwak <dh0128.kwak@samsung.com>
Diffstat (limited to 'gi')
-rw-r--r-- | gi/overrides/GLib.py | 2 | ||||
-rw-r--r-- | gi/overrides/__init__.py | 1 | ||||
-rw-r--r-- | gi/pygi-marshal-from-py.c | 53 |
3 files changed, 31 insertions, 25 deletions
diff --git a/gi/overrides/GLib.py b/gi/overrides/GLib.py index 0a4cdb6..f4b1ef5 100644 --- a/gi/overrides/GLib.py +++ b/gi/overrides/GLib.py @@ -536,7 +536,7 @@ __all__.append('MainContext') class Source(GLib.Source): - def __new__(cls): + def __new__(cls, *args, **kwargs): # use our custom pyg_source_new() here as g_source_new() is not # bindable source = source_new() diff --git a/gi/overrides/__init__.py b/gi/overrides/__init__.py index 943ea60..8aa9731 100644 --- a/gi/overrides/__init__.py +++ b/gi/overrides/__init__.py @@ -64,6 +64,7 @@ class overridefunc(object): def wrapper(*args, **kwargs): return func(*args, **kwargs) wrapper.__name__ = func.__name__ + wrapper.__doc__ = func.__doc__ setattr(self.module, func.__name__, wrapper) return wrapper diff --git a/gi/pygi-marshal-from-py.c b/gi/pygi-marshal-from-py.c index 82d94a0..57b4126 100644 --- a/gi/pygi-marshal-from-py.c +++ b/gi/pygi-marshal-from-py.c @@ -1780,6 +1780,8 @@ _pygi_marshal_from_py_interface_struct (PyObject *py_arg, gboolean copy_reference, gboolean is_foreign) { + gboolean is_union = FALSE; + if (py_arg == Py_None) { arg->v_pointer = NULL; return TRUE; @@ -1806,41 +1808,27 @@ _pygi_marshal_from_py_interface_struct (PyObject *py_arg, return (success == Py_None); } else if (!PyObject_IsInstance (py_arg, py_type)) { /* first check to see if this is a member of the expected union */ - if (!_is_union_member (interface_info, py_arg)) { - if (!PyErr_Occurred()) { - gchar *type_name = _pygi_g_base_info_get_fullname (interface_info); - PyObject *module = PyObject_GetAttrString(py_arg, "__module__"); - - PyErr_Format (PyExc_TypeError, "argument %s: Expected %s, but got %s%s%s", - arg_name ? arg_name : "self", - type_name, - module ? PYGLIB_PyUnicode_AsString(module) : "", - module ? "." : "", - py_arg->ob_type->tp_name); - if (module) - Py_DECREF (module); - g_free (type_name); - } - - return FALSE; + is_union = _is_union_member (interface_info, py_arg); + if (!is_union) { + goto type_error; } } if (g_type_is_a (g_type, G_TYPE_BOXED)) { - /* Use pyg_type_from_object to pull the stashed __gtype__ attribute - * off of the input argument instead of checking PyGBoxed.gtype - * with pyg_boxed_check. This is needed to work around type discrepancies - * in cases with aliased (typedef) types. e.g. GtkAllocation, GdkRectangle. + /* Additionally use pyg_type_from_object to pull the stashed __gtype__ + * attribute off of the input argument for type checking. This is needed + * to work around type discrepancies in cases with aliased (typedef) types. + * e.g. GtkAllocation, GdkRectangle. * See: https://bugzilla.gnomethere are .org/show_bug.cgi?id=707140 */ - if (g_type_is_a (pyg_type_from_object (py_arg), g_type)) { + if (is_union || pyg_boxed_check (py_arg, g_type) || + g_type_is_a (pyg_type_from_object (py_arg), g_type)) { arg->v_pointer = pyg_boxed_get (py_arg, void); if (transfer == GI_TRANSFER_EVERYTHING) { arg->v_pointer = g_boxed_copy (g_type, arg->v_pointer); } } else { - PyErr_Format (PyExc_TypeError, "wrong boxed type"); - return FALSE; + goto type_error; } } else if (g_type_is_a (g_type, G_TYPE_POINTER) || @@ -1862,4 +1850,21 @@ _pygi_marshal_from_py_interface_struct (PyObject *py_arg, return FALSE; } return TRUE; + +type_error: + { + gchar *type_name = _pygi_g_base_info_get_fullname (interface_info); + PyObject *module = PyObject_GetAttrString(py_arg, "__module__"); + + PyErr_Format (PyExc_TypeError, "argument %s: Expected %s, but got %s%s%s", + arg_name ? arg_name : "self", + type_name, + module ? PYGLIB_PyUnicode_AsString(module) : "", + module ? "." : "", + py_arg->ob_type->tp_name); + if (module) + Py_DECREF (module); + g_free (type_name); + return FALSE; + } } |