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 490080a

Browse filesBrowse files
committed
Revert "Use _binary prefix for bytes/bytearray parameters"
1 parent 387c350 commit 490080a
Copy full SHA for 490080a

File tree

Expand file treeCollapse file tree

2 files changed

+4
-16
lines changed
Filter options
Expand file treeCollapse file tree

2 files changed

+4
-16
lines changed

‎MySQLdb/__init__.py

Copy file name to clipboardExpand all lines: MySQLdb/__init__.py
+2-7Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@
2727
paramstyle = "format"
2828

2929
from _mysql import *
30-
from MySQLdb.compat import PY2
3130
from MySQLdb.constants import FIELD_TYPE
3231
from MySQLdb.times import Date, Time, Timestamp, \
3332
DateFromTicks, TimeFromTicks, TimestampFromTicks
@@ -73,12 +72,8 @@ def test_DBAPISet_set_equality_membership():
7372
def test_DBAPISet_set_inequality_membership():
7473
assert FIELD_TYPE.DATE != STRING
7574

76-
if PY2:
77-
def Binary(x):
78-
return bytearray(x)
79-
else:
80-
def Binary(x):
81-
return bytes(x)
75+
def Binary(x):
76+
return bytes(x)
8277

8378
def Connect(*args, **kwargs):
8479
"""Factory function for connections.Connection."""

‎MySQLdb/connections.py

Copy file name to clipboardExpand all lines: MySQLdb/connections.py
+2-9Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,7 @@ class object, used to create cursors (keyword only)
197197

198198
db = proxy(self)
199199
def _get_string_literal():
200-
# Note: string_literal() is called for bytes object on Python 3 (via bytes_literal)
200+
# Note: string_literal() is called for bytes object on Python 3.
201201
def string_literal(obj, dummy=None):
202202
return db.string_literal(obj)
203203
return string_literal
@@ -213,19 +213,13 @@ def unicode_literal(u, dummy=None):
213213
return db.literal(str(u).encode(unicode_literal.charset))
214214
return unicode_literal
215215

216-
def _get_bytes_literal():
217-
def bytes_literal(obj, dummy=None):
218-
return b'_binary' + db.string_literal(obj)
219-
return bytes_literal
220-
221216
def _get_string_decoder():
222217
def string_decoder(s):
223218
return s.decode(string_decoder.charset)
224219
return string_decoder
225220

226221
string_literal = _get_string_literal()
227222
self.unicode_literal = unicode_literal = _get_unicode_literal()
228-
bytes_literal = _get_bytes_literal()
229223
self.string_decoder = string_decoder = _get_string_decoder()
230224
if not charset:
231225
charset = self.character_set_name()
@@ -240,8 +234,7 @@ def string_decoder(s):
240234
self.converter[FIELD_TYPE.VARCHAR].append((None, string_decoder))
241235
self.converter[FIELD_TYPE.BLOB].append((None, string_decoder))
242236

243-
self.encoders[bytes] = string_literal if PY2 else bytes_literal
244-
self.encoders[bytearray] = bytes_literal
237+
self.encoders[bytes] = string_literal
245238
self.encoders[unicode] = unicode_literal
246239
self._transactional = self.server_capabilities & CLIENT.TRANSACTIONS
247240
if self._transactional:

0 commit comments

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