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))
|
return "%s: %s in %s" % (exc_type.__name__, err, " > ".join(tb))
|
||||||
|
|
||||||
|
|
||||||
def formatStack():
|
def formatStack(limit=99):
|
||||||
import inspect
|
import inspect
|
||||||
back = []
|
back = []
|
||||||
|
i = 0
|
||||||
for stack in inspect.stack():
|
for stack in inspect.stack():
|
||||||
|
i += 1
|
||||||
frame, path, line, function, source, index = stack
|
frame, path, line, function, source, index = stack
|
||||||
file = os.path.split(path)[1]
|
file = os.path.split(path)[1]
|
||||||
back.append("%s line %s" % (file, line))
|
back.append("%s line %s" % (file, line))
|
||||||
|
if i > limit:
|
||||||
|
back.append("...")
|
||||||
|
break
|
||||||
return " > ".join(back)
|
return " > ".join(back)
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue