From 2df5b716b55ab2f6c0f8186aa961ca5a6eb7fa40 Mon Sep 17 00:00:00 2001 From: Eygene Ryabinkin Date: Mon, 2 Sep 2013 09:08:50 +0400 Subject: [PATCH] Updated bundled imaplib2 to 2.35: - Fix for Gmail sending a BYE response after reading >100 messages in a session. - Includes fix for GitHub#15: patch was accepted upstream. Signed-off-by: Eygene Ryabinkin --- Changelog.rst | 4 ++++ offlineimap/imaplib2.py | 44 +++++++++++++++++++++++++++++------------ 2 files changed, 35 insertions(+), 13 deletions(-) diff --git a/Changelog.rst b/Changelog.rst index f4e18ed..aa40d59 100644 --- a/Changelog.rst +++ b/Changelog.rst @@ -29,6 +29,10 @@ WIP (add new stuff for the next release) * [regression] pass folder names to the foldersort function, revert the documented behaviour * Fix handling of zero-sized IMAP data items (GitHub#15). +* Updated bundled imaplib2 to 2.35: + - fix for Gmail sending a BYE response after reading >100 messages + in a session; + - includes fix for GitHub#15: patch was accepted upstream. OfflineIMAP v6.5.5-rc1 (2012-09-05) =================================== diff --git a/offlineimap/imaplib2.py b/offlineimap/imaplib2.py index 8a78864..0958166 100644 --- a/offlineimap/imaplib2.py +++ b/offlineimap/imaplib2.py @@ -17,9 +17,9 @@ Public functions: Internaldate2Time __all__ = ("IMAP4", "IMAP4_SSL", "IMAP4_stream", "Internaldate2Time", "ParseFlags", "Time2Internaldate") -__version__ = "2.33" +__version__ = "2.35" __release__ = "2" -__revision__ = "33" +__revision__ = "35" __credits__ = """ Authentication code contributed by Donn Cave June 1998. String method conversion by ESR, February 2001. @@ -40,7 +40,9 @@ Time2Internaldate() patch to match RFC2060 specification of English month names starttls() bug fixed with the help of Sebastian Spaeth April 2011. Threads now set the "daemon" flag (suggested by offlineimap-project) April 2011. Single quoting introduced with the help of Vladimir Marek August 2011. -Support for specifying SSL version by Ryan Kavanagh July 2013.""" +Support for specifying SSL version by Ryan Kavanagh July 2013. +Fix for gmail "read 0" error provided by Jim Greenleaf August 2013. +Fix for offlineimap "indexerror: string index out of range" bug provided by Eygene Ryabinkin August 2013.""" __author__ = "Piers Lauder " __URL__ = "http://imaplib2.sourceforge.net" __license__ = "Python License" @@ -1331,7 +1333,7 @@ class IMAP4(object): self.ouq.put(rqb) return rqb - # Must setup continuation expectancy *before* ouq.put + # Must setup continuation expectancy *before* ouq.put crqb = self._request_push(tag='continuation') self.ouq.put(rqb) @@ -1373,8 +1375,8 @@ class IMAP4(object): # Called for non-callback commands - typ, dat = rqb.get_response('command: %s => %%s' % rqb.name) self._check_bye() + typ, dat = rqb.get_response('command: %s => %%s' % rqb.name) if typ == 'BAD': if __debug__: self._print_log() raise self.error('%s command error: %s %s. Data: %.100s' % (rqb.name, typ, dat, rqb.data)) @@ -1903,11 +1905,12 @@ class IMAP4(object): if __debug__: def _init_debug(self, debug=None, debug_file=None, debug_buf_lvl=None): + self.debug_lock = threading.Lock() + self.debug = self._choose_nonull_or_dflt(0, debug, Debug) self.debug_file = self._choose_nonull_or_dflt(sys.stderr, debug_file) self.debug_buf_lvl = self._choose_nonull_or_dflt(DFLT_DEBUG_BUF_LVL, debug_buf_lvl) - self.debug_lock = threading.Lock() self._cmd_log_len = 20 self._cmd_log_idx = 0 self._cmd_log = {} # Last `_cmd_log_len' interactions @@ -2111,6 +2114,7 @@ class IMAP4_stream(IMAP4): from subprocess import Popen, PIPE + if __debug__: self._log(0, 'opening stream from command "%s"' % self.command) self._P = Popen(self.command, shell=True, stdin=PIPE, stdout=PIPE, close_fds=True) self.writefile, self.readfile = self._P.stdin, self._P.stdout self.read_fd = self.readfile.fileno() @@ -2313,19 +2317,22 @@ if __name__ == '__main__': # To test: invoke either as 'python imaplib2.py [IMAP4_server_hostname]', # or as 'python imaplib2.py -s "rsh IMAP4_server_hostname exec /etc/rimapd"' # or as 'python imaplib2.py -l "keyfile[:certfile]" [IMAP4_SSL_server_hostname]' + # Option "-i" tests that IDLE is interruptible import getopt, getpass try: - optlist, args = getopt.getopt(sys.argv[1:], 'd:l:s:p:') + optlist, args = getopt.getopt(sys.argv[1:], 'd:il:s:p:') except getopt.error, val: optlist, args = (), () - debug, debug_buf_lvl, port, stream_command, keyfile, certfile = (None,)*6 + debug, debug_buf_lvl, port, stream_command, keyfile, certfile, idle_intr = (None,)*7 for opt,val in optlist: if opt == '-d': debug = int(val) debug_buf_lvl = debug - 1 + elif opt == '-i': + idle_intr = 1 elif opt == '-l': try: keyfile,certfile = val.split(':') @@ -2446,7 +2453,7 @@ if __name__ == '__main__': run('id', ()) run('id', ('("name", "imaplib2")',)) run('id', ("version", __version__, "os", os.uname()[0])) - + for cmd,args in test_seq2: if (cmd,args) != ('uid', ('SEARCH', 'SUBJECT', 'IMAP4 test')): run(cmd, args) @@ -2476,6 +2483,16 @@ if __name__ == '__main__': M._mesg('fetch %s => %s' % (num, `dat`)) run('uid', ('STORE', num, 'FLAGS', '(\Deleted)')) run('expunge', ()) + if idle_intr: + M._mesg('HIT CTRL-C to interrupt IDLE') + try: + run('idle', (99,), cb=False) # Synchronous, to test interruption of 'idle' by INTR + except KeyboardInterrupt: + M._mesg('Thanks!') + M._mesg('') + raise + elif idle_intr: + M._mesg('chosen server does not report IDLE capability') run('logout', (), cb=False) @@ -2489,12 +2506,13 @@ if __name__ == '__main__': print 'All tests OK.' except: - print 'Tests failed.' + if not idle_intr or not 'IDLE' in M.capabilities: + print 'Tests failed.' - if not debug: - print ''' + if not debug: + print ''' If you would like to see debugging output, try: %s -d5 ''' % sys.argv[0] - raise + raise