Skip to content

Add some garbage for Django 1.11 compatibility #327

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Feb 7, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 12 additions & 2 deletions MySQLdb/connections.py
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,13 @@ class object, used to create cursors (keyword only)
self.encoders = dict([ (k, v) for k, v in conv.items()
if type(k) is not int ])

# XXX THIS IS GARBAGE: While this is just a garbage and undocumented,
# Django 1.11 depends on it. And they don't fix it because
# they are in security-only fix mode.
# So keep this garbage for now. This will be removed in 1.5.
# See PyMySQL/mysqlclient-python#306
self.encoders[bytes] = bytes

self._server_version = tuple([ numeric_part(n) for n in self.get_server_info().split('.')[:2] ])

self.encoding = 'ascii' # overridden in set_character_set()
Expand Down Expand Up @@ -238,8 +245,11 @@ def literal(self, o):
s = self.string_literal(o.encode(self.encoding))
elif isinstance(o, bytearray):
s = self._bytes_literal(o)
elif not PY2 and isinstance(o, bytes):
s = self._bytes_literal(o)
elif isinstance(o, bytes):
if PY2:
s = self.string_literal(o)
else:
s = self._bytes_literal(o)
elif isinstance(o, (tuple, list)):
s = self._tuple_literal(o)
else:
Expand Down
9 changes: 9 additions & 0 deletions MySQLdb/cursors.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,14 @@ def __init__(self, connection):
self.rowcount = -1
self.arraysize = 1
self._executed = None

# XXX THIS IS GARBAGE: While this is totally garbage and private,
# Django 1.11 depends on it. And they don't fix it because
# they are in security-only fix mode.
# So keep this garbage for now. This will be removed in 1.5.
# See PyMySQL/mysqlclient-python#303
self._last_executed = None

self.lastrowid = None
self.messages = []
self._result = None
Expand Down Expand Up @@ -300,6 +308,7 @@ def _query(self, q):
self._do_get_result(db)
self._post_get_result()
self._executed = q
self._last_executed = q # XXX THIS IS GARBAGE: See above.
return self.rowcount

def _fetch_row(self, size=1):
Expand Down