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

Barry A. Warsaw report at bugs.python.org
Fri Oct 23 14:42:32 EDT 2020


Barry A. Warsaw <barry at python.org> added the comment:

Aside: I noticed that on _parseaddr.py:68, there's a bare `return`.  That should really be `return None` (EIBTI).  Can you fix that in your PR?

I think it's confusing to raise both TypeError and ValueError.  I suggest we check the `None` return from _parsedate_tz() and raise ValueError explicitly in that case, avoiding the implicit TypeError on the failing tuple unpack.

+1 on removing the mention of returning None from the documentation.  Then with the above, it would document raising ValueError on invalid date input.

As for backporting, I'm nosing Ned and Łukasz to weigh in.  Given that the patch is adding a new defect class (which it should), this won't break existing code, but it does mean that existing code would have different semantics depending on the patch version release of 3.9, 3.8, and 3.7.  I'm not completely comfortable with that, but let's see what the RMs say.  I guess I'm currently -0 on backporting.

----------
nosy: +lukasz.langa, ned.deily

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue30681>
_______________________________________


More information about the Python-bugs-list mailing list