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 683099 - Support GParamSpec signal arguments
Support GParamSpec signal arguments
Status: RESOLVED FIXED
Product: pygobject
Classification: Bindings
Component: introspection
Git master
Other Linux
: Normal normal
: ---
Assigned To: Nobody's working on this now (help wanted and appreciated)
Python bindings maintainers
Depends on: 685275
Blocks:
 
 
Reported: 2012-08-31 12:02 UTC by Mark Nauwelaerts
Modified: 2013-01-14 11:23 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Support marshalling GParamSpec signal arguments (1.51 KB, patch)
2012-08-31 12:02 UTC, Mark Nauwelaerts
committed Details | Review
attempt for a test case (1.94 KB, patch)
2012-09-03 10:10 UTC, Martin Pitt
none Details | Review
testcase for C -> Python direction (2.88 KB, patch)
2012-09-03 10:20 UTC, Martin Pitt
committed Details | Review
Script to reproduce C -> python unsupported marshalling (318 bytes, text/x-python)
2012-09-03 12:33 UTC, Mark Nauwelaerts
  Details
testcase for Python -> C direction (1.78 KB, patch)
2012-09-03 14:22 UTC, Martin Pitt
none Details | Review
testcase for Python -> C direction (2.14 KB, patch)
2013-01-14 10:40 UTC, Martin Pitt
committed Details | Review

Description Mark Nauwelaerts 2012-08-31 12:02:57 UTC
Created attachment 223044 [details] [review]
Support marshalling GParamSpec signal arguments

See also https://bugzilla.gnome.org/show_bug.cgi?id=681565

Looks like there are some other codepaths where a GParamSpec needs to be wrapped to a python type and where it is currently treated like a GObject, notably when a GParamSpec occurs as a signal arg, such as in gstreamer's GstObject::deep-notify signal
Comment 1 Martin Pitt 2012-09-03 10:10:18 UTC
Created attachment 223269 [details] [review]
attempt for a test case

This is an attempt to provide a test case for this. However, it fails a lot earlier, in pyg_value_from_pyobject() it is trying to do

		    g_value_set_param(value, PYGLIB_CPointer_GetPointer(obj, NULL));

but PYGLIB_CPointer_GetPointer(obj, NULL) == NULL in this case, so the generated GValue is invalid. So the marshalling from Python to C for GParamSpec signal arguments is broken.

However, your patch fixes the other direction (marshalling from C to Python), so I guess we have to reduce the test case for this to just this direction, and keep this as a full test case as part of bug 682355?
Comment 2 Martin Pitt 2012-09-03 10:20:29 UTC
Created attachment 223272 [details] [review]
testcase for C -> Python direction

Even with this reduced test case, which only checks C -> Python marshalling this patch does not help at all, as this now crashes with

testTestReturnParamSpec (test_signal.TestCMarshaller) ... 
** (process:6095): WARNING **: Unsupported fundamental type: GParam
make[2]: *** [check-local] Trace/Breakpoint ausgelöst (Speicherauszug erstellt)

in gi_cclosure_marshal_generic() from g-i.

Do you have a reproducer script etc. which can be used to test that this patch actually does something useful?

Thanks!
Comment 3 Mark Nauwelaerts 2012-09-03 12:33:05 UTC
Created attachment 223289 [details]
Script to reproduce C -> python unsupported marshalling

Supplied patch indeed intends to fix a C to Python marshalling bug, but one where the signal is triggered in C and the ParamSpec is an argument to be marshalled to a Python callback.  This is (apparently) another code path than the test case, where the invoked callback is a C one, whose return value has to be marshalled to C.

In summary, this python script will fail without the supplied patch, but works fine with the patch.
Comment 4 Mark Nauwelaerts 2012-09-03 12:53:06 UTC
FWIW/FTR, the problem encountered by the (restricted) test case seems resolved by the patch to the newly reported gobject-introspection bug #683265.
Comment 5 Martin Pitt 2012-09-03 14:09:00 UTC
Comment on attachment 223272 [details] [review]
testcase for C -> Python direction

Indeed, with the patch from bug 683265 applied the "testcase for C -> Python direction" works just fine. So this code path is indeed independent from your patch.

I committed the test case part from this now, as the g-i fix just landed in trunk.
Comment 6 Martin Pitt 2012-09-03 14:22:44 UTC
Created attachment 223327 [details] [review]
testcase for Python -> C direction

This is the other half of the test case which checks the "python signal argument -> C" direction. As stated above, it fails with

testTestReturnParamSpec (test_signal.TestCMarshaller) ... 
(runtests.py:13547): GLib-GObject-CRITICAL **: g_value_unset: assertion `G_IS_VALUE (value)' failed

in pyg_value_from_pyobject(), when it is trying to do

            g_value_set_param(value, PYGLIB_CPointer_GetPointer(obj, NULL));

PYGLIB_CPointer_GetPointer(obj, NULL) == NULL in this case, so the
generated GValue is invalid. So the marshalling from Python to C for GParamSpec
signal arguments is broken.

This is orthogonal to your patch, but I keep the test case here anyway because this code path needs fixing as well.
Comment 7 Martin Pitt 2012-09-03 14:24:11 UTC
Confirming that the attached script reproduces the problem and the patch works. Thanks!

I'll spend some time to write a proper test case for this.
Comment 8 Martin Pitt 2012-09-03 14:49:08 UTC
Comment on attachment 223044 [details] [review]
Support marshalling GParamSpec signal arguments

Committed your patch with a test case. Thanks!

http://git.gnome.org/browse/pygobject/commit/?id=0d099bdb3f4bbd962e5e60b583673d9e6f5673cc
Comment 9 Martin Pitt 2012-09-03 14:49:41 UTC
Comment on attachment 223289 [details]
Script to reproduce C -> python unsupported marshalling

This reproducer script is obsolete, the same approach (which does not need GStreamer) went into the test suite.
Comment 10 Martin Pitt 2012-09-03 14:50:51 UTC
Keeping bug open for the Python -> C direction.
Comment 11 Martin Pitt 2013-01-14 10:40:17 UTC
Created attachment 233432 [details] [review]
testcase for Python -> C direction

Update Python -> C direction test case to current git head.
Comment 12 Martin Pitt 2013-01-14 11:23:12 UTC
Fixed the Python -> C direction as well:

http://git.gnome.org/browse/pygobject/commit/?id=f9429192cb1002725a11a75a7b8f9300375b9caf