From da99d1cbfeedafd41263ac2d1b397d57c14ab28e Mon Sep 17 00:00:00 2001 From: Raymond Hettinger Date: Tue, 21 Jun 2005 07:43:58 +0000 Subject: SF bug #1224621: tokenize module does not detect inconsistent dedents --- Lib/tokenize.py | 3 +++ 1 file changed, 3 insertions(+) (limited to 'Lib/tokenize.py') diff --git a/Lib/tokenize.py b/Lib/tokenize.py index b29da6b7ad..2b40e6f31b 100644 --- a/Lib/tokenize.py +++ b/Lib/tokenize.py @@ -271,6 +271,9 @@ def generate_tokens(readline): indents.append(column) yield (INDENT, line[:pos], (lnum, 0), (lnum, pos), line) while column < indents[-1]: + if column not in indents: + raise IndentationError( + "unindent does not match any outer indentation level") indents = indents[:-1] yield (DEDENT, '', (lnum, pos), (lnum, pos), line) -- cgit v1.2.1