classification
Title: email.utils.parsetime_tz does not return "None" as the tz offset
Type: behavior Stage: resolved
Components: Documentation Versions: Python 3.9, Python 3.8, Python 3.7, Python 3.6, Python 3.5
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: docs@python Nosy List: barry, docs@python, irishsmurf, maxking, miss-islington, petr.viktorin, r.david.murray, xtreak
Priority: normal Keywords: patch

Created on 2019-10-09 12:45 by irishsmurf, last changed 2019-11-12 13:39 by petr.viktorin. This issue is now closed.

Pull Requests
URL Status Linked Edit
PR 16678 merged python-dev, 2019-10-09 13:36
PR 17121 merged miss-islington, 2019-11-12 12:39
PR 17122 merged miss-islington, 2019-11-12 12:39
Messages (7)
msg354265 - (view) Author: David Kernan (irishsmurf) * Date: 2019-10-09 12:45
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?
msg354267 - (view) Author: Karthikeyan Singaravelan (xtreak) * (Python triager) Date: 2019-10-09 13:20
It looks like a documentation issue to me given the change and tests made in https://github.com/python/cpython/commit/875048bd4c95ae90c3e541cad681b11436ce1f3f
msg354268 - (view) Author: David Kernan (irishsmurf) * Date: 2019-10-09 13:25
Ah yes, thanks, this does seem pretty intentional.

I'll submit a PR for the documentation for this method for the affected version.
msg356449 - (view) Author: miss-islington (miss-islington) Date: 2019-11-12 12:38
New changeset a12255d8def0c82560545e66c1be981a447751c3 by Miss Islington (bot) (David K) in branch 'master':
bpo-38421: Update email.utils documentation (GH-16678)
https://github.com/python/cpython/commit/a12255d8def0c82560545e66c1be981a447751c3
msg356454 - (view) Author: miss-islington (miss-islington) Date: 2019-11-12 13:34
New changeset eadddad6b093bca74601b1ea91ab96119bc543d8 by Miss Islington (bot) in branch '3.7':
[3.7] bpo-38421: Update email.utils documentation (GH-16678) (GH-17121)
https://github.com/python/cpython/commit/eadddad6b093bca74601b1ea91ab96119bc543d8
msg356455 - (view) Author: miss-islington (miss-islington) Date: 2019-11-12 13:34
New changeset 29fd6a77d509cffacc5691ebd9dab53455ad959e by Miss Islington (bot) in branch '3.8':
[3.8] bpo-38421: Update email.utils documentation (GH-16678) (GH-17122)
https://github.com/python/cpython/commit/29fd6a77d509cffacc5691ebd9dab53455ad959e
msg356456 - (view) Author: Petr Viktorin (petr.viktorin) * (Python committer) Date: 2019-11-12 13:39
Thank you for the fix!
History
Date User Action Args
2019-11-12 13:39:15petr.viktorinsetstatus: open -> closed

nosy: + petr.viktorin
messages: + msg356456

resolution: fixed
stage: patch review -> resolved
2019-11-12 13:34:27miss-islingtonsetmessages: + msg356455
2019-11-12 13:34:23miss-islingtonsetmessages: + msg356454
2019-11-12 12:39:35miss-islingtonsetpull_requests: + pull_request16628
2019-11-12 12:39:05miss-islingtonsetpull_requests: + pull_request16627
2019-11-12 12:38:54miss-islingtonsetnosy: + miss-islington
messages: + msg356449
2019-10-09 13:36:40python-devsetkeywords: + patch
stage: patch review
pull_requests: + pull_request16261
2019-10-09 13:35:59irishsmurfsetassignee: docs@python

components: + Documentation, - email
nosy: + docs@python
2019-10-09 13:25:23irishsmurfsetmessages: + msg354268
2019-10-09 13:20:33xtreaksetnosy: + xtreak
messages: + msg354267
2019-10-09 13:14:52xtreaksetnosy: + maxking
2019-10-09 12:46:31irishsmurfsettitle: email.utils.parsetime_tz does not return "None" -> email.utils.parsetime_tz does not return "None" as the tz offset
2019-10-09 12:45:09irishsmurfsettype: behavior
2019-10-09 12:45:03irishsmurfcreate