From 108982d765e4da1f8bd3293782433428eac0146e Mon Sep 17 00:00:00 2001 From: Stefan Behnel Date: Wed, 13 Feb 2013 19:57:52 +0100 Subject: [PATCH] extend compile time constants error test case --- Cython/Compiler/Parsing.py | 4 ++-- tests/errors/nonconst_def_tuple.pyx | 13 +++++++++++++ 2 files changed, 15 insertions(+), 2 deletions(-) create mode 100644 tests/errors/nonconst_def_tuple.pyx diff --git a/Cython/Compiler/Parsing.py b/Cython/Compiler/Parsing.py index 43b94d9..a17aae3 100644 --- a/Cython/Compiler/Parsing.py +++ b/Cython/Compiler/Parsing.py @@ -711,8 +711,8 @@ def wrap_compile_time_constant(pos, value): else: # error already reported return None - error(pos, "Invalid type for compile-time constant: %s" - % value.__class__.__name__) + error(pos, "Invalid type for compile-time constant: %r (type %s)" + % (value, value.__class__.__name__)) return None diff --git a/tests/errors/nonconst_def_tuple.pyx b/tests/errors/nonconst_def_tuple.pyx new file mode 100644 index 0000000..89d6aeb --- /dev/null +++ b/tests/errors/nonconst_def_tuple.pyx @@ -0,0 +1,13 @@ +# mode: error + +DEF t = (1,2,3) +DEF t_const = (1,t,2) +DEF t_non_const = (1,[1,2,3],3,t[4]) + +x = t_non_const + +_ERRORS = u""" +5:32: Error in compile-time expression: IndexError: tuple index out of range +7:15: Invalid type for compile-time constant: None (type NoneType) +7:15: Invalid type for compile-time constant: [1, 2, 3] (type list) +""" -- 2.7.4