Commit c272df40 by Jonatan Heyman

Added a try except clause around inspect.stack() call, since python's inspect…

Added a try except clause around inspect.stack() call, since python's inspect sometimes fail when jinja2 templates are on the stack
parent 969e806b
...@@ -31,7 +31,14 @@ removes = [] ...@@ -31,7 +31,14 @@ removes = []
WANT_STACK_TRACE = getattr(settings, 'DEBUG_TOOLBAR_MONGO_STACKTRACES', True) WANT_STACK_TRACE = getattr(settings, 'DEBUG_TOOLBAR_MONGO_STACKTRACES', True)
def _get_stacktrace(): def _get_stacktrace():
if WANT_STACK_TRACE: 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 []
return _tidy_stacktrace(reversed(stack))
else: else:
return [] 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