浏览代码

fix `buttons` parameter check

wangweimin 5 年之前
父节点
当前提交
a58318eb59
共有 2 个文件被更改,包括 2 次插入2 次删除
  1. 1 1
      pywebio/input.py
  2. 1 1
      pywebio/output.py

+ 1 - 1
pywebio/input.py

@@ -210,7 +210,7 @@ def _parse_action_buttons(buttons):
     for act in buttons:
     for act in buttons:
         if isinstance(act, Mapping):
         if isinstance(act, Mapping):
             assert 'value' in act and 'label' in act, 'actions item must have value and label key'
             assert 'value' in act and 'label' in act, 'actions item must have value and label key'
-        elif isinstance(act, list):
+        elif isinstance(act, (list, tuple)):
             assert len(act) in (2, 3), 'actions item format error'
             assert len(act) in (2, 3), 'actions item format error'
             act = dict(zip(('label', 'value', 'disabled'), act))
             act = dict(zip(('label', 'value', 'disabled'), act))
         else:
         else:

+ 1 - 1
pywebio/output.py

@@ -241,7 +241,7 @@ def _format_button(buttons):
     for btn in buttons:
     for btn in buttons:
         if isinstance(btn, Mapping):
         if isinstance(btn, Mapping):
             assert 'value' in btn and 'label' in btn, 'actions item must have value and label key'
             assert 'value' in btn and 'label' in btn, 'actions item must have value and label key'
-        elif isinstance(btn, list):
+        elif isinstance(btn, (list, tuple)):
             assert len(btn) == 2, 'actions item format error'
             assert len(btn) == 2, 'actions item format error'
             btn = dict(zip(('label', 'value'), btn))
             btn = dict(zip(('label', 'value'), btn))
         else:
         else: