[Python-checkins] cpython: Issue #16301: Fix the localhost verification in urllib/request.py for file://.
senthil.kumaran
python-checkins at python.org
Mon Oct 22 18:43:51 CEST 2012
http://hg.python.org/cpython/rev/49de26395d1a
changeset: 79896:49de26395d1a
user: Senthil Kumaran <senthil at uthcode.com>
date: Mon Oct 22 09:43:04 2012 -0700
summary:
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
files:
Lib/test/test_urllib.py | 2 +-
Lib/urllib/request.py | 2 +-
Misc/NEWS | 3 +++
3 files changed, 5 insertions(+), 2 deletions(-)
diff --git a/Lib/test/test_urllib.py b/Lib/test/test_urllib.py
--- a/Lib/test/test_urllib.py
+++ b/Lib/test/test_urllib.py
@@ -277,7 +277,7 @@
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
--- a/Lib/urllib/request.py
+++ b/Lib/urllib/request.py
@@ -1905,7 +1905,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
diff --git a/Misc/NEWS b/Misc/NEWS
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -59,6 +59,9 @@
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.
--
Repository URL: http://hg.python.org/cpython
More information about the Python-checkins
mailing list