Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 8ab1e6f

Browse filesBrowse files
committed
Use _binary prefix for bytes/bytearray parameters (Python 3)
1 parent fb842fb commit 8ab1e6f
Copy full SHA for 8ab1e6f

File tree

Expand file treeCollapse file tree

1 file changed

+7
-2
lines changed
Filter options
Expand file treeCollapse file tree

1 file changed

+7
-2
lines changed

‎MySQLdb/connections.py

Copy file name to clipboardExpand all lines: MySQLdb/connections.py
+7-2Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -198,8 +198,12 @@ class object, used to create cursors (keyword only)
198198
db = proxy(self)
199199
def _get_string_literal():
200200
# Note: string_literal() is called for bytes object on Python 3.
201-
def string_literal(obj, dummy=None):
202-
return db.string_literal(obj)
201+
if PY2:
202+
def string_literal(obj, dummy=None):
203+
return db.string_literal(obj)
204+
else:
205+
def string_literal(obj, dummy=None):
206+
return b'_binary' + db.string_literal(obj)
203207
return string_literal
204208

205209
def _get_unicode_literal():
@@ -235,6 +239,7 @@ def string_decoder(s):
235239
self.converter[FIELD_TYPE.BLOB].append((None, string_decoder))
236240

237241
self.encoders[bytes] = string_literal
242+
self.encoders[bytearray] = string_literal
238243
self.encoders[unicode] = unicode_literal
239244
self._transactional = self.server_capabilities & CLIENT.TRANSACTIONS
240245
if self._transactional:

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.