Skip to content

Commit 81cdb41

Browse files
authored
Revert DEPRECATE_EOF support (PyMySQL#513)
2 parents 6f2dd7f + ced55c4 commit 81cdb41

File tree

2 files changed

+19
-18
lines changed

2 files changed

+19
-18
lines changed

pymysql/connections.py

Lines changed: 14 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -117,20 +117,18 @@ def is_ascii(data):
117117

118118
try:
119119
print("packet length:", len(data))
120-
print("method call[1]:", sys._getframe(1).f_code.co_name)
121-
print("method call[2]:", sys._getframe(2).f_code.co_name)
122-
print("method call[3]:", sys._getframe(3).f_code.co_name)
123-
print("method call[4]:", sys._getframe(4).f_code.co_name)
124-
print("method call[5]:", sys._getframe(5).f_code.co_name)
125-
print("-" * 88)
120+
for i in range(1, 6):
121+
f = sys._getframe(i)
122+
print("call[%d]: %s (line %d)" % (i, f.f_code.co_name, f.f_lineno))
123+
print("-" * 66)
126124
except ValueError:
127125
pass
128126
dump_data = [data[i:i+16] for i in range_type(0, min(len(data), 256), 16)]
129127
for d in dump_data:
130128
print(' '.join(map(lambda x: "{:02X}".format(byte2int(x)), d)) +
131129
' ' * (16 - len(d)) + ' ' * 2 +
132-
' '.join(map(lambda x: "{}".format(is_ascii(x)), d)))
133-
print("-" * 88)
130+
''.join(map(lambda x: "{}".format(is_ascii(x)), d)))
131+
print("-" * 66)
134132
print()
135133

136134

@@ -660,7 +658,7 @@ def _config(key, arg):
660658

661659
self.encoding = charset_by_name(self.charset).encoding
662660

663-
client_flag |= CLIENT.CAPABILITIES | CLIENT.MULTI_STATEMENTS
661+
client_flag |= CLIENT.CAPABILITIES
664662
if self.db:
665663
client_flag |= CLIENT.CONNECT_WITH_DB
666664
self.client_flag = client_flag
@@ -1357,12 +1355,13 @@ def _read_load_local_packet(self, first_packet):
13571355
self._read_ok_packet(ok_packet)
13581356

13591357
def _check_packet_is_eof(self, packet):
1360-
if packet.is_eof_packet():
1361-
wp = EOFPacketWrapper(packet)
1362-
elif packet.is_ok_packet():
1363-
wp = OKPacketWrapper(packet)
1364-
else:
1358+
if not packet.is_eof_packet():
13651359
return False
1360+
#TODO: Support CLIENT.DEPRECATE_EOF
1361+
# 1) Add DEPRECATE_EOF to CAPABILITIES
1362+
# 2) Mask CAPABILITIES with server_capabilities
1363+
# 3) if server_capabilities & CLIENT.DEPRECATE_EOF: use OKPacketWrapper instead of EOFPacketWrapper
1364+
wp = EOFPacketWrapper(packet)
13661365
self.warning_count = wp.warning_count
13671366
self.has_next = wp.has_next
13681367
return True
@@ -1470,7 +1469,7 @@ def _get_descriptions(self):
14701469
self.converters.append((encoding, converter))
14711470

14721471
eof_packet = self.connection._read_packet()
1473-
assert eof_packet.is_eof_packet() or eof_packet.is_ok_packet, 'Protocol error, expecting EOF'
1472+
assert eof_packet.is_eof_packet(), 'Protocol error, expecting EOF'
14741473
self.description = tuple(description)
14751474

14761475

pymysql/constants/CLIENT.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,11 @@
1919
PS_MULTI_RESULTS = 1 << 18
2020
PLUGIN_AUTH = 1 << 19
2121
PLUGIN_AUTH_LENENC_CLIENT_DATA = 1 << 21
22-
CAPABILITIES = (LONG_PASSWORD | LONG_FLAG | TRANSACTIONS |
23-
PROTOCOL_41 | SECURE_CONNECTION | PLUGIN_AUTH |
24-
PLUGIN_AUTH_LENENC_CLIENT_DATA)
22+
CAPABILITIES = (
23+
LONG_PASSWORD | LONG_FLAG | PROTOCOL_41 | TRANSACTIONS
24+
| SECURE_CONNECTION | MULTI_STATEMENTS | MULTI_RESULTS
25+
| PLUGIN_AUTH | PLUGIN_AUTH_LENENC_CLIENT_DATA)
26+
2527
# Not done yet
2628
CONNECT_ATTRS = 1 << 20
2729
HANDLE_EXPIRED_PASSWORDS = 1 << 22

0 commit comments

Comments
 (0)