mirror of
https://github.com/jupyter/notebook.git
synced 2025-01-24 12:05:22 +08:00
undo failed changes
before raising otherwise, invalid values were still accepted
This commit is contained in:
parent
b51cc50357
commit
62f318c777
@ -298,7 +298,7 @@ def test_default_values():
|
|||||||
)
|
)
|
||||||
|
|
||||||
def test_default_out_of_bounds():
|
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'):
|
def f(f='hi', h=5, j='other'):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
@ -310,13 +310,13 @@ def test_default_out_of_bounds():
|
|||||||
),
|
),
|
||||||
h=dict(
|
h=dict(
|
||||||
cls=widgets.DropdownWidget,
|
cls=widgets.DropdownWidget,
|
||||||
values={'a': 1, 'b': 2},
|
values={'a': 1},
|
||||||
value=1
|
value=1,
|
||||||
),
|
),
|
||||||
j=dict(
|
j=dict(
|
||||||
cls=widgets.DropdownWidget,
|
cls=widgets.DropdownWidget,
|
||||||
values={'hi':'hi', 'there':'there'},
|
values={'hi':'hi', 'there':'there'},
|
||||||
value='hi'
|
value='hi',
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -90,6 +90,8 @@ class _SelectionWidget(DOMWidget):
|
|||||||
# set the selected value name
|
# set the selected value name
|
||||||
self.value_name = k
|
self.value_name = k
|
||||||
return
|
return
|
||||||
|
# undo the change, and raise KeyError
|
||||||
|
self.value = old
|
||||||
raise KeyError(new)
|
raise KeyError(new)
|
||||||
finally:
|
finally:
|
||||||
self.value_lock.release()
|
self.value_lock.release()
|
||||||
|
Loading…
Reference in New Issue
Block a user