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

senthil.kumaran python-checkins at python.org
Sun Dec 27 11:13:40 CET 2009


Author: senthil.kumaran
Date: Sun Dec 27 11:13:39 2009
New Revision: 77060

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


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	Sun Dec 27 11:13:39 2009
@@ -1190,8 +1190,9 @@
     def get_names(self):
         if FileHandler.names is None:
             try:
-                FileHandler.names = (socket.gethostbyname('localhost'),
-                                    socket.gethostbyname(socket.gethostname()))
+                FileHandler.names = tuple(
+                    socket.gethostbyname_ex('localhost')[2] +
+                    socket.gethostbyname_ex(socket.gethostname())[2])
             except socket.gaierror:
                 FileHandler.names = (socket.gethostbyname('localhost'),)
         return FileHandler.names
@@ -1688,7 +1689,7 @@
             return addinfourl(open(localname, 'rb'), headers, urlfile)
         host, port = splitport(host)
         if (not port
-           and socket.gethostbyname(host) in (localhost(), thishost())):
+           and socket.gethostbyname(host) in (localhost() + thishost())):
             urlfile = file
             if file[:1] == '/':
                 urlfile = 'file://' + file
@@ -1998,10 +1999,10 @@
 
 _thishost = None
 def thishost():
-    """Return the IP address of the current host."""
+    """Return the IP addresses of the current host."""
     global _thishost
     if _thishost is None:
-        _thishost = socket.gethostbyname(socket.gethostname())
+        _thishost = tuple(socket.gethostbyname_ex(socket.gethostname()[2]))
     return _thishost
 
 _ftperrors = None


More information about the Python-checkins mailing list