SF bug #1224621: tokenize module does not detect inconsistent dedents

This commit is contained in:
Raymond Hettinger 2005-06-21 07:43:58 +00:00
parent 8fa7eb563b
commit da99d1cbfe
3 changed files with 25 additions and 1 deletions

View file

@ -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)