[Python-checkins] cpython (merge 3.1 -> 3.2): merge 3.1

victor.stinner python-checkins at python.org
Mon Mar 21 02:53:21 CET 2011


http://hg.python.org/cpython/rev/7113319e4dcc
changeset:   68786:7113319e4dcc
branch:      3.2
parent:      68783:be74f446b4b8
parent:      68785:b15f60f9e256
user:        Victor Stinner <victor.stinner at haypocalc.com>
date:        Mon Mar 21 02:51:38 2011 +0100
summary:
  merge 3.1

files:
  Lib/http/cookiejar.py
  Misc/NEWS

diff --git a/Lib/http/cookiejar.py b/Lib/http/cookiejar.py
--- a/Lib/http/cookiejar.py
+++ b/Lib/http/cookiejar.py
@@ -29,6 +29,7 @@
            'FileCookieJar', 'LWPCookieJar', 'LoadError', 'MozillaCookieJar']
 
 import copy
+import datetime
 import re
 import time
 import urllib.parse, urllib.request
@@ -97,10 +98,12 @@
     1994-11-24 08:49:37Z
 
     """
-    if t is None: t = time.time()
-    year, mon, mday, hour, min, sec = time.gmtime(t)[:6]
+    if t is None:
+        dt = datetime.datetime.utcnow()
+    else:
+        dt = datetime.datetime.utcfromtimestamp(t)
     return "%04d-%02d-%02d %02d:%02d:%02dZ" % (
-        year, mon, mday, hour, min, sec)
+        dt.year, dt.month, dt.day, dt.hour, dt.minute, dt.second)
 
 def time2netscape(t=None):
     """Return a string representing time in seconds since epoch, t.
@@ -113,10 +116,13 @@
     Wed, DD-Mon-YYYY HH:MM:SS GMT
 
     """
-    if t is None: t = time.time()
-    year, mon, mday, hour, min, sec, wday = time.gmtime(t)[:7]
+    if t is None:
+        dt = datetime.datetime.utcnow()
+    else:
+        dt = datetime.datetime.utcfromtimestamp(t)
     return "%s %02d-%s-%04d %02d:%02d:%02d GMT" % (
-        DAYS[wday], mday, MONTHS[mon-1], year, hour, min, sec)
+        DAYS[dt.weekday()], dt.day, MONTHS[dt.month-1],
+        dt.year, dt.hour, dt.minute, dt.second)
 
 
 UTC_ZONES = {"GMT": None, "UTC": None, "UT": None, "Z": None}
diff --git a/Misc/NEWS b/Misc/NEWS
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -49,6 +49,9 @@
 Library
 -------
 
+- Issue #5537: Fix time2isoz() and time2netscape() functions of
+  httplib.cookiejar for expiration year greater than 2038 on 32-bit systems.
+
 - Issue #11563: Connection:close header is sent by requests using URLOpener
   class which helps in closing of sockets after connection is over. Patch
   contributions by Jeff McNeil and Nadeem Vawda.

-- 
Repository URL: http://hg.python.org/cpython


More information about the Python-checkins mailing list