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

Skip to content

Commit 0647ef0

Browse files
committed
Issue #16181: cookiejar.http2time() now returns None if year is higher than datetime.MAXYEAR
2 parents 4c9375b + 20be53e commit 0647ef0

3 files changed

Lines changed: 11 additions & 1 deletion

File tree

Lib/http/cookiejar.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,10 @@ def offset_from_tz_string(tz):
143143
return offset
144144

145145
def _str2time(day, mon, yr, hr, min, sec, tz):
146+
yr = int(yr)
147+
if yr > datetime.MAXYEAR:
148+
return None
149+
146150
# translate month name to number
147151
# month numbers start with 1 (January)
148152
try:
@@ -163,7 +167,6 @@ def _str2time(day, mon, yr, hr, min, sec, tz):
163167
if min is None: min = 0
164168
if sec is None: sec = 0
165169

166-
yr = int(yr)
167170
day = int(day)
168171
hr = int(hr)
169172
min = int(min)

Lib/test/test_http_cookiejar.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,10 @@ def test_http2time_garbage(self):
9191
'01-01-1980 25:00:00',
9292
'01-01-1980 00:61:00',
9393
'01-01-1980 00:00:62',
94+
'08-Oct-3697739',
95+
'08-01-3697739',
96+
'09 Feb 19942632 22:23:32 GMT',
97+
'Wed, 09 Feb 1994834 22:23:32 GMT',
9498
]:
9599
self.assertIsNone(http2time(test),
96100
"http2time(%s) is not None\n"

Misc/NEWS

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -201,6 +201,9 @@ Core and Builtins
201201
Library
202202
-------
203203

204+
- Issue #16181: cookiejar.http2time() now returns None if year is higher than
205+
datetime.MAXYEAR.
206+
204207
- Issue #26513: Fixes platform module detection of Windows Server
205208

206209
- Issue #23718: Fixed parsing time in week 0 before Jan 1. Original patch by

0 commit comments

Comments
 (0)