undo failed changes

before raising

otherwise, invalid values were still accepted
This commit is contained in:
MinRK 2014-02-20 22:37:32 -08:00
parent b51cc50357
commit 62f318c777
2 changed files with 6 additions and 4 deletions

View File

@ -298,7 +298,7 @@ def test_default_values():
)
def test_default_out_of_bounds():
@annotate(f=(0, 10.), h={'a': 1, 'b': 2}, j=['hi', 'there'])
@annotate(f=(0, 10.), h={'a': 1}, j=['hi', 'there'])
def f(f='hi', h=5, j='other'):
pass
@ -310,13 +310,13 @@ def test_default_out_of_bounds():
),
h=dict(
cls=widgets.DropdownWidget,
values={'a': 1, 'b': 2},
value=1
values={'a': 1},
value=1,
),
j=dict(
cls=widgets.DropdownWidget,
values={'hi':'hi', 'there':'there'},
value='hi'
value='hi',
),
)

View File

@ -90,6 +90,8 @@ class _SelectionWidget(DOMWidget):
# set the selected value name
self.value_name = k
return
# undo the change, and raise KeyError
self.value = old
raise KeyError(new)
finally:
self.value_lock.release()