Author serhiy.storchaka
Recipients barry, maxking, r.david.murray, serhiy.storchaka
Date 2020-10-26.11:41:51
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1603712511.56.0.0108062453896.issue42155@roundup.psfhosted.org>
In-reply-to
Content
Documentation says that parsedate_to_datetime() performs the same function as parsedata(), but on success returns a datetime.

parsedata() returns None when date cannot be parsed, but parsedate_to_datetime() raises TypeError.

>>> email.utils.parsedate("0")
>>> email.utils.parsedate_to_datetime("0")
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/serhiy/py/cpython/Lib/email/utils.py", line 198, in parsedate_to_datetime
    *dtuple, tz = _parsedate_tz(data)
TypeError: cannot unpack non-iterable NoneType object

The other use case is passing None as arguments. Although it is not documented, but I seen the following code in wild:

    parsedate(header.get('Date'))

parsedate() and parsedate_tz() accept None, but parsedate_to_datetime() does not.
History
Date User Action Args
2020-10-26 11:41:51serhiy.storchakasetrecipients: + serhiy.storchaka, barry, r.david.murray, maxking
2020-10-26 11:41:51serhiy.storchakasetmessageid: <1603712511.56.0.0108062453896.issue42155@roundup.psfhosted.org>
2020-10-26 11:41:51serhiy.storchakalinkissue42155 messages
2020-10-26 11:41:51serhiy.storchakacreate