Tim Bell added the comment:

My proposed solution (in https://github.com/python/cpython/pull/2229) is 
two-part:

1. change parsedate_to_datetime() to return None rather than raising an 
exception; and

2. change headerregistry.DateHeader.parse() to check for None being returned 
from parsedate_to_datetime(), and to add a defect; the datetime attribute is 
set to None (as if the Date header were missing), but the header still 
evaluates as a string to the supplied header value.

I'm not sure what the use case is for distinguishing between a missing Date 
header and an invalid date value, but can't that be distinguished by the 
different defects added to the header?

In any case, if I'm not fully grasping the context and parsedate_to_datetime() 
should continue to throw exceptions, then a slightly different modification to 
DateHeader to catch those exceptions would seem sensible, and would address my 
use case.

----------

_______________________________________
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue30681>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to