[pygobject: 5/5] Value.set_value: raise TypeError in case the wrong type is passed, not ValueError



commit b4a911aa4804ff6efb8780e76f499a92894f858f
Author: Christoph Reiter <reiter christoph gmail com>
Date:   Sat Nov 24 19:23:22 2018 +0100

    Value.set_value: raise TypeError in case the wrong type is passed, not ValueError

 gi/overrides/GObject.py         | 8 ++++----
 tests/test_overrides_gobject.py | 4 ++--
 2 files changed, 6 insertions(+), 6 deletions(-)
---
diff --git a/gi/overrides/GObject.py b/gi/overrides/GObject.py
index 7129c92c..44eaa185 100644
--- a/gi/overrides/GObject.py
+++ b/gi/overrides/GObject.py
@@ -260,11 +260,11 @@ class Value(GObjectModule.Value):
                 if isinstance(py_value, text_type):
                     py_value = py_value.encode('UTF-8')
                 else:
-                    raise ValueError("Expected string or unicode but got %s%s" %
-                                     (py_value, type(py_value)))
+                    raise TypeError("Expected string or unicode but got %s%s" %
+                                    (py_value, type(py_value)))
             else:
-                raise ValueError("Expected string but got %s%s" %
-                                 (py_value, type(py_value)))
+                raise TypeError("Expected string but got %s%s" %
+                                (py_value, type(py_value)))
             self.set_string(py_value)
         elif gtype == TYPE_PARAM:
             self.set_param(py_value)
diff --git a/tests/test_overrides_gobject.py b/tests/test_overrides_gobject.py
index 6cd93be1..3c7cc04b 100644
--- a/tests/test_overrides_gobject.py
+++ b/tests/test_overrides_gobject.py
@@ -206,14 +206,14 @@ def test_value_string():
         v.set_value(u"öäü")
         assert v.get_value().decode("utf-8") == u"öäü"
     else:
-        with pytest.raises(ValueError):
+        with pytest.raises(TypeError):
             v.set_value(b"bar")
 
     v.set_value(u"quux")
     assert v.get_value() == u"quux"
     assert isinstance(v.get_value(), str)
 
-    with pytest.raises(ValueError):
+    with pytest.raises(TypeError):
         v.set_value(None)
 
 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]