mirror of
https://github.com/python/cpython.git
synced 2025-11-20 02:50:14 +00:00
Get the urllib tests to pass without the email package
This commit is contained in:
parent
0337ef62fa
commit
fce59bf72a
2 changed files with 24 additions and 4 deletions
|
|
@ -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' %
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue