[New-bugs-announce] [issue46011] Python 3.10 email returns invalid Date: header unchanged.

Mark Sapiro report at bugs.python.org
Tue Dec 7 23:32:57 EST 2021


New submission from Mark Sapiro <mark at msapiro.net>:

Here is an interactive Python session
```
Python 3.10.1 (main, Dec  7 2021, 15:44:39) [GCC 9.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> from email import message_from_bytes, policy
>>> msg_raw = b"""Return-Path: <owner-mailman-users at python.org>
... Delivered-To: mailman-users at dinsdale.python.org
... From: user at example.com
... Message-Id: <msg1>
... Date: Tue, 30 Nov 1999 23:56:33 -3000 (CST)
... To: mailman-users at python.org
... 
... msg1
... """
>>> message = message_from_bytes(msg_raw, policy=policy.default)
>>> message.get('date')
'Tue, 30 Nov 1999 23:56:33 -3000 (CST)'
>>> message.defects
[]
>>> 
```
The same session in Python 3.9 throws ValueError: offset must be a timedelta strictly between -timedelta(hours=24) and timedelta(hours=24), not datetime.timedelta(days=-2, seconds=64800).

At first I thought this was related to https://bugs.python.org/issue30681 but that seems to not be the case as utils.parsedate_to_datetime('Tue, 30 Nov 1999 23:56:33 -3000 (CST)') throws the same exception In Python 3.10.1.

I think getting the Date: header which has an invalid timezone should either throw the exception as before or return None, but not return the invalid date header.

----------
components: email
keywords: 3.10regression
messages: 407997
nosy: barry, msapiro, r.david.murray
priority: normal
severity: normal
status: open
title: Python 3.10 email returns invalid Date: header unchanged.
versions: Python 3.10

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


More information about the New-bugs-announce mailing list