From 0db18d875b887c73140695c10b645a5d8b1fc7a0 Mon Sep 17 00:00:00 2001 From: Menno Smits Date: Thu, 4 Apr 2013 22:25:57 +0100 Subject: [PATCH] Handle new exception in idle_check Under Python 3 IMAP4.abort might get raised by _get_line() when the socket is in non-blocking mode. --- imapclient/imapclient.py | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/imapclient/imapclient.py b/imapclient/imapclient.py index 81835f4..4bcc459 100644 --- a/imapclient/imapclient.py +++ b/imapclient/imapclient.py @@ -422,8 +422,8 @@ class IMAPClient(object): (1, 'EXISTS'), (1, 'FETCH', ('FLAGS', ('\\NotJunk',)))] """ - # in py2, imaplib has sslobj (for ssl connexions), and sock for non-sll - # in the py3 version it's just sock + # In py2, imaplib has sslobj (for SSL connections), and sock for non-SSL. + # In the py3 version it's just sock. sock = getattr(self._imap, 'sslobj', self._imap.sock) # make the socket non-blocking so the timeout can be @@ -438,6 +438,14 @@ class IMAPClient(object): line = from_bytes(self._imap._get_line(), self.folder_encode) except (socket.timeout, socket.error): break + except IMAPClient.AbortError: + # An imaplib.IMAP4.abort with "EOF" is raised + # under Python 3 + err = sys.exc_info()[1] + if 'EOF' in err.args[0]: + break + else: + raise else: resps.append(_parse_untagged_response(line)) return resps -- 2.43.0