[Python-checkins] r80675 - in python/trunk/Lib: test/test_urllibnet.py urllib.py

senthil.kumaran python-checkins at python.org
Sat May 1 10:01:56 CEST 2010


Author: senthil.kumaran
Date: Sat May  1 10:01:56 2010
New Revision: 80675

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



Modified:
   python/trunk/Lib/test/test_urllibnet.py
   python/trunk/Lib/urllib.py

Modified: python/trunk/Lib/test/test_urllibnet.py
==============================================================================
--- python/trunk/Lib/test/test_urllibnet.py	(original)
+++ python/trunk/Lib/test/test_urllibnet.py	Sat May  1 10:01:56 2010
@@ -7,6 +7,8 @@
 import urllib
 import sys
 import os
+import time
+
 mimetools = test_support.import_module("mimetools", deprecated=True)
 
 
@@ -178,6 +180,17 @@
         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():

Modified: python/trunk/Lib/urllib.py
==============================================================================
--- python/trunk/Lib/urllib.py	(original)
+++ python/trunk/Lib/urllib.py	Sat May  1 10:01:56 2010
@@ -588,7 +588,7 @@
         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':


More information about the Python-checkins mailing list