[py-svn] r8307 - py/dist/py/code
hpk at codespeak.net
hpk at codespeak.net
Sun Jan 16 17:21:09 CET 2005
Author: hpk
Date: Sun Jan 16 17:21:09 2005
New Revision: 8307
Modified:
py/dist/py/code/traceback.py
Log:
hack a bit to get better tracebackentry.getsource()
heuristics ...
Modified: py/dist/py/code/traceback.py
==============================================================================
--- py/dist/py/code/traceback.py (original)
+++ py/dist/py/code/traceback.py Sun Jan 16 17:21:09 2005
@@ -39,6 +39,14 @@
source = self.frame.code.fullsource
start, end = self.frame.code.firstlineno, self.lineno
_, end = source.getstatementrange(end)
+ # heuristic to stop displaying source on e.g.
+ # if something: # assume this causes a NameError
+ # # _this_ lines and the one
+ # below we don't want from entry.getsource()
+ for i in range(self.lineno, end):
+ if source[i].rstrip().endswith(':'):
+ end = i + 1
+ break
return source[start:end]
def __str__(self):
More information about the pytest-commit
mailing list