mirror of
https://github.com/python/cpython.git
synced 2025-12-04 16:43:27 +00:00
Merged revisions 77058 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk ........ r77058 | senthil.kumaran | 2009-12-27 14:41:09 +0530 (Sun, 27 Dec 2009) | 4 lines Fix for issue5625 - test_urllib2 fails - urlopen error file not on local host. This is on hosts with multiple ip addresses. ........
This commit is contained in:
parent
54ad07e999
commit
99b2c8f811
1 changed files with 6 additions and 5 deletions
|
|
@ -1190,8 +1190,9 @@ class FileHandler(BaseHandler):
|
||||||
def get_names(self):
|
def get_names(self):
|
||||||
if FileHandler.names is None:
|
if FileHandler.names is None:
|
||||||
try:
|
try:
|
||||||
FileHandler.names = (socket.gethostbyname('localhost'),
|
FileHandler.names = tuple(
|
||||||
socket.gethostbyname(socket.gethostname()))
|
socket.gethostbyname_ex('localhost')[2] +
|
||||||
|
socket.gethostbyname_ex(socket.gethostname())[2])
|
||||||
except socket.gaierror:
|
except socket.gaierror:
|
||||||
FileHandler.names = (socket.gethostbyname('localhost'),)
|
FileHandler.names = (socket.gethostbyname('localhost'),)
|
||||||
return FileHandler.names
|
return FileHandler.names
|
||||||
|
|
@ -1688,7 +1689,7 @@ class URLopener:
|
||||||
return addinfourl(open(localname, 'rb'), headers, urlfile)
|
return addinfourl(open(localname, 'rb'), headers, urlfile)
|
||||||
host, port = splitport(host)
|
host, port = splitport(host)
|
||||||
if (not port
|
if (not port
|
||||||
and socket.gethostbyname(host) in (localhost(), thishost())):
|
and socket.gethostbyname(host) in (localhost() + thishost())):
|
||||||
urlfile = file
|
urlfile = file
|
||||||
if file[:1] == '/':
|
if file[:1] == '/':
|
||||||
urlfile = 'file://' + file
|
urlfile = 'file://' + file
|
||||||
|
|
@ -1998,10 +1999,10 @@ def localhost():
|
||||||
|
|
||||||
_thishost = None
|
_thishost = None
|
||||||
def thishost():
|
def thishost():
|
||||||
"""Return the IP address of the current host."""
|
"""Return the IP addresses of the current host."""
|
||||||
global _thishost
|
global _thishost
|
||||||
if _thishost is None:
|
if _thishost is None:
|
||||||
_thishost = socket.gethostbyname(socket.gethostname())
|
_thishost = tuple(socket.gethostbyname_ex(socket.gethostname()[2]))
|
||||||
return _thishost
|
return _thishost
|
||||||
|
|
||||||
_ftperrors = None
|
_ftperrors = None
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue