Fix unbound local error in RE tokenizer example. Thanks to Herman L. Jackson.

This commit is contained in:
Georg Brandl 2011-05-13 06:54:23 +02:00
parent cc5ea6860f
commit 325477e20e
1 changed files with 2 additions and 1 deletions

View File

@ -1322,9 +1322,10 @@ successive matches::
line_start = pos line_start = pos
line += 1 line += 1
elif typ != 'SKIP': elif typ != 'SKIP':
val = mo.group(typ)
if typ == 'ID' and val in keywords: if typ == 'ID' and val in keywords:
typ = val typ = val
yield Token(typ, mo.group(typ), line, mo.start()-line_start) yield Token(typ, val, line, mo.start()-line_start)
pos = mo.end() pos = mo.end()
mo = gettok(s, pos) mo = gettok(s, pos)
if pos != len(s): if pos != len(s):