New submission from David Kernan <davidsm...@gmail.com>:
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? ---------- components: email messages: 354265 nosy: David Kernan, barry, r.david.murray priority: normal severity: normal status: open title: email.utils.parsetime_tz does not return "None" versions: Python 3.5, Python 3.6, Python 3.7, Python 3.8, Python 3.9 _______________________________________ Python tracker <rep...@bugs.python.org> <https://bugs.python.org/issue38421> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com