_postproc_translate_options: fix syntax error

* python/spot/__init__.py: Here.
* tests/python/except.py: Add test.
* NEWS: Mention the issue.
This commit is contained in:
Alexandre Duret-Lutz 2020-02-10 11:37:58 +01:00
parent 71f1f2fb96
commit 09bb61db33
3 changed files with 16 additions and 3 deletions

4
NEWS
View file

@ -92,6 +92,10 @@ New in spot 2.8.5.dev (not yet released)
consequence, some correct output could be larger than necessary consequence, some correct output could be larger than necessary
(but still correct). (but still correct).
- calling spot.translate() with two conflicting preferences like
spot.translate(..., 'det', 'any') triggered a syntax error in the
Python code to handle this error.
New in spot 2.8.5 (2020-01-04) New in spot 2.8.5 (2020-01-04)
Bugs fixed: Bugs fixed:

View file

@ -1,5 +1,5 @@
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
# Copyright (C) 2014-2019 Laboratoire de # Copyright (C) 2014-2020 Laboratoire de
# Recherche et Développement de l'Epita (LRDE). # Recherche et Développement de l'Epita (LRDE).
# #
# This file is part of Spot, a model checking library. # This file is part of Spot, a model checking library.
@ -622,7 +622,7 @@ def _postproc_translate_options(obj, default_type, *args):
nonlocal pref_, pref_name_ nonlocal pref_, pref_name_
if pref_ is not None and pref_name_ != val: if pref_ is not None and pref_name_ != val:
raise ValueError("preference cannot be both {} and {}" raise ValueError("preference cannot be both {} and {}"
.format(pref_name, val)) .format(pref_name_, val))
elif val == 'small': elif val == 'small':
pref_ = postprocessor.Small pref_ = postprocessor.Small
elif val == 'deterministic': elif val == 'deterministic':

View file

@ -1,5 +1,5 @@
# -*- mode: python; coding: utf-8 -*- # -*- mode: python; coding: utf-8 -*-
# Copyright (C) 2018, 2019 Laboratoire de Recherche et Développement de # Copyright (C) 2018-2020 Laboratoire de Recherche et Développement de
# l'Epita (LRDE). # l'Epita (LRDE).
# #
# This file is part of Spot, a model checking library. # This file is part of Spot, a model checking library.
@ -179,3 +179,12 @@ except RuntimeError as e:
assert "requires a semi-deterministic input" in str(e) assert "requires a semi-deterministic input" in str(e)
else: else:
report_missing_exception() report_missing_exception()
try:
spot.translate('F(G(a | !a) & ((b <-> c) W d))', 'det', 'any')
except ValueError as e:
s = str(e)
assert 'det' in s
assert 'any' in s
else:
report_missing_exception()