Limit stack size on formatting
This commit is contained in:
parent
c2d2189039
commit
b4f7e51e96
1 changed files with 6 additions and 1 deletions
|
@ -54,13 +54,18 @@ def formatException(err=None, format="text"):
|
|||
return "%s: %s in %s" % (exc_type.__name__, err, " > ".join(tb))
|
||||
|
||||
|
||||
def formatStack():
|
||||
def formatStack(limit=99):
|
||||
import inspect
|
||||
back = []
|
||||
i = 0
|
||||
for stack in inspect.stack():
|
||||
i += 1
|
||||
frame, path, line, function, source, index = stack
|
||||
file = os.path.split(path)[1]
|
||||
back.append("%s line %s" % (file, line))
|
||||
if i > limit:
|
||||
back.append("...")
|
||||
break
|
||||
return " > ".join(back)
|
||||
|
||||
|
||||
|
|
Loading…
Reference in a new issue