[PATCH] imaplib2: Bump from 2.20 to 2.22
Sebastian Spaeth
Sebastian at SSpaeth.de
Mon Apr 11 16:24:44 BST 2011
This contains a fixed Time2InternalDate function and a more robust
socket connection, trying twice and raising an error only when that
fails (I believe). The actual code changes are rather minor.
Signed-off-by: Sebastian Spaeth <Sebastian at SSpaeth.de>
---
Bump upstream imaplib2 to current released version. This is on top of current master. The fixes are not critical though, so we should probably postpone applying this until after the stable release? Although the risk of breaking something that is now not broken are pretty slim.
offlineimap/imaplib2.py | 32 +++++++++++++++++++++-----------
1 files changed, 21 insertions(+), 11 deletions(-)
mode change 100755 => 100644 offlineimap/imaplib2.py
diff --git a/offlineimap/imaplib2.py b/offlineimap/imaplib2.py
old mode 100755
new mode 100644
index 20b90ae..be34025
--- 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.20"
+__version__ = "2.22"
__release__ = "2"
-__revision__ = "20"
+__revision__ = "22"
__credits__ = """
Authentication code contributed by Donn Cave <donn at u.washington.edu> June 1998.
String method conversion by ESR, February 2001.
@@ -35,12 +35,13 @@ ID contributed by Dave Baggett <dave at baggett.org> November 2009.
Improved untagged responses handling suggested by Dave Baggett <dave at baggett.org> November 2009.
Improved thread naming, and 0 read detection contributed by Grant Edwards <grant.b.edwards at gmail.com> June 2010.
Improved timeout handling contributed by Ivan Vovnenko <ivovnenko at gmail.com> October 2010.
-Timeout handling further improved by Ethan Glasser-Camp <glasse at cs.rpi.edu> December 2010."""
+Timeout handling further improved by Ethan Glasser-Camp <glasse at cs.rpi.edu> December 2010.
+Time2Internaldate() patch to match RFC2060 specification of English month names from http://bugs.python.org/issue11024 March 2011."""
__author__ = "Piers Lauder <piers at janeelix.com>"
__URL__ = "http://janeelix.com/piers/python/imaplib2"
__license__ = "Python License"
-import binascii, os, Queue, random, re, select, socket, sys, time, threading, zlib
+import binascii, errno, os, Queue, random, re, select, socket, sys, time, threading, zlib
select_module = select
@@ -404,7 +405,15 @@ class IMAP4(object):
except socket.error, msg:
continue
try:
- s.connect(sa)
+ for i in (0, 1):
+ try:
+ s.connect(sa)
+ break
+ except socket.error, msg:
+ if len(msg.args) < 2 or msg.args[0] != errno.EINTR:
+ raise
+ else:
+ raise socket.error(msg)
except socket.error, msg:
s.close()
continue
@@ -2057,8 +2066,10 @@ class _IdleCont(object):
-Mon2num = {'Jan': 1, 'Feb': 2, 'Mar': 3, 'Apr': 4, 'May': 5, 'Jun': 6,
- 'Jul': 7, 'Aug': 8, 'Sep': 9, 'Oct': 10, 'Nov': 11, 'Dec': 12}
+MonthNames = [None, 'Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun',
+ 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec']
+
+Mon2num = dict(zip((x.encode() for x in MonthNames[1:]), range(1, 13)))
InternalDate = re.compile(r'.*INTERNALDATE "'
r'(?P<day>[ 0123][0-9])-(?P<mon>[A-Z][a-z][a-z])-(?P<year>[0-9][0-9][0-9][0-9])'
@@ -2126,14 +2137,13 @@ def Time2Internaldate(date_time):
else:
raise ValueError("date_time not of a known type")
- dt = time.strftime("%d-%b-%Y %H:%M:%S", tt)
- if dt[0] == '0':
- dt = ' ' + dt[1:]
if time.daylight and tt[-1]:
zone = -time.altzone
else:
zone = -time.timezone
- return '"' + dt + " %+03d%02d" % divmod(zone//60, 60) + '"'
+ return ('"%2d-%s-%04d %02d:%02d:%02d %+03d%02d"' %
+ ((tt[2], MonthNames[tt[1]], tt[0]) + tt[3:6] +
+ divmod(zone//60, 60)))
--
1.7.1
More information about the OfflineIMAP-project
mailing list