From 1b7da519b09d8885272d323af982d36675419075 Mon Sep 17 00:00:00 2001 From: Senthil Kumaran Date: Thu, 6 Oct 2011 00:32:02 +0800 Subject: Issue13104 - Fix urllib.request.thishost() utility function. --- Lib/test/test_urllib.py | 4 ++++ Lib/urllib/request.py | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/Lib/test/test_urllib.py b/Lib/test/test_urllib.py index c6dae17..8055dc2 100644 --- a/Lib/test/test_urllib.py +++ b/Lib/test/test_urllib.py @@ -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.""" diff --git a/Lib/urllib/request.py b/Lib/urllib/request.py index 773025a..d3b5c29 100644 --- a/Lib/urllib/request.py +++ b/Lib/urllib/request.py @@ -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 -- cgit v0.12