From: Stefan Behnel Date: Sun, 14 Mar 2010 11:05:07 +0000 (+0100) Subject: better error output X-Git-Tag: 0.13.beta0~297 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=31fac6c53aff52c3fe049bf6e40ddf24aef67a85;p=cython.git better error output --- diff --git a/Cython/Compiler/Options.py b/Cython/Compiler/Options.py index 8e822ebf..08a38d32 100644 --- a/Cython/Compiler/Options.py +++ b/Cython/Compiler/Options.py @@ -102,11 +102,12 @@ def parse_directive_value(name, value, relaxed_bool=False): >>> parse_directive_value('boundscheck', 'true') Traceback (most recent call last): ... - ValueError: boundscheck directive must be set to True or False + ValueError: boundscheck directive must be set to True or False, got 'true' """ type = directive_types.get(name) if not type: return None + orig_value = value if type is bool: value = str(value) if value == 'True': return True @@ -115,12 +116,14 @@ def parse_directive_value(name, value, relaxed_bool=False): value = value.lower() if value in ("true", "yes"): return True elif value in ("false", "no"): return False - raise ValueError("%s directive must be set to True or False" % name) + raise ValueError("%s directive must be set to True or False, got %r" % ( + name, orig_value)) elif type is int: try: return int(value) except ValueError: - raise ValueError("%s directive must be set to an integer" % name) + raise ValueError("%s directive must be set to an integer, got %r" % ( + name, orig_value)) elif type is str: return str(value) else: @@ -143,7 +146,7 @@ def parse_directive_list(s, relaxed_bool=False, ignore_unknown=False): >>> parse_directive_list('boundscheck=hey') Traceback (most recent call last): ... - ValueError: boundscheck directive must be set to True or False + ValueError: boundscheck directive must be set to True or False, got 'hey' >>> parse_directive_list('unknown=True') Traceback (most recent call last): ...