Commit 59538e6b authored by Christoph Reiter's avatar Christoph Reiter 🐍

GObject.Value: deprecate calling get/set_boxed on a non-boxed value

This wasn't documented but worked in most cases. Make sure no-one is depending
on it in the long run.
parent f1229222
......@@ -210,12 +210,18 @@ class Value(GObjectModule.Value):
self.set_value(py_value)
def set_boxed(self, boxed):
if not self.g_type.is_a(TYPE_BOXED):
warnings.warn('Calling set_boxed() on a non-boxed type deprecated',
PyGIDeprecationWarning, stacklevel=2)
# Workaround the introspection marshalers inability to know
# these methods should be marshaling boxed types. This is because
# the type information is stored on the GValue.
_gi._gvalue_set(self, boxed)
def get_boxed(self):
if not self.g_type.is_a(TYPE_BOXED):
warnings.warn('Calling get_boxed() on a non-boxed type deprecated',
PyGIDeprecationWarning, stacklevel=2)
return _gi._gvalue_get(self)
def set_value(self, py_value):
......
......@@ -266,3 +266,11 @@ def test_value_uchar():
with pytest.raises(OverflowError):
v.set_value(256)
def test_value_set_boxed_deprecate_non_boxed():
v = GObject.Value(GObject.TYPE_POINTER)
with pytest.warns(PyGIDeprecationWarning):
v.get_boxed()
with pytest.warns(PyGIDeprecationWarning):
v.set_boxed(None)
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment