summaryrefslogtreecommitdiff
path: root/Lib
diff options
context:
space:
mode:
authorBerker Peksag <berker.peksag@gmail.com>2016-03-14 05:48:28 +0200
committerBerker Peksag <berker.peksag@gmail.com>2016-03-14 05:48:28 +0200
commit0647ef05ebe3802617978b9f92922e6e9d33eaac (patch)
treee6990fd530d149e68294ce0b6893e0a7db5bf047 /Lib
parent4c9375b65f4788b73cfa46f3daa94143b49273fa (diff)
parent20be53e5b51a3388454cb7d0604a03a20d884510 (diff)
downloadcpython-git-0647ef05ebe3802617978b9f92922e6e9d33eaac.tar.gz
Issue #16181: cookiejar.http2time() now returns None if year is higher than datetime.MAXYEAR
Diffstat (limited to 'Lib')
-rw-r--r--Lib/http/cookiejar.py5
-rw-r--r--Lib/test/test_http_cookiejar.py4
2 files changed, 8 insertions, 1 deletions
diff --git a/Lib/http/cookiejar.py b/Lib/http/cookiejar.py
index ac5e667dba..bd367f94ca 100644
--- a/Lib/http/cookiejar.py
+++ b/Lib/http/cookiejar.py
@@ -143,6 +143,10 @@ def offset_from_tz_string(tz):
return offset
def _str2time(day, mon, yr, hr, min, sec, tz):
+ yr = int(yr)
+ if yr > datetime.MAXYEAR:
+ return None
+
# translate month name to number
# month numbers start with 1 (January)
try:
@@ -163,7 +167,6 @@ def _str2time(day, mon, yr, hr, min, sec, tz):
if min is None: min = 0
if sec is None: sec = 0
- yr = int(yr)
day = int(day)
hr = int(hr)
min = int(min)
diff --git a/Lib/test/test_http_cookiejar.py b/Lib/test/test_http_cookiejar.py
index 50260ffe5c..ea3c827fb7 100644
--- a/Lib/test/test_http_cookiejar.py
+++ b/Lib/test/test_http_cookiejar.py
@@ -91,6 +91,10 @@ class DateTimeTests(unittest.TestCase):
'01-01-1980 25:00:00',
'01-01-1980 00:61:00',
'01-01-1980 00:00:62',
+ '08-Oct-3697739',
+ '08-01-3697739',
+ '09 Feb 19942632 22:23:32 GMT',
+ 'Wed, 09 Feb 1994834 22:23:32 GMT',
]:
self.assertIsNone(http2time(test),
"http2time(%s) is not None\n"