hmarr/django-debug-toolbar-mongo — pull request #9 by heyman (2012-02-16 10:00:52+00:00)
Title: Workaround for inspect.stack() failing when jinja2 templates are on the stack

When jinja2 templates are on the stack, inspect.stack() often fails with IndexError (because the generated python code usually have more lines than the template file. Here's the issue in the jinja2 repo: https://github.com/mitsuhiko/jinja2/issues/38

This is a work around that explicitly checks for this exception, and replaces the stack trace with a message saying that the stack could not be retrieved.

Preferably, this should of course be fixed in jinja2, but the issue has been open for a long time, and since using jinja2 with Django is a common use case, I think including a workaround in django-debug-toolbar-mongo is justified.