From af464c1b567af8e0150034634cfba8ac541fe94d Mon Sep 17 00:00:00 2001 From: Eygene Ryabinkin Date: Fri, 10 Oct 2014 16:23:07 +0400 Subject: [PATCH 1/2] Update imaplib2 to 2.37 The only fix is - add missing idle_lock in _handler(). Signed-off-by: Eygene Ryabinkin --- Changelog.rst | 3 +++ offlineimap/imaplib2.py | 29 +++++++++++++++++------------ 2 files changed, 20 insertions(+), 12 deletions(-) diff --git a/Changelog.rst b/Changelog.rst index 66f5c05..cdd871f 100644 --- a/Changelog.rst +++ b/Changelog.rst @@ -8,6 +8,9 @@ ChangeLog OfflineIMAP v6.5.6.1 (YYYY-MM-DD) ================================= +* Updated bundled imaplib2 to 2.37: + - add missing idle_lock in _handler() + * Added default CA bundle location for OpenBSD (GitHub pull #120) and DragonFlyBSD. diff --git a/offlineimap/imaplib2.py b/offlineimap/imaplib2.py index 14a802b..8921c9d 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.36" +__version__ = "2.37" __release__ = "2" -__revision__ = "36" +__revision__ = "37" __credits__ = """ Authentication code contributed by Donn Cave June 1998. String method conversion by ESR, February 2001. @@ -42,7 +42,8 @@ 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. 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.""" +Fix for offlineimap "indexerror: string index out of range" bug provided by Eygene Ryabinkin August 2013. +Fix for missing idle_lock in _handler() provided by Franklin Brook August 2014""" __author__ = "Piers Lauder " __URL__ = "http://imaplib2.sourceforge.net" __license__ = "Python License" @@ -1663,16 +1664,20 @@ class IMAP4(object): typ, val = self.abort, 'connection terminated' while not self.Terminate: + + self.idle_lock.acquire() + if self.idle_timeout is not None: + timeout = self.idle_timeout - time.time() + if timeout <= 0: + timeout = 1 + if __debug__: + if self.idle_rqb is not None: + self._log(5, 'server IDLING, timeout=%.2f' % timeout) + else: + timeout = resp_timeout + self.idle_lock.release() + try: - if self.idle_timeout is not None: - timeout = self.idle_timeout - time.time() - if timeout <= 0: - timeout = 1 - if __debug__: - if self.idle_rqb is not None: - self._log(5, 'server IDLING, timeout=%.2f' % timeout) - else: - timeout = resp_timeout line = self.inq.get(True, timeout) except Queue.Empty: if self.idle_rqb is None: From dbf683ed388df3211828a2c37e2bf3f400f98eff Mon Sep 17 00:00:00 2001 From: Eygene Ryabinkin Date: Fri, 10 Oct 2014 16:13:16 +0400 Subject: [PATCH 2/2] Imaplib2: trade backticks to repr() Backticks are gone in Python 3.x. GitHub issue: https://github.com/OfflineIMAP/offlineimap/issues/121 Signed-off-by: Eygene Ryabinkin --- offlineimap/imaplib2.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/offlineimap/imaplib2.py b/offlineimap/imaplib2.py index 8921c9d..8975145 100644 --- a/offlineimap/imaplib2.py +++ b/offlineimap/imaplib2.py @@ -378,7 +378,7 @@ class IMAP4(object): elif self._get_untagged_response('OK'): if __debug__: self._log(1, 'state => NONAUTH') else: - raise self.error('unrecognised server welcome message: %s' % `self.welcome`) + raise self.error('unrecognised server welcome message: %s' % repr(self.welcome)) typ, dat = self.capability() if dat == [None]: @@ -1603,7 +1603,7 @@ class IMAP4(object): tag = rqb.tag self.tagged_commands[tag] = rqb self.commands_lock.release() - if __debug__: self._log(4, '_request_push(%s, %s, %s) = %s' % (tag, name, `kw`, rqb.tag)) + if __debug__: self._log(4, '_request_push(%s, %s, %s) = %s' % (tag, name, repr(kw), rqb.tag)) return rqb @@ -1707,7 +1707,7 @@ class IMAP4(object): self.Terminate = True - if __debug__: self._log(1, 'terminating: %s' % `val`) + if __debug__: self._log(1, 'terminating: %s' % repr(val)) while not self.ouq.empty(): try: @@ -1760,7 +1760,7 @@ class IMAP4(object): timeout = read_poll_timeout try: r = poll.poll(timeout) - if __debug__: self._log(5, 'poll => %s' % `r`) + if __debug__: self._log(5, 'poll => %s' % repr(r)) if not r: continue # Timeout @@ -2480,11 +2480,11 @@ if __name__ == '__main__': run('append', (None, None, None, test_mesg), cb=False) num = run('search', (None, 'ALL'), cb=False)[0].split()[0] dat = run('fetch', (num, '(FLAGS INTERNALDATE RFC822)'), cb=False) - M._mesg('fetch %s => %s' % (num, `dat`)) + M._mesg('fetch %s => %s' % (num, repr(dat))) run('idle', (2,)) run('store', (num, '-FLAGS', '(\Seen)'), cb=False), dat = run('fetch', (num, '(FLAGS INTERNALDATE RFC822)'), cb=False) - M._mesg('fetch %s => %s' % (num, `dat`)) + M._mesg('fetch %s => %s' % (num, repr(dat))) run('uid', ('STORE', num, 'FLAGS', '(\Deleted)')) run('expunge', ()) if idle_intr: