Issue 634557: Better inspect.BlockFinder fixes bug (original) (raw)
inspect.BlockFinder didn't do a good enough job finding
the end of code blocks. This can be observed by
running:
import inspect
import tokenize
print inspect.getsource(tokenize.TokenError)
class TokenError(Exception): pass
class StopTokenizing(Exception): pass
def printtoken(type, token, (srow, scol), (erow, ecol),
line): # for testing
print "%d,%d-%d,%d:\t%s\t%s" % \
(srow, scol, erow, ecol, tok_name[type],
repr(token))
Notice how it picks up extra source code lines. The
attached patch fixes this problem. There should probably
be some additional unit tests for this, but I ran out of time
and energy.