[pygobject/gvalue-support-converters] GValue: fall back to the custom C marshaller to support fundamental types. Fixes #280
- From: Christoph Reiter <creiter src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [pygobject/gvalue-support-converters] GValue: fall back to the custom C marshaller to support fundamental types. Fixes #280
- Date: Sat, 24 Nov 2018 20:19:38 +0000 (UTC)
commit 47239afa31ea189f6b8d020ca903a7253ca1352b
Author: Christoph Reiter <reiter christoph gmail com>
Date: Sat Nov 24 20:56:00 2018 +0100
GValue: fall back to the custom C marshaller to support fundamental types. Fixes #280
In gst-python a custom gvalue converter is registered for GstFraction which is a fundamental type.
In case of Value.set_value/get_value we only support a limited set of types and only fall back
to the C marshaller which looks up the registered converters in case of boxed types.
Instead of raising for an unhandled type fall back to the custom C marshaller.
gi/overrides/GObject.py | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
---
diff --git a/gi/overrides/GObject.py b/gi/overrides/GObject.py
index 44eaa185..e6f5b882 100644
--- a/gi/overrides/GObject.py
+++ b/gi/overrides/GObject.py
@@ -285,7 +285,9 @@ class Value(GObjectModule.Value):
elif gtype == TYPE_VARIANT:
self.set_variant(py_value)
else:
- raise TypeError("Unknown value type %s" % gtype)
+ # Fall back to _gvalue_set which handles some more cases
+ # like fundamentals for which a converter is registered
+ _gi._gvalue_set(self, py_value)
def get_value(self):
gtype = self.g_type
@@ -335,7 +337,7 @@ class Value(GObjectModule.Value):
elif gtype == _gi.TYPE_INVALID:
return None
else:
- raise TypeError("Unknown value type %s" % gtype)
+ return _gi._gvalue_get(self)
def __repr__(self):
return '<Value (%s) %s>' % (self.g_type.name, self.get_value())
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]