Skip to content

Commit cb7d43c

Browse files
Merge heads
2 parents 17f5f81 + bc07ac5 commit cb7d43c

File tree

2 files changed

+3
-2
lines changed

2 files changed

+3
-2
lines changed

Lib/test/test_urllib2.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -678,7 +678,7 @@ def connect_ftp(self, user, passwd, host, port, dirs,
678678
self.assertEqual(int(headers["Content-length"]), len(data))
679679

680680
def test_file(self):
681-
import email.utils, socket
681+
import email.utils
682682
h = urllib.request.FileHandler()
683683
o = h.parent = MockOpener()
684684

@@ -725,6 +725,7 @@ def test_file(self):
725725
for url in [
726726
"file://localhost:80%s" % urlpath,
727727
"file:///file_does_not_exist.txt",
728+
"file://not-a-local-host.com//dir/file.txt",
728729
"file://%s:80%s/%s" % (socket.gethostbyname('localhost'),
729730
os.getcwd(), TESTFN),
730731
"file://somerandomhost.ontheinternet.com%s/%s" %

Lib/urllib/request.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1315,7 +1315,7 @@ def file_open(self, req):
13151315
url = req.selector
13161316
if url[:2] == '//' and url[2:3] != '/' and (req.host and
13171317
req.host != 'localhost'):
1318-
if not req.host is self.get_names():
1318+
if not req.host in self.get_names():
13191319
raise URLError("file:// scheme is supported only on localhost")
13201320
else:
13211321
return self.open_local_file(req)

0 commit comments

Comments
 (0)