From: Menno Smits Date: Thu, 4 Apr 2013 21:25:57 +0000 (+0100) Subject: Handle new exception in idle_check X-Git-Tag: 0.10~2^2~21^2~13 X-Git-Url: http://git.khamidou.com/?a=commitdiff_plain;h=0db18d875b887c73140695c10b645a5d8b1fc7a0;p=imapclient.git 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. --- 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