[issue42155] email.utils.parsedate_to_datetime() should return None when date cannot be parsed

2020-10-26 Thread Barry A. Warsaw


Change by Barry A. Warsaw :


--
stage:  -> resolved
status: open -> closed

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue42155] email.utils.parsedate_to_datetime() should return None when date cannot be parsed

2020-10-26 Thread Barry A. Warsaw


Barry A. Warsaw  added the comment:

Hi Serhiy.  I believe this is a duplicate of bpo-30681 which is active and has 
a good PR IMHO.  The only hold up is whether to backport that PR to 3.9 and 
3.8.  See the bug and PR for details.

--
resolution:  -> duplicate
superseder:  -> email.utils.parsedate_to_datetime() should return None when 
date cannot be parsed

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue42155] email.utils.parsedate_to_datetime() should return None when date cannot be parsed

2020-10-26 Thread Serhiy Storchaka


New submission from Serhiy Storchaka :

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 "", line 1, in 
  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.

--
components: Library (Lib), email
messages: 379661
nosy: barry, maxking, r.david.murray, serhiy.storchaka
priority: normal
severity: normal
status: open
title: email.utils.parsedate_to_datetime() should return None when date cannot 
be parsed
versions: Python 3.10

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com