Skip to content

Commit

Permalink
Fix unicode error when trying to escape binary data
Browse files Browse the repository at this point in the history
  • Loading branch information
Daniel authored and Daniel committed Oct 18, 2018
1 parent a2ed32c commit 3bf2b74
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions debug_toolbar/panels/sql/tracking.py
Expand Up @@ -6,7 +6,7 @@
from time import time

from django.utils import six
from django.utils.encoding import force_text
from django.utils.encoding import force_text, DjangoUnicodeDecodeError

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

def _quote_expr(self, element):
if isinstance(element, six.string_types):
return "'%s'" % force_text(element).replace("'", "''")
try:
return "'%s'" % force_text(element).replace("'", "''")
except DjangoUnicodeDecodeError:
return repr(element)
else:
return repr(element)

Expand Down

0 comments on commit 3bf2b74

Please sign in to comment.