django-debug-toolbar/django-debug-toolbar — Issue #228: source code in iso-8859-1 causes DjangoUnicodeDecodeError
Author: guettli
Created: 2011-11-02 13:06:42+00:00
State: open

Some of my source files are still encoded in iso-8859-1. Unfortunately I get a UnicodeDecodeError. Here is a patch:

```patch
diff --git a/debug_toolbar/panels/sql.py b/debug_toolbar/panels/sql.py
index b27e6c0..f98437b 100644
--- a/debug_toolbar/panels/sql.py
+++ b/debug_toolbar/panels/sql.py
@@ -197,7 +197,12 @@ class SQLDebugPanel(DebugPanel):

stacktrace = []
for frame in query['stacktrace']:
- params = map(escape, frame[0].rsplit('/', 1) + list(frame[1:]))
+ frame_lines=[]
+ for frame_line in frame[0].rsplit('/', 1) + list(frame[1:]):
+ #if isinstance(frame_line, str):
+ # frame_line=unicode(frame_line, 'utf-8', errors='replace') # source could be in e.g. iso-8859-1
+ frame_lines.append(frame_line)
+ params = map(escape, frame_lines)
try:
stacktrace.append(u'{0}/{1} in {3}({2})\n {4}'.format(*params))
except IndexError:

```