summaryrefslogtreecommitdiffstats
path: root/Lib/email
diff options
context:
space:
mode:
authorGeorg Brandl <georg@python.org>2012-09-22 07:03:56 (GMT)
committerGeorg Brandl <georg@python.org>2012-09-22 07:03:56 (GMT)
commit1aca31e8f329e19de62a2f1a2080995e5712a9cd (patch)
tree9a3d62178053892e1bb1033032f88977746a7951 /Lib/email
parentdeb92b5b1b015191bb9f072b67536e471bd37a7a (diff)
downloadcpython-1aca31e8f329e19de62a2f1a2080995e5712a9cd.zip
cpython-1aca31e8f329e19de62a2f1a2080995e5712a9cd.tar.gz
cpython-1aca31e8f329e19de62a2f1a2080995e5712a9cd.tar.bz2
Closes #15925: fix regression in parsedate() and parsedate_tz() that should return None if unable to parse the argument.
Diffstat (limited to 'Lib/email')
-rw-r--r--Lib/email/_parseaddr.py4
-rw-r--r--Lib/email/utils.py24
2 files changed, 6 insertions, 22 deletions
diff --git a/Lib/email/_parseaddr.py b/Lib/email/_parseaddr.py
index 3528d02..cdfa372 100644
--- a/Lib/email/_parseaddr.py
+++ b/Lib/email/_parseaddr.py
@@ -48,6 +48,8 @@ def parsedate_tz(data):
Accounts for military timezones.
"""
res = _parsedate_tz(data)
+ if not res:
+ return
if res[9] is None:
res[9] = 0
return tuple(res)
@@ -62,6 +64,8 @@ def _parsedate_tz(data):
source timezone really was UTC.
"""
+ if not data:
+ return
data = data.split()
# The FWS after the comma after the day-of-week is optional, so search and
# adjust for this.
diff --git a/Lib/email/utils.py b/Lib/email/utils.py
index 73bc348..6b6d7f4 100644
--- a/Lib/email/utils.py
+++ b/Lib/email/utils.py
@@ -37,10 +37,7 @@ from email._parseaddr import quote
from email._parseaddr import AddressList as _AddressList
from email._parseaddr import mktime_tz
-# We need wormarounds for bugs in these methods in older Pythons (see below)
-from email._parseaddr import parsedate as _parsedate
-from email._parseaddr import parsedate_tz as _parsedate_tz
-from email._parseaddr import _parsedate_tz as __parsedate_tz
+from email._parseaddr import parsedate, parsedate_tz, _parsedate_tz
from quopri import decodestring as _qdecode
@@ -222,25 +219,8 @@ def make_msgid(idstring=None, domain=None):
return msgid
-
-# These functions are in the standalone mimelib version only because they've
-# subsequently been fixed in the latest Python versions. We use this to worm
-# around broken older Pythons.
-def parsedate(data):
- if not data:
- return None
- return _parsedate(data)
-
-
-def parsedate_tz(data):
- if not data:
- return None
- return _parsedate_tz(data)
-
def parsedate_to_datetime(data):
- if not data:
- return None
- *dtuple, tz = __parsedate_tz(data)
+ *dtuple, tz = _parsedate_tz(data)
if tz is None:
return datetime.datetime(*dtuple[:6])
return datetime.datetime(*dtuple[:6],