New submission from Ruben Bakker <ruben.bakk...@gmail.com>: When using imaplib.IMAP4_SSL to open a Gmail mailbox, the readline method can go into a infinite loop. It happens after Gmail drops the connection, usually after some time/inactivity. The next imaplib request will cause the infinite loop inside the readline() method.
Steps to reproduce: Perform this script (use python -i to get the prompt): import imaplib HOST="imap.gmail.com" PORT=993 USERNAME="usern...@gmail.com" PASSWORD="password" server = imaplib.IMAP4_SSL(host=HOST, port=PORT) server.login(USERNAME, PASSWORD) def f(): print server.select("INBOX") print server.uid("FETCH", "1:*", "(UID FLAGS BODY.PEEK[HEADER.FIELDS (Subject)])") Call the f() function and then wait about about an hour. Call f() again and server.select() will not return but take all CPU. Add this line in IMAP4_SSL if not char: raise self.abort('socket error: EOF') complete method: def readline(self): """Read line from remote.""" line = [] while 1: char = self.sslobj.read(1) if not char: raise self.abort('socket error: EOF') line.append(char) if char == "\n": return ''.join(line) ---------- components: Library (Lib) messages: 107925 nosy: Ruben.Bakker priority: normal severity: normal status: open title: Infinite loop in imaplib.IMAP4_SSL when used with Gmail type: behavior versions: Python 2.6 _______________________________________ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue9010> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com