Skip to content
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
29 changes: 14 additions & 15 deletions pymysql/connections.py
Original file line number Diff line number Diff line change
Expand Up @@ -117,20 +117,18 @@ def is_ascii(data):

try:
print("packet length:", len(data))
print("method call[1]:", sys._getframe(1).f_code.co_name)
print("method call[2]:", sys._getframe(2).f_code.co_name)
print("method call[3]:", sys._getframe(3).f_code.co_name)
print("method call[4]:", sys._getframe(4).f_code.co_name)
print("method call[5]:", sys._getframe(5).f_code.co_name)
print("-" * 88)
for i in range(1, 6):
f = sys._getframe(i)
print("call[%d]: %s (line %d)" % (i, f.f_code.co_name, f.f_lineno))
print("-" * 66)
except ValueError:
pass
dump_data = [data[i:i+16] for i in range_type(0, min(len(data), 256), 16)]
for d in dump_data:
print(' '.join(map(lambda x: "{:02X}".format(byte2int(x)), d)) +
' ' * (16 - len(d)) + ' ' * 2 +
' '.join(map(lambda x: "{}".format(is_ascii(x)), d)))
print("-" * 88)
''.join(map(lambda x: "{}".format(is_ascii(x)), d)))
print("-" * 66)
print()


Expand Down Expand Up @@ -660,7 +658,7 @@ def _config(key, arg):

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

client_flag |= CLIENT.CAPABILITIES | CLIENT.MULTI_STATEMENTS
client_flag |= CLIENT.CAPABILITIES
if self.db:
client_flag |= CLIENT.CONNECT_WITH_DB
self.client_flag = client_flag
Expand Down Expand Up @@ -1357,12 +1355,13 @@ def _read_load_local_packet(self, first_packet):
self._read_ok_packet(ok_packet)

def _check_packet_is_eof(self, packet):
if packet.is_eof_packet():
wp = EOFPacketWrapper(packet)
elif packet.is_ok_packet():
wp = OKPacketWrapper(packet)
else:
if not packet.is_eof_packet():
return False
#TODO: Support CLIENT.DEPRECATE_EOF
# 1) Add DEPRECATE_EOF to CAPABILITIES
# 2) Mask CAPABILITIES with server_capabilities
# 3) if server_capabilities & CLIENT.DEPRECATE_EOF: use OKPacketWrapper instead of EOFPacketWrapper
wp = EOFPacketWrapper(packet)
self.warning_count = wp.warning_count
self.has_next = wp.has_next
return True
Expand Down Expand Up @@ -1470,7 +1469,7 @@ def _get_descriptions(self):
self.converters.append((encoding, converter))

eof_packet = self.connection._read_packet()
assert eof_packet.is_eof_packet() or eof_packet.is_ok_packet, 'Protocol error, expecting EOF'
assert eof_packet.is_eof_packet(), 'Protocol error, expecting EOF'
self.description = tuple(description)


Expand Down
8 changes: 5 additions & 3 deletions pymysql/constants/CLIENT.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,11 @@
PS_MULTI_RESULTS = 1 << 18
PLUGIN_AUTH = 1 << 19
PLUGIN_AUTH_LENENC_CLIENT_DATA = 1 << 21
CAPABILITIES = (LONG_PASSWORD | LONG_FLAG | TRANSACTIONS |
PROTOCOL_41 | SECURE_CONNECTION | PLUGIN_AUTH |
PLUGIN_AUTH_LENENC_CLIENT_DATA)
CAPABILITIES = (
LONG_PASSWORD | LONG_FLAG | PROTOCOL_41 | TRANSACTIONS
| SECURE_CONNECTION | MULTI_STATEMENTS | MULTI_RESULTS
| PLUGIN_AUTH | PLUGIN_AUTH_LENENC_CLIENT_DATA)

# Not done yet
CONNECT_ATTRS = 1 << 20
HANDLE_EXPIRED_PASSWORDS = 1 << 22
Expand Down