diff options
author | DongHun Kwak <dh0128.kwak@samsung.com> | 2017-07-12 08:42:29 +0900 |
---|---|---|
committer | DongHun Kwak <dh0128.kwak@samsung.com> | 2017-07-12 08:42:33 +0900 |
commit | c20b00fa62305380031ec383e1d7f7c548cdfe44 (patch) | |
tree | eff0bb0ed4ac1fc12518637304d67bf421a2783e /gi | |
parent | 70d11d3c9704b35313f8b4dfbb3bc1c1c4afd87d (diff) | |
download | pygobject2-c20b00fa62305380031ec383e1d7f7c548cdfe44.tar.gz pygobject2-c20b00fa62305380031ec383e1d7f7c548cdfe44.tar.bz2 pygobject2-c20b00fa62305380031ec383e1d7f7c548cdfe44.zip |
Imported Upstream version 3.13.91
Change-Id: I0e28e5ad489cdaed2e72ffdfb2bdbb482de5dd0a
Signed-off-by: DongHun Kwak <dh0128.kwak@samsung.com>
Diffstat (limited to 'gi')
-rw-r--r-- | gi/docstring.py | 13 | ||||
-rw-r--r-- | gi/gimodule.c | 1 | ||||
-rw-r--r-- | gi/pygi-boxed.c | 5 | ||||
-rw-r--r-- | gi/pygi-closure.c | 10 | ||||
-rw-r--r-- | gi/pygi-list.c | 4 | ||||
-rw-r--r-- | gi/pygi-signal-closure.c | 41 |
6 files changed, 60 insertions, 14 deletions
diff --git a/gi/docstring.py b/gi/docstring.py index 80bb022..fec5f63 100644 --- a/gi/docstring.py +++ b/gi/docstring.py @@ -148,10 +148,11 @@ def _generate_callable_info_doc(info): # Build return + output argument strings out_args_strs = [] return_hint = _get_pytype_hint(info.get_return_type()) - if not info.skip_return and return_hint and return_hint not in hint_blacklist: + if not info.skip_return() and return_hint and return_hint not in hint_blacklist: + argstr = return_hint if info.may_return_null(): argstr += ' or None' - out_args_strs.append(return_hint) + out_args_strs.append(argstr) for i, arg in enumerate(args): if arg.get_direction() == Direction.IN: @@ -171,7 +172,8 @@ def _generate_callable_info_doc(info): def _generate_class_info_doc(info): - doc = '\n:Constructors:\n\n::\n\n' # start with \n to avoid auto indent of other lines + header = '\n:Constructors:\n\n::\n\n' # start with \n to avoid auto indent of other lines + doc = '' if isinstance(info, StructInfo): # Don't show default constructor for disguised (0 length) structs @@ -184,7 +186,10 @@ def _generate_class_info_doc(info): if method_info.is_constructor(): doc += ' ' + _generate_callable_info_doc(method_info) + '\n' - return doc + if doc: + return header + doc + else: + return '' def _generate_doc_dispatch(info): diff --git a/gi/gimodule.c b/gi/gimodule.c index 00c9422..a18c477 100644 --- a/gi/gimodule.c +++ b/gi/gimodule.c @@ -500,6 +500,7 @@ _wrap_pyg_variant_new_tuple (PyObject *self, PyObject *args) } variant = g_variant_new_tuple (values, PyTuple_Size (py_values)); + g_variant_ref_sink (variant); py_variant = _pygi_struct_new ( (PyTypeObject *) py_type, variant, FALSE); diff --git a/gi/pygi-boxed.c b/gi/pygi-boxed.c index 557584b..a1494b6 100644 --- a/gi/pygi-boxed.c +++ b/gi/pygi-boxed.c @@ -134,7 +134,10 @@ _boxed_init (PyObject *self, static char *kwlist[] = { NULL }; if (!PyArg_ParseTupleAndKeywords (args, kwargs, "", kwlist)) { - return -1; + PyErr_Clear (); + PyErr_Warn (PyExc_TypeError, + "Passing arguments to gi.types.Boxed.__init__() is deprecated. " + "All arguments passed will be ignored."); } /* Don't call PyGBoxed's init, which raises an exception. */ diff --git a/gi/pygi-closure.c b/gi/pygi-closure.c index 15c6767..2a5a120 100644 --- a/gi/pygi-closure.c +++ b/gi/pygi-closure.c @@ -371,7 +371,8 @@ _pygi_closure_convert_arguments (PyGIInvokeState *state, for (i = 0; i < _pygi_callable_cache_args_len (cache); i++) { PyGIArgCache *arg_cache = g_ptr_array_index (cache->args_cache, i); - if (arg_cache->direction & PYGI_DIRECTION_FROM_PYTHON) { + if (arg_cache->direction & PYGI_DIRECTION_FROM_PYTHON && + state->arg_values[i].v_pointer) { state->arg_pointers[i].v_pointer = state->arg_values[i].v_pointer; state->arg_values[i] = *(GIArgument *) state->arg_values[i].v_pointer; } @@ -551,6 +552,13 @@ _pygi_closure_handle (ffi_cif *cif, gboolean success; PyGIInvokeState state = { 0, }; + /* Ignore closures when Python is not initialized. This can happen in cases + * where calling Python implemented vfuncs can happen at shutdown time. + * See: https://bugzilla.gnome.org/show_bug.cgi?id=722562 */ + if (!Py_IsInitialized()) { + return; + } + /* Lock the GIL as we are coming into this code without the lock and we may be executing python code */ py_state = PyGILState_Ensure (); diff --git a/gi/pygi-list.c b/gi/pygi-list.c index f6589c1..e3f3c67 100644 --- a/gi/pygi-list.c +++ b/gi/pygi-list.c @@ -82,7 +82,7 @@ err: PyGIMarshalCleanupFunc cleanup = sequence_cache->item_cache->from_py_cleanup; } */ - Py_DECREF (py_item); + Py_XDECREF (py_item); g_list_free (list_); _PyGI_ERROR_PREFIX ("Item %i: ", i); return FALSE; @@ -160,7 +160,7 @@ err: } */ - Py_DECREF (py_item); + Py_XDECREF (py_item); g_slist_free (list_); _PyGI_ERROR_PREFIX ("Item %i: ", i); return FALSE; diff --git a/gi/pygi-signal-closure.c b/gi/pygi-signal-closure.c index 0c6b9b9..3cf8486 100644 --- a/gi/pygi-signal-closure.c +++ b/gi/pygi-signal-closure.c @@ -109,16 +109,19 @@ pygi_signal_closure_marshal(GClosure *closure, } else if (i < sig_info_highest_arg) { GIArgInfo arg_info; GITypeInfo type_info; + GITypeTag type_tag; GIArgument arg = { 0, }; PyObject *item = NULL; gboolean free_array = FALSE; + gboolean pass_struct_by_ref = FALSE; g_callable_info_load_arg(signal_info, i - 1, &arg_info); g_arg_info_load_type(&arg_info, &type_info); arg = _pygi_argument_from_g_value(¶m_values[i], &type_info); - - if (g_type_info_get_tag (&type_info) == GI_TYPE_TAG_ARRAY) { + + type_tag = g_type_info_get_tag (&type_info); + if (type_tag == GI_TYPE_TAG_ARRAY) { /* Skip the self argument of param_values */ arg.v_pointer = _pygi_argument_to_array (&arg, _pygi_argument_array_length_marshal, @@ -127,13 +130,39 @@ pygi_signal_closure_marshal(GClosure *closure, &type_info, &free_array); } - - item = _pygi_argument_to_object (&arg, &type_info, GI_TRANSFER_NOTHING); - + + /* Hack to ensure struct output args are passed-by-reference allowing + * callback implementors to modify the struct values. This is needed + * for keeping backwards compatibility and should be removed in future + * versions which support signal output arguments as return values. + * See: https://bugzilla.gnome.org/show_bug.cgi?id=735486 + */ + if (type_tag == GI_TYPE_TAG_INTERFACE && + g_arg_info_get_direction (&arg_info) == GI_DIRECTION_OUT) { + GIBaseInfo *info = g_type_info_get_interface (&type_info); + GIInfoType info_type = g_base_info_get_type (info); + + if (info_type == GI_INFO_TYPE_STRUCT) { + GType gtype = g_registered_type_info_get_g_type ((GIRegisteredTypeInfo *) info); + if (g_type_is_a (gtype, G_TYPE_BOXED)) { + pass_struct_by_ref = TRUE; + } + } + + g_base_info_unref (info); + } + + if (pass_struct_by_ref) { + item = _pygi_argument_to_object (&arg, &type_info, GI_TRANSFER_EVERYTHING); + ((PyGBoxed *)item)->free_on_dealloc = FALSE; + + } else { + item = _pygi_argument_to_object (&arg, &type_info, GI_TRANSFER_NOTHING); + } + if (free_array) { g_array_free (arg.v_pointer, FALSE); } - if (item == NULL) { goto out; |