Skip to content

Commit 81d57ba

Browse files
committed
deep copy parameters options and buttons of input functions
1 parent 20bb478 commit 81d57ba

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

pywebio/input.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,7 @@
7575
import os.path
7676
import logging
7777
from collections.abc import Mapping
78+
import copy
7879

7980
from .io_ctrl import single_input, input_control, output_register_callback, send_msg, single_input_kwargs
8081
from .session import get_current_session, get_current_task_id
@@ -299,14 +300,14 @@ def _parse_select_options(options):
299300
# value (label same as value)
300301
opts_res = []
301302
for opt in options:
303+
opt = copy.deepcopy(opt)
302304
if isinstance(opt, Mapping):
303305
assert 'value' in opt and 'label' in opt, 'options item must have value and label key'
304306
elif isinstance(opt, (list, tuple)):
305307
assert len(opt) > 1 and len(opt) <= 4, 'options item format error'
306308
opt = dict(zip(('label', 'value', 'selected', 'disabled'), opt))
307309
else:
308310
opt = dict(value=opt, label=opt)
309-
opt['value'] = opt['value']
310311
opts_res.append(opt)
311312

312313
return opts_res
@@ -430,6 +431,7 @@ def _parse_action_buttons(buttons):
430431
"""
431432
act_res = []
432433
for act in buttons:
434+
act = copy.deepcopy(act)
433435
if isinstance(act, Mapping):
434436
assert 'label' in act, 'actions item must have label key'
435437
assert 'value' in act or act.get('type', 'submit') != 'submit' or act.get('disabled'), \

0 commit comments

Comments
 (0)