summaryrefslogtreecommitdiffstats
path: root/Lib
diff options
context:
space:
mode:
authorR. David Murray <rdmurray@bitdance.com>2010-12-23 20:35:46 (GMT)
committerR. David Murray <rdmurray@bitdance.com>2010-12-23 20:35:46 (GMT)
commit4a62e89728a9394af43a6b791140d90ee4b45c11 (patch)
tree25e5bbf56a6ec345ae3f782e5eab3fa3881e12fe /Lib
parent25b8cca6e890ba405dfdbe284c929718d86f6aaf (diff)
downloadcpython-4a62e89728a9394af43a6b791140d90ee4b45c11.zip
cpython-4a62e89728a9394af43a6b791140d90ee4b45c11.tar.gz
cpython-4a62e89728a9394af43a6b791140d90ee4b45c11.tar.bz2
#1155362: allow hh:mm:ss-uuuu like we allow hh:mm:ss+uuuu in parsedate_tz
Original patch by Thomas Herve.
Diffstat (limited to 'Lib')
-rw-r--r--Lib/email/_parseaddr.py4
-rw-r--r--Lib/email/test/test_email.py10
2 files changed, 13 insertions, 1 deletions
diff --git a/Lib/email/_parseaddr.py b/Lib/email/_parseaddr.py
index 699d418..41694f9 100644
--- a/Lib/email/_parseaddr.py
+++ b/Lib/email/_parseaddr.py
@@ -64,8 +64,10 @@ def parsedate_tz(data):
if len(data) == 4:
s = data[3]
i = s.find('+')
+ if i == -1:
+ i = s.find('-')
if i > 0:
- data[3:] = [s[:i], s[i+1:]]
+ data[3:] = [s[:i], s[i:]]
else:
data.append('') # Dummy tz
if len(data) < 5:
diff --git a/Lib/email/test/test_email.py b/Lib/email/test/test_email.py
index a54c1a3..53c4042 100644
--- a/Lib/email/test/test_email.py
+++ b/Lib/email/test/test_email.py
@@ -2277,6 +2277,16 @@ class TestMiscellaneous(TestEmailBase):
eq(utils.parsedate_tz('5 Feb 2003 13:47:26 -0800'),
(2003, 2, 5, 13, 47, 26, 0, 1, -1, -28800))
+ def test_parsedate_no_space_before_positive_offset(self):
+ self.assertEqual(utils.parsedate_tz('Wed, 3 Apr 2002 14:58:26+0800'),
+ (2002, 4, 3, 14, 58, 26, 0, 1, -1, 28800))
+
+ def test_parsedate_no_space_before_negative_offset(self):
+ # Issue 1155362: we already handled '+' for this case.
+ self.assertEqual(utils.parsedate_tz('Wed, 3 Apr 2002 14:58:26-0800'),
+ (2002, 4, 3, 14, 58, 26, 0, 1, -1, -28800))
+
+
def test_parsedate_acceptable_to_time_functions(self):
eq = self.assertEqual
timetup = utils.parsedate('5 Feb 2003 13:47:26 -0800')