[pygobject] Variant.keys: correctly raise TypeError for non-dict types
- From: Christoph Reiter <creiter src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [pygobject] Variant.keys: correctly raise TypeError for non-dict types
- Date: Wed, 21 Nov 2018 22:28:23 +0000 (UTC)
commit 66161778dfac3ad7a075a22052482c7593efe0bc
Author: Christoph Reiter <reiter christoph gmail com>
Date: Wed Nov 21 23:26:39 2018 +0100
Variant.keys: correctly raise TypeError for non-dict types
It was returning instead of raising the error for some reason.
gi/overrides/GLib.py | 2 +-
tests/test_overrides_glib.py | 3 +++
2 files changed, 4 insertions(+), 1 deletion(-)
---
diff --git a/gi/overrides/GLib.py b/gi/overrides/GLib.py
index 97bdfc1c..650d6bd8 100644
--- a/gi/overrides/GLib.py
+++ b/gi/overrides/GLib.py
@@ -392,7 +392,7 @@ class Variant(GLib.Variant):
def keys(self):
if not self.get_type_string().startswith('a{'):
- return TypeError, 'GVariant type %s is not a dictionary' % self.get_type_string()
+ raise TypeError('GVariant type %s is not a dictionary' % self.get_type_string())
res = []
for i in range(self.n_children()):
diff --git a/tests/test_overrides_glib.py b/tests/test_overrides_glib.py
index 947c74bf..82a2608d 100644
--- a/tests/test_overrides_glib.py
+++ b/tests/test_overrides_glib.py
@@ -143,6 +143,9 @@ class TestGVariant(unittest.TestCase):
with pytest.raises(TypeError):
variant[0]
+ with pytest.raises(TypeError):
+ variant.keys()
+
def test_create_variant(self):
variant = GLib.Variant('v', GLib.Variant('i', 42))
self.assertTrue(isinstance(variant, GLib.Variant))
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]