Skip to content

Commit fb412f7

Browse files
committed
Merge pull request #342 from davidwtbuxton/master
Python 2.5 compatibility, fixes #261
2 parents 0844c8b + 3013b5a commit fb412f7

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
lines changed

debug_toolbar/utils/__init__.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,9 +56,15 @@ def render_stacktrace(trace):
5656
stacktrace = []
5757
for frame in trace:
5858
params = map(escape, frame[0].rsplit(os.path.sep, 1) + list(frame[1:]))
59+
params_dict = dict((unicode(idx), v) for idx, v in enumerate(params))
5960
try:
60-
stacktrace.append(u'<span class="path">{0}/</span><span class="file">{1}</span> in <span class="func">{3}</span>(<span class="lineno">{2}</span>)\n <span class="code">{4}</span>'.format(*params))
61-
except IndexError:
61+
stacktrace.append(u'<span class="path">%(0)s/</span>'
62+
u'<span class="file">%(1)s</span>'
63+
u' in <span class="func">%(3)s</span>'
64+
u'(<span class="lineno">%(2)s</span>)\n'
65+
u' <span class="code">%(4)s</span>'
66+
% params_dict)
67+
except KeyError:
6268
# This frame doesn't have the expected format, so skip it and move on to the next one
6369
continue
6470
return mark_safe('\n'.join(stacktrace))

tests/tests.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
from __future__ import with_statement
12
import thread
23

34
from django.conf import settings

0 commit comments

Comments
 (0)