summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSenthil Kumaran <senthil@uthcode.com>2012-10-22 09:43:04 -0700
committerSenthil Kumaran <senthil@uthcode.com>2012-10-22 09:43:04 -0700
commit40d8078f418104e8558e72ca71484d8f3df088ce (patch)
tree15df1dbcc062bc733b9c13af75e7568197a25c10
parentefb15993f8c7788958da288cd66cf49b8afdd871 (diff)
downloadcpython-git-40d8078f418104e8558e72ca71484d8f3df088ce.tar.gz
Issue #16301: Fix the localhost verification in urllib/request.py for file://. Modify tests to use localhost for local temp files, which could make Windows Buildbot (#16300) happy
-rw-r--r--Lib/test/test_urllib.py2
-rw-r--r--Lib/urllib/request.py2
-rw-r--r--Misc/NEWS3
3 files changed, 5 insertions, 2 deletions
diff --git a/Lib/test/test_urllib.py b/Lib/test/test_urllib.py
index 85e54bff92..e2d306fc28 100644
--- a/Lib/test/test_urllib.py
+++ b/Lib/test/test_urllib.py
@@ -277,7 +277,7 @@ Content-Type: text/html; charset=iso-8859-1
def test_file_notexists(self):
fd, tmp_file = tempfile.mkstemp()
- tmp_fileurl = 'file://' + tmp_file
+ tmp_fileurl = 'file://localhost' + tmp_file
self.assertTrue(os.path.exists(tmp_file))
self.assertTrue(urlopen(tmp_fileurl))
diff --git a/Lib/urllib/request.py b/Lib/urllib/request.py
index f2ea952639..2de3b99d9c 100644
--- a/Lib/urllib/request.py
+++ b/Lib/urllib/request.py
@@ -1905,7 +1905,7 @@ class URLopener:
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
diff --git a/Misc/NEWS b/Misc/NEWS
index fd82353e54..47107b5ba4 100644
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -59,6 +59,9 @@ Core and Builtins
Library
-------
+- Issue #16301: Fix the localhost verification in urllib/request.py for file://
+ urls.
+
- Issue #16250: Fix the invocations of URLError which had misplaced filename
attribute for exception.