Skip to content

Commit bb005fa

Browse files
Onwaybaloo
authored andcommitted
Fix struct.pack in ReportSlave (julien-duponchelle#194)
The 'p' format character requires 'bytes' type in python3.
1 parent 6669558 commit bb005fa

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

pymysqlreplication/binlogstream.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -88,9 +88,9 @@ def encoded(self, server_id, master_id=0):
8888
# 4 replication rank
8989
# 4 master-id
9090

91-
lhostname = len(self.hostname)
92-
lusername = len(self.username)
93-
lpassword = len(self.password)
91+
lhostname = len(self.hostname.encode())
92+
lusername = len(self.username.encode())
93+
lpassword = len(self.password.encode())
9494

9595
packet_len = (1 + # command
9696
4 + # server-id
@@ -110,11 +110,11 @@ def encoded(self, server_id, master_id=0):
110110
int2byte(COM_REGISTER_SLAVE) +
111111
struct.pack('<L', server_id) +
112112
struct.pack('<%dp' % min(MAX_STRING_LEN, lhostname + 1),
113-
self.hostname) +
113+
self.hostname.encode()) +
114114
struct.pack('<%dp' % min(MAX_STRING_LEN, lusername + 1),
115-
self.username) +
115+
self.username.encode()) +
116116
struct.pack('<%dp' % min(MAX_STRING_LEN, lpassword + 1),
117-
self.password) +
117+
self.password.encode()) +
118118
struct.pack('<H', self.port) +
119119
struct.pack('<l', 0) +
120120
struct.pack('<l', master_id))

0 commit comments

Comments
 (0)