Issue #20368: The null character now correctly passed from Tcl to Python.

Improved error handling in variables-related commands.
This commit is contained in:
Serhiy Storchaka 2014-02-03 21:25:56 +02:00
commit ce591c2868
4 changed files with 175 additions and 78 deletions

View file

@ -68,6 +68,18 @@ class TestVariable(TestBase):
with self.assertRaises(TypeError):
Variable(self.root, name=123)
def test_null_in_name(self):
with self.assertRaises(ValueError):
Variable(self.root, name='var\x00name')
with self.assertRaises(ValueError):
self.root.globalsetvar('var\x00name', "value")
with self.assertRaises(ValueError):
self.root.globalsetvar(b'var\x00name', "value")
with self.assertRaises(ValueError):
self.root.setvar('var\x00name', "value")
with self.assertRaises(ValueError):
self.root.setvar(b'var\x00name', "value")
def test_initialize(self):
v = Var()
self.assertFalse(v.side_effect)
@ -87,6 +99,12 @@ class TestStringVar(TestBase):
self.root.globalsetvar("name", "value")
self.assertEqual("value", v.get())
def test_get_null(self):
v = StringVar(self.root, "abc\x00def", "name")
self.assertEqual("abc\x00def", v.get())
self.root.globalsetvar("name", "val\x00ue")
self.assertEqual("val\x00ue", v.get())
class TestIntVar(TestBase):