[Python-checkins] r80959 - in python/branches/py3k: Lib/urllib/request.py

senthil.kumaran python-checkins at python.org
Sat May 8 07:12:05 CEST 2010


Author: senthil.kumaran
Date: Sat May  8 07:12:05 2010
New Revision: 80959

Log:
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.
........


Modified:
   python/branches/py3k/   (props changed)
   python/branches/py3k/Lib/urllib/request.py

Modified: python/branches/py3k/Lib/urllib/request.py
==============================================================================
--- python/branches/py3k/Lib/urllib/request.py	(original)
+++ python/branches/py3k/Lib/urllib/request.py	Sat May  8 07:12:05 2010
@@ -1202,13 +1202,13 @@
         import email.utils
         import mimetypes
         host = req.host
-        file = req.selector
-        localfile = url2pathname(file)
+        filename = req.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 = email.message_from_string(
                 'Content-type: %s\nContent-length: %d\nLast-modified: %s\n' %
                 (mtype or 'text/plain', size, modified))
@@ -1216,8 +1216,11 @@
                 host, port = splitport(host)
             if not host or \
                 (not port and _safe_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 as msg:
             # users shouldn't expect OSErrors coming from urlopen()
             raise URLError(msg)


More information about the Python-checkins mailing list