Skip to content

Commit da85c7d

Browse files
committed
Minor fixes
Removed code and variables that are not used anymore. Fixed 24-bit integer parsing. Moved one comment to its place.
1 parent ecd8a66 commit da85c7d

1 file changed

Lines changed: 3 additions & 19 deletions

File tree

pymysql/connections.py

Lines changed: 3 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -103,10 +103,6 @@ def _makefile(sock, mode):
103103
UNSIGNED_SHORT_COLUMN = 252
104104
UNSIGNED_INT24_COLUMN = 253
105105
UNSIGNED_INT64_COLUMN = 254
106-
UNSIGNED_CHAR_LENGTH = 1
107-
UNSIGNED_SHORT_LENGTH = 2
108-
UNSIGNED_INT24_LENGTH = 3
109-
UNSIGNED_INT64_LENGTH = 8
110106

111107
DEFAULT_CHARSET = 'latin1'
112108

@@ -217,18 +213,6 @@ def _hash_password_323(password):
217213
def pack_int24(n):
218214
return struct.pack('<I', n)[:3]
219215

220-
def unpack_uint16(n):
221-
return struct.unpack('<H', n[0:2])[0]
222-
223-
def unpack_int24(n):
224-
return struct.unpack('<I', n + b'\0')[0]
225-
226-
def unpack_int32(n):
227-
return struct.unpack('<I', n)[0]
228-
229-
def unpack_int64(n):
230-
return struct.unpack('<Q', n)[0]
231-
232216

233217
class MysqlPacket(object):
234218
"""Representation of a MySQL response packet.
@@ -311,7 +295,7 @@ def read_uint16(self):
311295
def read_uint24(self):
312296
low, high = struct.unpack_from('<HB', self._data, self._position)
313297
self._position += 3
314-
return low + high << 16
298+
return low + (high << 16)
315299

316300
def read_uint32(self):
317301
result = struct.unpack_from('<I', self._data, self._position)[0]
@@ -885,7 +869,7 @@ def _read_packet(self, packet_type=MysqlPacket):
885869
packet_header = self._read_bytes(4)
886870
if DEBUG: dump_packet(packet_header)
887871
btrl, btrh, packet_number = struct.unpack('<HBB', packet_header)
888-
bytes_to_read = btrl + btrh * 65536
872+
bytes_to_read = btrl + (btrh << 16)
889873
#TODO: check sequence id
890874
recv_data = self._read_bytes(bytes_to_read)
891875
if DEBUG: dump_packet(recv_data)
@@ -1253,9 +1237,9 @@ def _get_descriptions(self):
12531237
if field_type in TEXT_TYPES:
12541238
charset = charset_by_id(field.charsetnr)
12551239
if charset.is_binary:
1240+
# TEXTs with charset=binary means BINARY types.
12561241
encoding = None
12571242
else:
1258-
# TEXTs with charset=binary means BINARY types.
12591243
encoding = charset.encoding
12601244
else:
12611245
encoding = 'ascii'

0 commit comments

Comments
 (0)