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 351072 - Cannot handle signals with parameter type G_TYPE_VALUE (marshal/unmarshal for GValue-wrapped GValue)
Cannot handle signals with parameter type G_TYPE_VALUE (marshal/unmarshal for...
Status: RESOLVED FIXED
Product: pygobject
Classification: Bindings
Component: gobject
2.11.x
Other Linux
: Normal enhancement
: ---
Assigned To: Nobody's working on this now (help wanted and appreciated)
Python bindings maintainers
Depends on:
Blocks: 345592
 
 
Reported: 2006-08-12 19:00 UTC by Ed Catmur
Modified: 2007-07-07 12:10 UTC
See Also:
GNOME target: ---
GNOME version: 2.15/2.16


Attachments
pygobject-marshal-gvalue-gvalue.patch (1.44 KB, patch)
2006-08-21 02:48 UTC, Ed Catmur
none Details | Review
TestCase (1.83 KB, patch)
2007-07-06 16:57 UTC, inean
committed Details | Review
Updated path to be commited in trunk (1.57 KB, patch)
2007-07-06 16:59 UTC, inean
committed Details | Review
Changelog (650 bytes, patch)
2007-07-06 16:59 UTC, inean
committed Details | Review

Description Ed Catmur 2006-08-12 19:00:35 UTC
Background: at bug 345592 we want a polymorphic signal: one which has G_TYPE_VALUE as one of its parameter types.

Currently pyg_value_{from,as}_pyobject does not handle the case where the GValue itself stores a GValue. It seems that fixing this would be the easiest way to enable such signals to be emitted and connected to from Python.
Comment 1 Gustavo Carneiro 2006-08-12 20:26:16 UTC
Confirming.

Hint: if you don't need these signals to interface with C code, only from python to python, you can use the type 'object' to allow any python object as signal argument (in C land it is a boxed type).
Comment 2 Ed Catmur 2006-08-21 02:48:01 UTC
Created attachment 71270 [details] [review]
pygobject-marshal-gvalue-gvalue.patch

Suggested patch.
Comment 3 Ed Catmur 2006-08-21 03:45:55 UTC
Workaround is to use these functions in embedding code:

static PyObject *
pyg_value_g_value_as_pyobject (const GValue *value)
{
	return pyg_value_as_pyobject((GValue *)g_value_get_boxed(value), FALSE);
}

static int
pyg_value_g_value_from_pyobject (GValue *value, PyObject *obj)
{
	GType type;
	GValue obj_value = { 0, };
	
	type = pyg_type_from_object((PyObject *) obj->ob_type);
	if (! type) {
		PyErr_Clear();
		return -1;
	}
	g_value_init(&obj_value, type);
	if (pyg_value_from_pyobject(&obj_value, obj) == -1) {
		g_value_unset(&obj_value);
		return -1;
	}
	g_value_set_boxed(value, &obj_value);
	g_value_unset(&obj_value);
	return 0;
}

...

	init_pygobject ();

	pyg_register_gtype_custom (G_TYPE_VALUE, pyg_value_g_value_as_pyobject, pyg_value_g_value_from_pyobject);
Comment 4 Johan (not receiving bugmail) Dahlin 2007-04-30 02:51:22 UTC
(In reply to comment #2)
> Created an attachment (id=71270) [edit]
> pygobject-marshal-gvalue-gvalue.patch
> 
> Suggested patch.
> 

In general the patch looks good. But it's missing a test, do you think you can write a simple testcase demostrating this bug?
Comment 5 inean 2007-07-06 16:57:06 UTC
Created attachment 91313 [details] [review]
TestCase
Comment 6 inean 2007-07-06 16:59:32 UTC
Created attachment 91314 [details] [review]
Updated path to be commited in trunk
Comment 7 inean 2007-07-06 16:59:56 UTC
Created attachment 91315 [details] [review]
Changelog
Comment 8 Gustavo Carneiro 2007-07-07 12:10:49 UTC
This problem has been fixed in the development version. The fix will be available in the next major software release. Thank you for your bug report.