summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSenthil Kumaran <orsenthil@gmail.com>2010-05-08 05:03:45 (GMT)
committerSenthil Kumaran <orsenthil@gmail.com>2010-05-08 05:03:45 (GMT)
commita9a9f696d5b6ff5e80173412c3c00b056fcf58b6 (patch)
tree6718e47d148ee24de7d529794980157bed1678ad
parent2add184b2d84a802593c1230e80a2b6766291db1 (diff)
downloadcpython-a9a9f696d5b6ff5e80173412c3c00b056fcf58b6.zip
cpython-a9a9f696d5b6ff5e80173412c3c00b056fcf58b6.tar.gz
cpython-a9a9f696d5b6ff5e80173412c3c00b056fcf58b6.tar.bz2
Merged revisions 80957 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk ........ r80957 | senthil.kumaran | 2010-05-08 10:30:11 +0530 (Sat, 08 May 2010) | 2 lines Fixing the errors trigerred in test_urllib2net. Related to issue8656. ........
-rw-r--r--Lib/urllib2.py13
1 files changed, 8 insertions, 5 deletions
diff --git a/Lib/urllib2.py b/Lib/urllib2.py
index 58ef625..2429689 100644
--- a/Lib/urllib2.py
+++ b/Lib/urllib2.py
@@ -1273,13 +1273,13 @@ class FileHandler(BaseHandler):
import email.utils
import mimetypes
host = req.get_host()
- file = req.get_selector()
- localfile = url2pathname(file)
+ filename = req.get_selector()
+ localfile = url2pathname(filename)
try:
stats = os.stat(localfile)
size = stats.st_size
modified = email.utils.formatdate(stats.st_mtime, usegmt=True)
- mtype = mimetypes.guess_type(file)[0]
+ mtype = mimetypes.guess_type(filename)[0]
headers = mimetools.Message(StringIO(
'Content-type: %s\nContent-length: %d\nLast-modified: %s\n' %
(mtype or 'text/plain', size, modified)))
@@ -1287,8 +1287,11 @@ class FileHandler(BaseHandler):
host, port = splitport(host)
if not host or \
(not port and socket.gethostbyname(host) in self.get_names()):
- return addinfourl(open(localfile, 'rb'),
- headers, 'file://'+ host + file)
+ if host:
+ origurl = 'file://' + host + filename
+ else:
+ origurl = 'file://' + filename
+ return addinfourl(open(localfile, 'rb'), headers, origurl)
except OSError, msg:
# urllib2 users shouldn't expect OSErrors coming from urlopen()
raise URLError(msg)