python: fix error message of translate()/posprocess()

* python/spot/__init__.py: Here.
* NEWS: Mention the bug.
This commit is contained in:
Alexandre Duret-Lutz 2018-03-28 10:31:02 +02:00
parent 4ac3143b53
commit ee30f96676
2 changed files with 18 additions and 9 deletions

3
NEWS
View file

@ -32,6 +32,9 @@ New in spot 2.5.2.dev (not yet released)
- "autfilt --cobuchi --small/--det" would turn a transition-based - "autfilt --cobuchi --small/--det" would turn a transition-based
co-Büchi automaton into a state-based co-Büchi. co-Büchi automaton into a state-based co-Büchi.
- Fix cryptic error message from Python's spot.translate() and
spot.postprocess() when supplying conflicting arguments.
New in spot 2.5.2 (2018-03-25) New in spot 2.5.2 (2018-03-25)
Bugs fixed: Bugs fixed:

View file

@ -484,8 +484,11 @@ def automaton(filename, **kwargs):
def _postproc_translate_options(obj, default_type, *args): def _postproc_translate_options(obj, default_type, *args):
type_name_ = None
type_ = None type_ = None
pref_name_ = None
pref_ = None pref_ = None
optm_name_ = None
optm_ = None optm_ = None
comp_ = 0 comp_ = 0
unam_ = 0 unam_ = 0
@ -493,10 +496,10 @@ def _postproc_translate_options(obj, default_type, *args):
colo_ = 0 colo_ = 0
def type_set(val): def type_set(val):
nonlocal type_ nonlocal type_, type_name_
if type_ is not None and type_ != val: if type_ is not None and type_name_ != val:
raise ValueError("type cannot be both {} and {}" raise ValueError("type cannot be both {} and {}"
.format(type_, val)) .format(type_name_, val))
elif val == 'generic': elif val == 'generic':
type_ = postprocessor.Generic type_ = postprocessor.Generic
elif val == 'tgba': elif val == 'tgba':
@ -529,12 +532,13 @@ def _postproc_translate_options(obj, default_type, *args):
else: else:
assert(val == 'monitor') assert(val == 'monitor')
type_ = postprocessor.Monitor type_ = postprocessor.Monitor
type_name_ = val
def pref_set(val): def pref_set(val):
nonlocal pref_ nonlocal pref_, pref_name_
if pref_ is not None and pref_ != 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_, val)) .format(pref_name, val))
elif val == 'small': elif val == 'small':
pref_ = postprocessor.Small pref_ = postprocessor.Small
elif val == 'deterministic': elif val == 'deterministic':
@ -542,12 +546,13 @@ def _postproc_translate_options(obj, default_type, *args):
else: else:
assert(val == 'any') assert(val == 'any')
pref_ = postprocessor.Any pref_ = postprocessor.Any
pref_name_ = val
def optm_set(val): def optm_set(val):
nonlocal optm_ nonlocal optm_, optm_name_
if optm_ is not None and optm_ != val: if optm_ is not None and optm_name_ != val:
raise ValueError("optimization level cannot be both {} and {}" raise ValueError("optimization level cannot be both {} and {}"
.format(optm_, val)) .format(optm_name_, val))
if val == 'high': if val == 'high':
optm_ = postprocessor.High optm_ = postprocessor.High
elif val.startswith('med'): elif val.startswith('med'):
@ -555,6 +560,7 @@ def _postproc_translate_options(obj, default_type, *args):
else: else:
assert(val == 'low') assert(val == 'low')
optm_ = postprocessor.Low optm_ = postprocessor.Low
optm_name_ = val
def misc_set(val): def misc_set(val):
nonlocal comp_, unam_, sbac_, colo_ nonlocal comp_, unam_, sbac_, colo_