diff --git a/src/rougail/objspace.py b/src/rougail/objspace.py index dcf8c0e14..3be267288 100644 --- a/src/rougail/objspace.py +++ b/src/rougail/objspace.py @@ -393,7 +393,7 @@ class RougailObjSpace: for attr, val in child.attrib.items(): if redefine and attr in UNREDEFINABLE: msg = _(f'cannot redefine attribute "{attr}" for variable "{child.attrib["name"]}"' - f' in "{xmlfile}", already defined') + f' already defined') raise DictConsistencyError(msg, 48, variableobj.xmlfiles[:-1]) if attr in self.booleans_attributs: val = convert_boolean(val) @@ -411,6 +411,10 @@ class RougailObjSpace: """ if child.tag == 'variable': if child.attrib.get('remove_choice', False): + if variableobj.type != 'choice': + msg = _(f'cannot remove choices for variable "{variableobj.path}"' + f' the variable has type "{variableobj.type}"') + raise DictConsistencyError(msg, 33, variableobj.xmlfiles) variableobj.choice = [] if child.attrib.get('remove_check', False): self.remove_check(variableobj.name) diff --git a/tests/dictionaries/88remove_choice_not_choice/00-base.xml b/tests/dictionaries/88remove_choice_not_choice/00-base.xml new file mode 100644 index 000000000..57cc7646f --- /dev/null +++ b/tests/dictionaries/88remove_choice_not_choice/00-base.xml @@ -0,0 +1,7 @@ + + + + + + + diff --git a/tests/dictionaries/88remove_choice_not_choice/01-base.xml b/tests/dictionaries/88remove_choice_not_choice/01-base.xml new file mode 100644 index 000000000..f7fb6e5ca --- /dev/null +++ b/tests/dictionaries/88remove_choice_not_choice/01-base.xml @@ -0,0 +1,8 @@ + + + + + + + + diff --git a/tests/dictionaries/88remove_choice_not_choice/__init__.py b/tests/dictionaries/88remove_choice_not_choice/__init__.py new file mode 100644 index 000000000..e69de29bb diff --git a/tests/dictionaries/88remove_choice_not_choice/errno_33 b/tests/dictionaries/88remove_choice_not_choice/errno_33 new file mode 100644 index 000000000..e69de29bb