Skip to content

Commit

Permalink
Revert "stacktrace: include number of hidden frames"
Browse files Browse the repository at this point in the history
This reverts commit 5bd7513.
  • Loading branch information
matthiask committed Sep 6, 2018
1 parent de343a8 commit 8987d1d
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 14 deletions.
2 changes: 1 addition & 1 deletion debug_toolbar/panels/cache.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ def wrapped(self, *args, **kwargs):
if dt_settings.get_config()['ENABLE_STACKTRACES']:
stacktrace = tidy_stacktrace(reversed(get_stack()))
else:
stacktrace = ([], 0)
stacktrace = []

template_info = get_template_info()
cache_called.send(sender=self.__class__, time_taken=t,
Expand Down
2 changes: 1 addition & 1 deletion debug_toolbar/panels/sql/tracking.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ def _record(self, method, sql, params):
if dt_settings.get_config()['ENABLE_STACKTRACES']:
stacktrace = tidy_stacktrace(reversed(get_stack()))
else:
stacktrace = ([], 0)
stacktrace = []
_params = ''
try:
_params = json.dumps([self._decode(p) for p in params])
Expand Down
3 changes: 0 additions & 3 deletions debug_toolbar/static/debug_toolbar/css/toolbar.css
Original file line number Diff line number Diff line change
Expand Up @@ -626,9 +626,6 @@
#djDebug .djdt-stack span.djdt-code {
font-weight: normal;
}
#djDebug .djdt-stack span.djdt-hidden_count {
font-weight: normal;
}

@media print {
#djDebug {
Expand Down
13 changes: 5 additions & 8 deletions debug_toolbar/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,24 +52,24 @@ def omit_path(path):

def tidy_stacktrace(stack):
"""
Clean up stacktrace and remove entries according to HIDE_IN_STACKTRACES.
Clean up stacktrace and remove all entries that:
1. Are part of Django (except contrib apps)
2. Are part of socketserver (used by Django's dev server)
3. Are the last entry (which is part of our stacktracing code)
``stack`` should be a list of frame tuples from ``inspect.stack()``
"""
trace = []
hidden_count = 0
for frame, path, line_no, func_name, text in (f[:5] for f in stack):
if omit_path(os.path.realpath(path)):
hidden_count += 1
continue
text = (''.join(force_text(t) for t in text)).strip() if text else ''
trace.append((path, line_no, func_name, text))
return trace, hidden_count
return trace


def render_stacktrace(trace):
stacktrace = []
trace, hidden_count = trace
for frame in trace:
params = (escape(v) for v in chain(frame[0].rsplit(os.path.sep, 1), frame[1:]))
params_dict = {six.text_type(idx): v for idx, v in enumerate(params)}
Expand All @@ -83,9 +83,6 @@ def render_stacktrace(trace):
except KeyError:
# This frame doesn't have the expected format, so skip it and move on to the next one
continue
if hidden_count:
stacktrace.append('<span class="djdt-hidden_count">'
'%d hidden frames.</span>' % hidden_count)
return mark_safe('\n'.join(stacktrace))


Expand Down
2 changes: 1 addition & 1 deletion tests/panels/test_sql.py
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ def test_disable_stacktraces(self):
self.assertTrue('stacktrace' in query[1])

# ensure the stacktrace is empty
self.assertEqual(([], 0), query[1]['stacktrace'])
self.assertEqual([], query[1]['stacktrace'])

@override_settings(DEBUG=True, TEMPLATES=[{
'BACKEND': 'django.template.backends.django.DjangoTemplates',
Expand Down

0 comments on commit 8987d1d

Please sign in to comment.