diff options
author | Senthil Kumaran <orsenthil@gmail.com> | 2010-05-01 08:01:56 (GMT) |
---|---|---|
committer | Senthil Kumaran <orsenthil@gmail.com> | 2010-05-01 08:01:56 (GMT) |
commit | 1b7f9e53b3dbfb3c97b5e5a768ae4ac4a452f2aa (patch) | |
tree | ce2cc8a02e9f5f134afe18834f7c6e25d8940a34 | |
parent | d3b6022d0ab24727cd6197657bd6a3488fcd97ff (diff) | |
download | cpython-1b7f9e53b3dbfb3c97b5e5a768ae4ac4a452f2aa.zip cpython-1b7f9e53b3dbfb3c97b5e5a768ae4ac4a452f2aa.tar.gz cpython-1b7f9e53b3dbfb3c97b5e5a768ae4ac4a452f2aa.tar.bz2 |
Fix issue8582: urllib.urlretrieve fails with ValueError: Invalid format string
-rw-r--r-- | Lib/test/test_urllibnet.py | 13 | ||||
-rw-r--r-- | Lib/urllib.py | 2 |
2 files changed, 14 insertions, 1 deletions
diff --git a/Lib/test/test_urllibnet.py b/Lib/test/test_urllibnet.py index 8eb01e5..8cba2dc 100644 --- a/Lib/test/test_urllibnet.py +++ b/Lib/test/test_urllibnet.py @@ -7,6 +7,8 @@ import socket import urllib import sys import os +import time + mimetools = test_support.import_module("mimetools", deprecated=True) @@ -178,6 +180,17 @@ class urlretrieveNetworkTests(unittest.TestCase): self.assertIsInstance(header, mimetools.Message, "header is not an instance of mimetools.Message") + def test_data_header(self): + logo = "http://www.python.org/community/logos/python-logo-master-v3-TM.png" + file_location, fileheaders = self.urlretrieve(logo) + os.unlink(file_location) + datevalue = fileheaders.getheader('Date') + dateformat = '%a, %d %b %Y %H:%M:%S GMT' + try: + time.strptime(datevalue, dateformat) + except ValueError: + self.fail('Date value not in %r format', dateformat) + def test_main(): diff --git a/Lib/urllib.py b/Lib/urllib.py index c74dd3c..652be75 100644 --- a/Lib/urllib.py +++ b/Lib/urllib.py @@ -588,7 +588,7 @@ class URLopener: else: encoding = '' msg = [] - msg.append('Date: %s'%time.strftime('%a, %d %b %Y %T GMT', + msg.append('Date: %s'%time.strftime('%a, %d %b %Y %H:%M:%S GMT', time.gmtime(time.time()))) msg.append('Content-type: %s' % type) if encoding == 'base64': |