diff options
| author | Christoph Reiter <reiter.christoph@gmail.com> | 2019-01-18 18:40:35 +0100 |
|---|---|---|
| committer | Christoph Reiter <reiter.christoph@gmail.com> | 2019-01-18 18:40:35 +0100 |
| commit | 59538e6b256b3ccd6bcaf42f02c151f2fcf23535 (patch) | |
| tree | fb2bccd87a53e1453161460839804704a57ad804 | |
| parent | f122922276bfee0c01141c1ce6690d11399f6f1a (diff) | |
| download | pygobject-59538e6b256b3ccd6bcaf42f02c151f2fcf23535.tar.gz | |
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.
| -rw-r--r-- | gi/overrides/GObject.py | 6 | ||||
| -rw-r--r-- | tests/test_overrides_gobject.py | 8 |
2 files changed, 14 insertions, 0 deletions
diff --git a/gi/overrides/GObject.py b/gi/overrides/GObject.py index 938a19a8..4cc08a9a 100644 --- a/gi/overrides/GObject.py +++ b/gi/overrides/GObject.py @@ -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): diff --git a/tests/test_overrides_gobject.py b/tests/test_overrides_gobject.py index 37292dbb..56a62f13 100644 --- a/tests/test_overrides_gobject.py +++ b/tests/test_overrides_gobject.py @@ -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) |
