]> granicus.if.org Git - python/commitdiff
Merged revisions 80675 via svnmerge from
authorSenthil Kumaran <orsenthil@gmail.com>
Sat, 1 May 2010 08:06:38 +0000 (08:06 +0000)
committerSenthil Kumaran <orsenthil@gmail.com>
Sat, 1 May 2010 08:06:38 +0000 (08:06 +0000)
svn+ssh://pythondev@svn.python.org/python/trunk

........
  r80675 | senthil.kumaran | 2010-05-01 13:31:56 +0530 (Sat, 01 May 2010) | 3 lines

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

Lib/test/test_urllibnet.py
Lib/urllib.py

index ffb8b988910dd3195c14eda4d002aaf2c0ce85ec..b92bfc9c69f8866dba199e025ac2ce6f274cf4bd 100644 (file)
@@ -8,6 +8,7 @@ import urllib
 import sys
 import os
 import mimetools
+import time
 
 
 def _open_with_retry(func, host, *args, **kwargs):
@@ -178,6 +179,16 @@ class urlretrieveNetworkTests(unittest.TestCase):
         self.assert_(isinstance(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():
index e12d981ad026b62d12b295d1f98c4c102f40cddb..70900cd211e930148ec6bd418b488751c197b0a3 100644 (file)
@@ -592,7 +592,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':