def _get_stacktrace():
    if WANT_STACK_TRACE:
        try:
            stack = inspect.stack()
        except __HOLE__:
            # 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 []


# Wrap Cursor._refresh for getting queries
dataset/ETHPy150Open hmarr/django-debug-toolbar-mongo/debug_toolbar_mongo/operation_tracker.py/_get_stacktrace