Fix some cases where self.openedurl wasn't set.

This commit is contained in:
Guido van Rossum 1996-10-10 16:01:16 +00:00
parent b5fa1cb855
commit b030bc026e
1 changed files with 3 additions and 2 deletions

View File

@ -254,12 +254,13 @@ class URLopener:
# Use local file
def open_local_file(self, url):
host, file = splithost(url)
if not host: return addinfourl(open(url2pathname(file), 'r'), noheaders(), self.openedurl)
if not host:
return addinfourl(open(url2pathname(file), 'r'), noheaders(), 'file:'+file)
host, port = splitport(host)
if not port and socket.gethostbyname(host) in (
localhost(), thishost()):
file = unquote(file)
return addinfourl(open(url2pathname(file), 'r'), noheaders(), self.openedurl)
return addinfourl(open(url2pathname(file), 'r'), noheaders(), 'file:'+file)
raise IOError, ('local file error', 'not on local host')
# Use FTP protocol