[Python-checkins] cpython (3.4): Issue #23888: Handle fractional time in cookie expiry. Patch by ssh.

robert.collins python-checkins at python.org
Tue Aug 4 00:07:55 CEST 2015


https://hg.python.org/cpython/rev/1c1c508d1b98
changeset:   97221:1c1c508d1b98
branch:      3.4
parent:      97216:e48826904e63
user:        Robert Collins <rbtcollins at hp.com>
date:        Tue Aug 04 10:06:29 2015 +1200
summary:
  Issue #23888: Handle fractional time in cookie expiry. Patch by ssh.

files:
  Lib/http/cookiejar.py           |  2 +-
  Lib/test/test_http_cookiejar.py |  9 +++++++++
  Misc/NEWS                       |  2 ++
  3 files changed, 12 insertions(+), 1 deletions(-)


diff --git a/Lib/http/cookiejar.py b/Lib/http/cookiejar.py
--- a/Lib/http/cookiejar.py
+++ b/Lib/http/cookiejar.py
@@ -758,7 +758,7 @@
                  ):
 
         if version is not None: version = int(version)
-        if expires is not None: expires = int(expires)
+        if expires is not None: expires = int(float(expires))
         if port is None and port_specified is True:
             raise ValueError("if port is None, port_specified must be false")
 
diff --git a/Lib/test/test_http_cookiejar.py b/Lib/test/test_http_cookiejar.py
--- a/Lib/test/test_http_cookiejar.py
+++ b/Lib/test/test_http_cookiejar.py
@@ -566,6 +566,15 @@
         self.assertEqual(len(c), 1)
         self.assertIn('spam="bar"', h)
 
+        # test if fractional expiry is accepted
+        cookie  = Cookie(0, "name", "value",
+                         None, False, "www.python.org",
+                         True, False, "/",
+                         False, False, "1444312383.018307",
+                         False, None, None,
+                         {})
+        self.assertEqual(cookie.expires, 1444312383)
+
         # XXX RFC 2965 expiry rules (some apply to V0 too)
 
     def test_default_path(self):
diff --git a/Misc/NEWS b/Misc/NEWS
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -66,6 +66,8 @@
 Library
 -------
 
+- Issue #23888: Handle fractional time in cookie expiry. Patch by ssh.
+
 - Issue #23652: Make it possible to compile the select module against the
   libc headers from the Linux Standard Base, which do not include some
   EPOLL macros.  Patch by Matt Frank.

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


More information about the Python-checkins mailing list