]> granicus.if.org Git - python/commitdiff
Get the urllib tests to pass without the email package
authorNeal Norwitz <nnorwitz@gmail.com>
Sat, 25 Aug 2007 19:00:31 +0000 (19:00 +0000)
committerNeal Norwitz <nnorwitz@gmail.com>
Sat, 25 Aug 2007 19:00:31 +0000 (19:00 +0000)
Lib/urllib.py
Lib/urllib2.py

index 3ecfea7c0d04d52b33c24fb35c15cb37f9c56cc1..bbcd00e21d43fb099e7d9aaaba1c25c109cc40dc 100644 (file)
@@ -403,7 +403,7 @@ class URLopener:
 
     def open_local_file(self, url):
         """Use local file."""
-        import mimetypes, mimetools, email.utils
+        import mimetypes, mimetools #, email.utils
         from io import StringIO
         host, file = splithost(url)
         localname = url2pathname(file)
@@ -412,7 +412,17 @@ class URLopener:
         except OSError as e:
             raise IOError(e.errno, e.strerror, e.filename)
         size = stats.st_size
-        modified = email.utils.formatdate(stats.st_mtime, usegmt=True)
+        # XXX(nnorwitz): inline formatdate until it is restored.
+        #modified = email.utils.formatdate(stats.st_mtime, usegmt=True)
+        now, zone = time.gmtime(stats.st_mtime), 'GMT'
+        modified = '%s, %02d %s %04d %02d:%02d:%02d %s' % (
+            ['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun'][now[6]],
+            now[2],
+            ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun',
+             'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'][now[1] - 1],
+            now[0], now[3], now[4], now[5],
+            zone)
+
         mtype = mimetypes.guess_type(url)[0]
         headers = mimetools.Message(StringIO(
             'Content-Type: %s\nContent-Length: %d\nLast-modified: %s\n' %
index 448f2a82614915f746ff062ae8bd00fa228883c5..658bc3dc7aabe4f58620a8228552af44936511db 100644 (file)
@@ -1201,7 +1201,7 @@ class FileHandler(BaseHandler):
 
     # not entirely sure what the rules are here
     def open_local_file(self, req):
-        import email.utils
+        #import email.utils
         import mimetypes
         host = req.get_host()
         file = req.get_selector()
@@ -1209,7 +1209,17 @@ class FileHandler(BaseHandler):
         try:
             stats = os.stat(localfile)
             size = stats.st_size
-            modified = email.utils.formatdate(stats.st_mtime, usegmt=True)
+            #modified = email.utils.formatdate(stats.st_mtime, usegmt=True)
+            # XXX(nnorwitz): inline formatdate until it is restored.
+            now, zone = time.gmtime(stats.st_mtime), 'GMT'
+            modified = '%s, %02d %s %04d %02d:%02d:%02d %s' % (
+        ['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun'][now[6]],
+        now[2],
+        ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun',
+         'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'][now[1] - 1],
+        now[0], now[3], now[4], now[5],
+        zone)
+
             mtype = mimetypes.guess_type(file)[0]
             headers = mimetools.Message(StringIO(
                 'Content-type: %s\nContent-length: %d\nLast-modified: %s\n' %