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 1f6e18d

Browse filesBrowse files
authored
Add some garbage for Django 1.11 compatibility (PyMySQL#327)
Django touched private area of this library. Removing unused variables broke Django. While Django 2.0 fixed it, Django 1.11 doesn't fix it because it is in security-only fix mode. So add unused variables for Django 1.11 compatibility. They will be removed in next minor release. Fix PyMySQL#303, PyMySQL#306
1 parent c29d166 commit 1f6e18d
Copy full SHA for 1f6e18d

File tree

Expand file treeCollapse file tree

2 files changed

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

2 files changed

+21
-2
lines changed

‎MySQLdb/connections.py

Copy file name to clipboardExpand all lines: MySQLdb/connections.py
+12-2Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -166,6 +166,13 @@ class object, used to create cursors (keyword only)
166166
self.encoders = dict([ (k, v) for k, v in conv.items()
167167
if type(k) is not int ])
168168

169+
# XXX THIS IS GARBAGE: While this is just a garbage and undocumented,
170+
# Django 1.11 depends on it. And they don't fix it because
171+
# they are in security-only fix mode.
172+
# So keep this garbage for now. This will be removed in 1.5.
173+
# See PyMySQL/mysqlclient-python#306
174+
self.encoders[bytes] = bytes
175+
169176
self._server_version = tuple([ numeric_part(n) for n in self.get_server_info().split('.')[:2] ])
170177

171178
self.encoding = 'ascii' # overridden in set_character_set()
@@ -238,8 +245,11 @@ def literal(self, o):
238245
s = self.string_literal(o.encode(self.encoding))
239246
elif isinstance(o, bytearray):
240247
s = self._bytes_literal(o)
241-
elif not PY2 and isinstance(o, bytes):
242-
s = self._bytes_literal(o)
248+
elif isinstance(o, bytes):
249+
if PY2:
250+
s = self.string_literal(o)
251+
else:
252+
s = self._bytes_literal(o)
243253
elif isinstance(o, (tuple, list)):
244254
s = self._tuple_literal(o)
245255
else:

‎MySQLdb/cursors.py

Copy file name to clipboardExpand all lines: MySQLdb/cursors.py
+9Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,14 @@ def __init__(self, connection):
6363
self.rowcount = -1
6464
self.arraysize = 1
6565
self._executed = None
66+
67+
# XXX THIS IS GARBAGE: While this is totally garbage and private,
68+
# Django 1.11 depends on it. And they don't fix it because
69+
# they are in security-only fix mode.
70+
# So keep this garbage for now. This will be removed in 1.5.
71+
# See PyMySQL/mysqlclient-python#303
72+
self._last_executed = None
73+
6674
self.lastrowid = None
6775
self.messages = []
6876
self._result = None
@@ -305,6 +313,7 @@ def _query(self, q):
305313
self._do_get_result(db)
306314
self._post_get_result()
307315
self._executed = q
316+
self._last_executed = q # XXX THIS IS GARBAGE: See above.
308317
return self.rowcount
309318

310319
def _fetch_row(self, size=1):

0 commit comments

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