After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 609200 - Change from November breaks argument (allow-none)
Change from November breaks argument (allow-none)
Status: RESOLVED DUPLICATE of bug 607664
Product: pygi
Classification: Deprecated
Component: general
unspecified
Other Linux
: Normal normal
: 0.6
Assigned To: pygi-maint
pygi-maint
Depends on:
Blocks:
 
 
Reported: 2010-02-07 00:12 UTC by Zach Goldberg
Modified: 2010-02-08 18:13 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Testcase for argument allow-none (1.21 KB, patch)
2010-02-07 00:12 UTC, Zach Goldberg
none Details | Review

Description Zach Goldberg 2010-02-07 00:12:36 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.
Comment 1 Zach Goldberg 2010-02-07 19:38:52 UTC
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();
Comment 2 Simon van der Linden 2010-02-08 18:13:21 UTC
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 ***