New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Better inspect.BlockFinder fixes bug #37431
Comments
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. |
Logged In: YES Does this fix bug bpo-595018? There are a few other inspect |
Logged In: YES Yes, this does fix bug bpo-595018. I'll look at the other inspect |
Logged In: YES I spent a little time testing this one and checked to make Marking as accepted and applying as Lib/inspect 1.41. |
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
bugs.python.org fields:
The text was updated successfully, but these errors were encountered: