]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
Issue13104 - Fix urllib.request.thishost() utility function.
authorSenthil Kumaran <senthil@uthcode.com>
Wed, 5 Oct 2011 16:32:02 +0000 (00:32 +0800)
committerSenthil Kumaran <senthil@uthcode.com>
Wed, 5 Oct 2011 16:32:02 +0000 (00:32 +0800)
Lib/test/test_urllib.py
Lib/urllib/request.py

index c6dae1710e499621562cb138e9e8a9299babb1e6..8055dc20fe523a11a50a28907887b2ad5167c519 100644 (file)
@@ -1058,6 +1058,10 @@ class Utility_Tests(unittest.TestCase):
         self.assertEqual(('user', 'a\vb'),urllib.parse.splitpasswd('user:a\vb'))
         self.assertEqual(('user', 'a:b'),urllib.parse.splitpasswd('user:a:b'))
 
+    def test_thishost(self):
+        """Test the urllib.request.thishost utility function returns a tuple"""
+        self.assertIsInstance(urllib.request.thishost(), tuple)
+
 
 class URLopener_Tests(unittest.TestCase):
     """Testcase to test the open method of URLopener class."""
index 773025a09b3a22c05576cc6a2e59e563bc7e6c10..d3b5c29cbb705f3e0b4d8e9f162208903fe0aa9a 100644 (file)
@@ -2116,7 +2116,7 @@ def thishost():
     """Return the IP addresses of the current host."""
     global _thishost
     if _thishost is None:
-        _thishost = tuple(socket.gethostbyname_ex(socket.gethostname()[2]))
+        _thishost = tuple(socket.gethostbyname_ex(socket.gethostname())[2])
     return _thishost
 
 _ftperrors = None