Author irishsmurf
Recipients barry, irishsmurf, r.david.murray
Date 2019-10-09.12:45:03
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1570625103.37.0.0601159046628.issue38421@roundup.psfhosted.org>
In-reply-to
Content
email.utils.parsetime_tz() is a function which attempts to parse a date, and returns a 10-item tuple.
The first 9 items represents a time, and the last item represents the timezone offset from UTC.

In Python 2, the original behavior was to return the date, and a "None" value when there was no timezone - this is documented here:
https://docs.python.org/3/library/email.utils.html#email.utils.parsedate_tz

In Python 3 however, the code specifically prevents "None" from being returned in place of a UTC offset:
https://github.com/python/cpython/blob/3.7/Lib/email/_parseaddr.py#L53-#L54

The Python 3 documentation for email.utils.parsetime_tz() - is still the same as the 2.7 documentation, and specifically mentions that should a timezone be missing from the string, the last item will be "None"

This isn't the case:

Python 3.6.8:
>>> import email.utils
>>> date_string = 'Wed, 09 Oct 2019 08:32:37'
>>> email.utils.parsedate_tz(date_string)
(2019, 10, 9, 8, 32, 37, 0, 1, -1, 0)
----

Python 2.7.16:
>>> import email.utils
>>> date_string = 'Wed, 09 Oct 2019 08:32:37'
>>> email.utils.parsedate_tz(date_string)
(2019, 10, 9, 8, 32, 37, 0, 1, -1, None)

---

Is this an error in code, or is it a mistake in the documentation?
History
Date User Action Args
2019-10-09 12:45:03irishsmurfsetrecipients: + irishsmurf, barry, r.david.murray
2019-10-09 12:45:03irishsmurfsetmessageid: <1570625103.37.0.0601159046628.issue38421@roundup.psfhosted.org>
2019-10-09 12:45:03irishsmurflinkissue38421 messages
2019-10-09 12:45:03irishsmurfcreate