File tree 2 files changed +15
-1
lines changed
2 files changed +15
-1
lines changed Original file line number Diff line number Diff line change 6
6
from time import time
7
7
8
8
from django .utils import six
9
- from django .utils .encoding import force_text , DjangoUnicodeDecodeError
9
+ from django .utils .encoding import DjangoUnicodeDecodeError , force_text
10
10
11
11
from debug_toolbar import settings as dt_settings
12
12
from debug_toolbar .utils import get_stack , get_template_info , tidy_stacktrace
@@ -88,6 +88,8 @@ def _quote_expr(self, element):
88
88
return "'%s'" % force_text (element ).replace ("'" , "''" )
89
89
except DjangoUnicodeDecodeError :
90
90
return repr (element )
91
+ elif isinstance (element , six .binary_type ):
92
+ return '(binary data)'
91
93
else :
92
94
return repr (element )
93
95
Original file line number Diff line number Diff line change @@ -122,6 +122,18 @@ def test_param_conversion(self):
122
122
'["2017-12-22 16:07:01"]'
123
123
))
124
124
125
+ @unittest .skipUnless (connection .vendor not in ('sqlite' , 'postgresql' ), '' )
126
+ def test_binary_param_force_text (self ):
127
+ self .assertEqual (len (self .panel ._queries ), 0 )
128
+
129
+ with connection .cursor () as cursor :
130
+ cursor .execute ("SELECT * FROM auth_user WHERE username = %s" , [b'\xff ' ])
131
+
132
+ self .assertEqual (len (self .panel ._queries ), 1 )
133
+
134
+ self .panel .process_response (self .request , self .response )
135
+ self .panel .generate_stats (self .request , self .response )
136
+
125
137
@unittest .skipUnless (connection .vendor != 'sqlite' ,
126
138
'Test invalid for SQLite' )
127
139
def test_raw_query_param_conversion (self ):
You can’t perform that action at this time.
0 commit comments