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

Skip to content

Commit 99e1131

Browse files
committed
Avoid crash in parsedate_tz() on certain invalid dates -- when the
field assumed to be the time is in fact the year, the resulting list doesn't have enough items, and this isn't checked for. Return None instead.
1 parent 2d3b0d7 commit 99e1131

1 file changed

Lines changed: 3 additions & 1 deletion

File tree

Lib/rfc822.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -800,8 +800,10 @@ def parsedate_tz(data):
800800
if len(tm) == 2:
801801
[thh, tmm] = tm
802802
tss = '0'
803-
else:
803+
elif len(tm) == 3:
804804
[thh, tmm, tss] = tm
805+
else:
806+
return None
805807
try:
806808
yy = string.atoi(yy)
807809
dd = string.atoi(dd)

0 commit comments

Comments
 (0)