Commit b66e964e authored by Christoph Reiter's avatar Christoph Reiter 🐍

Value.set_value: allow None for TYPE_STRING

set_string() allows it too
parent 6c69fc7b
......@@ -258,8 +258,8 @@ class Value(GObjectModule.Value):
elif gtype == TYPE_DOUBLE:
self.set_double(py_value)
elif gtype == TYPE_STRING:
if isinstance(py_value, str):
py_value = str(py_value)
if py_value is None or isinstance(py_value, str):
py_value = py_value
elif PY2:
if isinstance(py_value, text_type):
py_value = py_value.encode('UTF-8')
......
......@@ -222,8 +222,8 @@ def test_value_string():
assert v.get_value() == u"quux"
assert isinstance(v.get_value(), str)
with pytest.raises(TypeError):
v.set_value(None)
v.set_value(None)
assert v.get_value() is None
def test_value_pyobject():
......
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