changeset: 97157:0879f2c53289 parent: 97154:f05fc1a16e53 parent: 97156:b6f04b9d8c12 user: Robert Collins date: Fri Jul 31 09:02:09 2015 +1200 files: Misc/ACKS Misc/NEWS description: Issue #23779: imaplib raises TypeError if authenticator tries to abort. Patch from Craig Holmquist. diff -r f05fc1a16e53 -r 0879f2c53289 Lib/imaplib.py --- a/Lib/imaplib.py Thu Jul 30 16:44:55 2015 -0400 +++ b/Lib/imaplib.py Fri Jul 31 09:02:09 2015 +1200 @@ -1353,7 +1353,7 @@ def process(self, data): ret = self.mech(self.decode(data)) if ret is None: - return '*' # Abort conversation + return b'*' # Abort conversation return self.encode(ret) def encode(self, inp): diff -r f05fc1a16e53 -r 0879f2c53289 Lib/test/test_imaplib.py --- a/Lib/test/test_imaplib.py Thu Jul 30 16:44:55 2015 -0400 +++ b/Lib/test/test_imaplib.py Fri Jul 31 09:02:09 2015 +1200 @@ -419,6 +419,26 @@ ret, data = client.login_cram_md5("tim", b"tanstaaftanstaaf") self.assertEqual(ret, "OK") + + @reap_threads + def test_aborted_authentication(self): + + class MyServer(SimpleIMAPHandler): + + def cmd_AUTHENTICATE(self, tag, args): + self._send_textline('+') + self.response = yield + + if self.response == b'*\r\n': + self._send_tagged(tag, 'NO', '[AUTHENTICATIONFAILED] aborted') + else: + self._send_tagged(tag, 'OK', 'MYAUTH successful') + + with self.reaped_pair(MyServer) as (server, client): + with self.assertRaises(imaplib.IMAP4.error): + code, data = client.authenticate('MYAUTH', lambda x: None) + + def test_linetoolong(self): class TooLongHandler(SimpleIMAPHandler): def handle(self): diff -r f05fc1a16e53 -r 0879f2c53289 Misc/ACKS --- a/Misc/ACKS Thu Jul 30 16:44:55 2015 -0400 +++ b/Misc/ACKS Fri Jul 31 09:02:09 2015 +1200 @@ -603,6 +603,7 @@ Shane Holloway Rune Holm Thomas Holmes +Craig Holmquist Philip Homburg Naofumi Honda Jeffrey Honig diff -r f05fc1a16e53 -r 0879f2c53289 Misc/NEWS --- a/Misc/NEWS Thu Jul 30 16:44:55 2015 -0400 +++ b/Misc/NEWS Fri Jul 31 09:02:09 2015 +1200 @@ -13,6 +13,9 @@ Library ------- +- Issue #23779: imaplib raises TypeError if authenticator tries to abort. + Patch from Craig Holmquist. + - Issue #24360: Improve __repr__ of argparse.Namespace() for invalid identifiers. Patch by Matthias Bussonnier.