]> granicus.if.org Git - python/commitdiff
Issue #23888: Handle fractional time in cookie expiry. Patch by ssh.
authorRobert Collins <rbtcollins@hp.com>
Mon, 3 Aug 2015 22:06:29 +0000 (10:06 +1200)
committerRobert Collins <rbtcollins@hp.com>
Mon, 3 Aug 2015 22:06:29 +0000 (10:06 +1200)
Lib/http/cookiejar.py
Lib/test/test_http_cookiejar.py
Misc/NEWS

index bfc6ae99932b3fe9f2b29c81a4b8fa21728570e2..92ead538c5a3aa012b6b2350b49848d7b717f777 100644 (file)
@@ -758,7 +758,7 @@ class Cookie:
                  ):
 
         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")
 
index e9f0356050783238ac9bd304ccbcb288e54d9059..50260ffe5cef4e8e803b4b2d4954e0033b79ff32 100644 (file)
@@ -566,6 +566,15 @@ class CookieTests(unittest.TestCase):
         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):
index f3348c14b10289bd07fa4435fc4598b4a598439c..822184b4e2e9ab542b84ed12609cb6c4796596db 100644 (file)
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -66,6 +66,8 @@ Core and Builtins
 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.