]> granicus.if.org Git - python/commitdiff
Issue #10939: Fixed imaplib.Internaldate2tuple(). Thanks Joe Peterson
authorAlexander Belopolsky <alexander.belopolsky@gmail.com>
Sat, 29 Jan 2011 17:19:08 +0000 (17:19 +0000)
committerAlexander Belopolsky <alexander.belopolsky@gmail.com>
Sat, 29 Jan 2011 17:19:08 +0000 (17:19 +0000)
for the report and the patch.  Reviewed by Georg Brandl.

Lib/imaplib.py
Lib/test/test_imaplib.py
Misc/ACKS

index 4b8e898575fa9dafa1cfaccd380077329852b066..1022e77c4f6032180c5d684061ea5741b89e4a75 100644 (file)
@@ -1308,8 +1308,8 @@ class _Authenticator:
 
 
 
-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}
+Mon2num = {b'Jan': 1, b'Feb': 2, b'Mar': 3, b'Apr': 4, b'May': 5, b'Jun': 6,
+           b'Jul': 7, b'Aug': 8, b'Sep': 9, b'Oct': 10, b'Nov': 11, b'Dec': 12}
 
 def Internaldate2tuple(resp):
     """Parse an IMAP4 INTERNALDATE string.
@@ -1336,7 +1336,7 @@ def Internaldate2tuple(resp):
     # INTERNALDATE timezone must be subtracted to get UT
 
     zone = (zoneh*60 + zonem)*60
-    if zonen == '-':
+    if zonen == b'-':
         zone = -zone
 
     tt = (year, mon, day, hour, min, sec, -1, -1, -1)
index acb89e37b42539f2af8234634ac2f8defea0b2d1..bad4d19b598c289625f74fa398a795785c429262 100644 (file)
@@ -23,6 +23,17 @@ CERTFILE = None
 
 class TestImaplib(unittest.TestCase):
 
+    def test_Internaldate2tuple(self):
+        tt = imaplib.Internaldate2tuple(
+            b'25 (INTERNALDATE "01-Jan-1970 00:00:00 +0000")')
+        self.assertEqual(time.mktime(tt), 0)
+        tt = imaplib.Internaldate2tuple(
+            b'25 (INTERNALDATE "01-Jan-1970 11:30:00 +1130")')
+        self.assertEqual(time.mktime(tt), 0)
+        tt = imaplib.Internaldate2tuple(
+            b'25 (INTERNALDATE "31-Dec-1969 12:30:00 -1130")')
+        self.assertEqual(time.mktime(tt), 0)
+
     def test_that_Time2Internaldate_returns_a_result(self):
         # We can check only that it successfully produces a result,
         # not the correctness of the result itself, since the result
index 5256cfb711669d5c2e1661b71093a3d41207902e..02e5d9168dd98a267ed91a46e72dd601c15ed42b 100644 (file)
--- a/Misc/ACKS
+++ b/Misc/ACKS
@@ -653,6 +653,7 @@ Trevor Perrin
 Gabriel de Perthuis
 Tim Peters
 Benjamin Peterson
+Joe Peterson
 Chris Petrilli
 Bjorn Pettersen
 Geoff Philbrick