Fix issue8582: urllib.urlretrieve fails with ValueError: Invalid format string

This commit is contained in:
Senthil Kumaran 2010-05-01 08:01:56 +00:00
parent d3b6022d0a
commit 1b7f9e53b3
2 changed files with 14 additions and 1 deletions

View File

@ -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():

View File

@ -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':