Commit b7a96405 by Harry Marr

Merge pull request #9 from heyman/stack-workaround

Workaround for inspect.stack() failing when jinja2 templates are on the stack
parents 711aa819 8879c334
......@@ -31,7 +31,20 @@ removes = []
WANT_STACK_TRACE = getattr(settings, 'DEBUG_TOOLBAR_MONGO_STACKTRACES', True)
def _get_stacktrace():
if WANT_STACK_TRACE:
return _tidy_stacktrace(reversed(inspect.stack()))
try:
stack = inspect.stack()
except IndexError:
# this is a work around because python's inspect.stack() sometimes fail
# when jinja templates are on the stack
return [(
"",
0,
"Error retrieving stack",
"Could not retrieve stack. IndexError exception occured in inspect.stack(). "
"This error might occur when jinja2 templates is on the stack.",
)]
return _tidy_stacktrace(reversed(stack))
else:
return []
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment