You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
email.utils.parsedate() and email.utils.parsedate_tz() should return None when date cannot be parsed #60129
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
assignee='https://github.com/birkenfeld'closed_at=<Date2012-09-22.15:35:54.351>created_at=<Date2012-09-12.00:37:45.217>labels= ['type-bug', 'expert-email', 'release-blocker']
title='email.utils.parsedate() and email.utils.parsedate_tz() should return None when date cannot be parsed'updated_at=<Date2012-09-24.05:46:47.118>user='https://bugs.python.org/Arfrever'
>>> email.utils.parsedate("0")
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/lib64/python3.3/email/utils.py", line 232, in parsedate
return _parsedate(data)
File "/usr/lib64/python3.3/email/_parseaddr.py", line 172, in parsedate
t = parsedate_tz(data)
File "/usr/lib64/python3.3/email/_parseaddr.py", line 51, in parsedate_tz
if res[9] is None:
TypeError: 'NoneType' object is not subscriptable
>>> email.utils.parsedate_tz("0")
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/lib64/python3.3/email/utils.py", line 238, in parsedate_tz
return _parsedate_tz(data)
File "/usr/lib64/python3.3/email/_parseaddr.py", line 51, in parsedate_tz
if res[9] is None:
TypeError: 'NoneType' object is not subscriptable
>>> email.utils.parsedate_to_datetime("0")
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/lib64/python3.3/email/utils.py", line 243, in parsedate_to_datetime
*dtuple, tz = __parsedate_tz(data)
TypeError: 'NoneType' object is not iterable
>>>
changed the title [-]email.utils.parsedate(), email.utils.parsedate_tz() and email.utils.parsedate_to_datetime() should return None when date cannot be parsed[/-][+]email.utils.parsedate() and email.utils.parsedate_tz() should return None when date cannot be parsed[/+]on Sep 16, 2012
Arfrever commented on Sep 17, 2012
Arfrevermannequin
MannequinAuthor
More actions
I think that email.utils.parsedate_to_datetime("0") should raise ValueError instead of TypeError.
New changeset c1e9a1fc6931 by Georg Brandl in branch 'default':
Closes bpo-15925: fix regression in parsedate() and parsedate_tz() that should return None if unable to parse the argument. http://hg.python.org/cpython/rev/c1e9a1fc6931
Activity
Arfrever commentedon Sep 12, 2012
Documentation (in Python 3.3) says that None is returned when date cannot be parsed.
In Python 3.2:
In Python 3.3:
bitdancer commentedon Sep 16, 2012
Here is a patch.
Georg, this unfortunately represents a regression from 3.2 and should be fixed.
bitdancer commentedon Sep 16, 2012
Hmm. Not sure why Georg didn't get auto-added.
bitdancer commentedon Sep 16, 2012
Oh, and I'm purposely allowing parsedate_to_datetime throw exceptions. I suppose that should be documented, but that's a separate issue.
[-]email.utils.parsedate(), email.utils.parsedate_tz() and email.utils.parsedate_to_datetime() should return None when date cannot be parsed[/-][+]email.utils.parsedate() and email.utils.parsedate_tz() should return None when date cannot be parsed[/+]Arfrever commentedon Sep 17, 2012
I think that email.utils.parsedate_to_datetime("0") should raise ValueError instead of TypeError.
python-dev commentedon Sep 22, 2012
New changeset 3b03d31f6a79 by R David Murray in branch 'default':
bpo-15925: fix regression: return None for null and non-date strings.
http://hg.python.org/cpython/rev/3b03d31f6a79
bitdancer commentedon Sep 22, 2012
I don't think it is worth the extra code to convert the TypeError into a ValueError. We aren't very strict about the distinction between those two.
Leaving this open for Georg to transplant it to 3.3.0.
birkenfeld commentedon Sep 22, 2012
This was committed to the release clone as c1e9a1fc6931.
python-dev commentedon Sep 24, 2012
New changeset c1e9a1fc6931 by Georg Brandl in branch 'default':
Closes bpo-15925: fix regression in parsedate() and parsedate_tz() that should return None if unable to parse the argument.
http://hg.python.org/cpython/rev/c1e9a1fc6931