From 91d387de7df9e19bb5b00e6ad4c94790eb3422e3 Mon Sep 17 00:00:00 2001 From: Damien Date: Wed, 9 Oct 2013 15:09:52 +0100 Subject: Improve indent/dedent error checking and reporting. --- py/compile.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'py/compile.c') diff --git a/py/compile.c b/py/compile.c index f4a5886b0b..3d5a29a192 100644 --- a/py/compile.c +++ b/py/compile.c @@ -2192,7 +2192,14 @@ void compile_node(compiler_t *comp, py_parse_node_t pn) { case PY_PARSE_NODE_DECIMAL: EMIT(load_const_dec, arg); break; case PY_PARSE_NODE_STRING: EMIT(load_const_str, arg, false); break; case PY_PARSE_NODE_BYTES: EMIT(load_const_str, arg, true); break; - case PY_PARSE_NODE_TOKEN: EMIT(load_const_tok, arg); break; + case PY_PARSE_NODE_TOKEN: + if (arg == PY_TOKEN_NEWLINE) { + // this can occur when file_input lets through a NEWLINE (eg if file starts with a newline) + // do nothing + } else { + EMIT(load_const_tok, arg); + } + break; default: assert(0); } } else { -- cgit v1.2.3