Skip to content

Commit 3bf2b74

Browse files
DanielDaniel
Daniel
authored and
Daniel
committed
Fix unicode error when trying to escape binary data
1 parent a2ed32c commit 3bf2b74

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

debug_toolbar/panels/sql/tracking.py

+5-2
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
from time import time
77

88
from django.utils import six
9-
from django.utils.encoding import force_text
9+
from django.utils.encoding import force_text, DjangoUnicodeDecodeError
1010

1111
from debug_toolbar import settings as dt_settings
1212
from debug_toolbar.utils import get_stack, get_template_info, tidy_stacktrace
@@ -84,7 +84,10 @@ def __init__(self, cursor, db, logger):
8484

8585
def _quote_expr(self, element):
8686
if isinstance(element, six.string_types):
87-
return "'%s'" % force_text(element).replace("'", "''")
87+
try:
88+
return "'%s'" % force_text(element).replace("'", "''")
89+
except DjangoUnicodeDecodeError:
90+
return repr(element)
8891
else:
8992
return repr(element)
9093

0 commit comments

Comments
 (0)