[pygobject] GVariant: Raise proper TypeError on invalid tuple input
- From: Martin Pitt <martinpitt src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [pygobject] GVariant: Raise proper TypeError on invalid tuple input
- Date: Wed, 20 Jun 2012 09:14:31 +0000 (UTC)
commit a0daa843801658929ffee5bcb9eb67d955dc7921
Author: David Keijser <keijser gmail com>
Date: Mon Jun 18 15:09:34 2012 +0200
GVariant: Raise proper TypeError on invalid tuple input
https://bugzilla.gnome.org/show_bug.cgi?id=678317
Signed-off-by: Martin Pitt <martinpitt gnome org>
gi/overrides/GLib.py | 4 ++--
tests/test_overrides.py | 1 +
2 files changed, 3 insertions(+), 2 deletions(-)
---
diff --git a/gi/overrides/GLib.py b/gi/overrides/GLib.py
index dcb2728..2e8dc9c 100644
--- a/gi/overrides/GLib.py
+++ b/gi/overrides/GLib.py
@@ -88,11 +88,11 @@ class _VariantCreator(object):
builder = GLib.VariantBuilder.new(variant_type_from_string('r'))
if args is not None:
if not args or type(args[0]) != type(()):
- raise (TypeError, 'expected tuple argument')
+ raise TypeError('expected tuple argument')
for i in range(len(args[0])):
if format.startswith(')'):
- raise (TypeError, 'too many arguments for tuple signature')
+ raise TypeError('too many arguments for tuple signature')
(v, format, _) = self._create(format, args[0][i:])
builder.add_value(v)
diff --git a/tests/test_overrides.py b/tests/test_overrides.py
index 0131792..67e51fe 100644
--- a/tests/test_overrides.py
+++ b/tests/test_overrides.py
@@ -230,6 +230,7 @@ class TestGLib(unittest.TestCase):
self.assertRaises(TypeError, GLib.Variant, 'i', 'hello')
self.assertRaises(TypeError, GLib.Variant, 's', 42)
self.assertRaises(TypeError, GLib.Variant, '(ss)', 'mec', 'mac')
+ self.assertRaises(TypeError, GLib.Variant, '(s)', 'hello')
# unimplemented data type
self.assertRaises(NotImplementedError, GLib.Variant, 'Q', 1)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]