GNOME Bugzilla – Bug 609200
Change from November breaks argument (allow-none)
Last modified: 2010-02-08 18:13:21 UTC
Created attachment 153173 [details] [review] Testcase for argument allow-none (Stupidly) I have been working on a relatively old HEAD from upstream for all my pygi work. I've recently been pushing things upstream and in the process rebasing against new trees. I found that several things in my project have broken since doing the rebase. This is the first bug I've been able to definitively nail down. The following hunk from b55503780abb7e065eda5ba8b4f53a742aca9e53 breaks (allow-none) input arguments. (e.g. you cant pass in None anymore). diff --git a/gi/pygi-argument.c b/gi/pygi-argument.c index 4717133..d13cef7 100644 --- a/gi/pygi-argument.c +++ b/gi/pygi-argument.c @@ -645,16 +645,8 @@ _pygi_argument_from_object (PyObject *object, { GArgument arg; GITypeTag type_tag; - gboolean is_pointer; type_tag = g_type_info_get_tag(type_info); - is_pointer = g_type_info_is_pointer(type_info); - - if (object == Py_None && is_pointer - && type_tag != GI_TYPE_TAG_BOOLEAN) { /* We want None == FALSE. */ - arg.v_pointer = NULL; - return arg; - } switch (type_tag) { case GI_TYPE_TAG_VOID: Attached to this bug report is a test case which works with this hunt reverted (patch -R), and breaks with this hunk applied.
This hunk also causes an abort: diff --git a/gi/pygi-argument.c b/gi/pygi-argument.c index 31500aa..9841b4f 100644 --- a/gi/pygi-argument.c +++ b/gi/pygi-argument.c @@ -1373,19 +1373,12 @@ _pygi_argument_to_object (GArgument *arg, GITransfer transfer) { GITypeTag type_tag; - gboolean is_pointer; PyObject *object = NULL; type_tag = g_type_info_get_tag(type_info); - is_pointer = g_type_info_is_pointer(type_info); - - if (is_pointer && arg->v_pointer == NULL) { - Py_RETURN_NONE; - } - switch (type_tag) { case GI_TYPE_TAG_VOID: - if (is_pointer) { + if (g_type_info_is_pointer(type_info)) { /* Raw Python objects are passed to void* args */ g_warn_if_fail(transfer == GI_TRANSFER_NOTHING); object = arg->v_pointer; ERROR:pygi-argument.c:2090:_pygi_argument_to_object: code should not be reached Line 2090: case GI_TYPE_TAG_ERROR: /* Errors should be handled in the invoke wrapper. */ g_assert_not_reached();
There was a couple of issues with nullable arguments and the latest gobject-introspection, and I had to (almost completely) drop the code that (partially) supported that in PyGI; I opened a bugreport to fix that later. *** This bug has been marked as a duplicate of bug 607664 ***