diff options
| -rw-r--r-- | debug_toolbar/utils/__init__.py | 6 | ||||
| -rw-r--r-- | tests/tests.py | 12 |
2 files changed, 14 insertions, 4 deletions
diff --git a/debug_toolbar/utils/__init__.py b/debug_toolbar/utils/__init__.py index 297c901..75f3024 100644 --- a/debug_toolbar/utils/__init__.py +++ b/debug_toolbar/utils/__init__.py @@ -7,6 +7,7 @@ import sys from django.conf import settings from django.views.debug import linebreak_iter +from django.utils.encoding import force_text from django.utils.html import escape from django.utils.safestring import mark_safe from django.utils import six @@ -39,10 +40,7 @@ def tidy_stacktrace(stack): continue if socketserver_path in s_path: continue - if not text: - text = '' - else: - text = (''.join(text)).strip() + text = (''.join(force_text(t) for t in text)).strip() if text else '' trace.append((path, line_no, func_name, text)) return trace diff --git a/tests/tests.py b/tests/tests.py index 6883428..6e0cd9b 100644 --- a/tests/tests.py +++ b/tests/tests.py @@ -213,6 +213,18 @@ class SQLPanelTestCase(BaseTestCase): # ensure the stacktrace is populated self.assertTrue(len(query[1]['stacktrace']) > 0) + def test_non_ascii_query(self): + panel = self.toolbar.get_panel(SQLDebugPanel) + self.assertEqual(len(panel._queries), 0) + + # non-ASCII query + list(User.objects.extra(where=["username = 'café'"])) + self.assertEqual(len(panel._queries), 1) + + # non-ASCII parameters + list(User.objects.filter(username='café')) + self.assertEqual(len(panel._queries), 2) + @unittest.skipUnless(connection.vendor=='postgresql', 'Test valid only on PostgreSQL') def test_erroneous_query(self): |
