@@ -103,10 +103,6 @@ def _makefile(sock, mode):
103103UNSIGNED_SHORT_COLUMN = 252
104104UNSIGNED_INT24_COLUMN = 253
105105UNSIGNED_INT64_COLUMN = 254
106- UNSIGNED_CHAR_LENGTH = 1
107- UNSIGNED_SHORT_LENGTH = 2
108- UNSIGNED_INT24_LENGTH = 3
109- UNSIGNED_INT64_LENGTH = 8
110106
111107DEFAULT_CHARSET = 'latin1'
112108
@@ -217,18 +213,6 @@ def _hash_password_323(password):
217213def 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
233217class 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