From 59f232d69f09d6a757b211ad80e883ad51ab82bd Mon Sep 17 00:00:00 2001 From: James Lu Date: Tue, 27 Dec 2016 18:16:15 -0800 Subject: [PATCH] clientbot: fix SASL PLAIN auth on Python 3.4 A strange bug causes "TypeError: unsupported operand type(s) for %: 'bytes' and 'tuple'" when formatting multiple args into a byte string using %b. --- protocols/clientbot.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/protocols/clientbot.py b/protocols/clientbot.py index 5642d32..d58961e 100644 --- a/protocols/clientbot.py +++ b/protocols/clientbot.py @@ -463,9 +463,10 @@ class ClientbotWrapperProtocol(Protocol): if args[0] == '+': sasl_mech = self.irc.serverdata['sasl_mechanism'].upper() if sasl_mech == 'PLAIN': - sasl_user = self.irc.serverdata['sasl_username'].encode('utf-8') - sasl_pass = self.irc.serverdata['sasl_password'].encode('utf-8') - self.sendAuthChunk(b'%b\0%b\0%b' % (sasl_user, sasl_user, sasl_pass)) + sasl_user = self.irc.serverdata['sasl_username'] + sasl_pass = self.irc.serverdata['sasl_password'] + authstring = '%s\0%s\0%s' % (sasl_user, sasl_user, sasl_pass) + self.sendAuthChunk(authstring.encode('utf-8')) elif sasl_mech == 'EXTERNAL': self.irc.send('AUTHENTICATE +')