Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit a0e5d98

Browse files
committed
Issue #23888: Handle fractional time in cookie expiry. Patch by ssh.
1 parent 43cbbe2 commit a0e5d98

3 files changed

Lines changed: 12 additions & 1 deletion

File tree

Lib/http/cookiejar.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -758,7 +758,7 @@ def __init__(self, version, name, value,
758758
):
759759

760760
if version is not None: version = int(version)
761-
if expires is not None: expires = int(expires)
761+
if expires is not None: expires = int(float(expires))
762762
if port is None and port_specified is True:
763763
raise ValueError("if port is None, port_specified must be false")
764764

Lib/test/test_http_cookiejar.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -566,6 +566,15 @@ def test_expires(self):
566566
self.assertEqual(len(c), 1)
567567
self.assertIn('spam="bar"', h)
568568

569+
# test if fractional expiry is accepted
570+
cookie = Cookie(0, "name", "value",
571+
None, False, "www.python.org",
572+
True, False, "/",
573+
False, False, "1444312383.018307",
574+
False, None, None,
575+
{})
576+
self.assertEqual(cookie.expires, 1444312383)
577+
569578
# XXX RFC 2965 expiry rules (some apply to V0 too)
570579

571580
def test_default_path(self):

Misc/NEWS

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,8 @@ Core and Builtins
6666
Library
6767
-------
6868

69+
- Issue #23888: Handle fractional time in cookie expiry. Patch by ssh.
70+
6971
- Issue #23652: Make it possible to compile the select module against the
7072
libc headers from the Linux Standard Base, which do not include some
7173
EPOLL macros. Patch by Matt Frank.

0 commit comments

Comments
 (0)