Index: Lib/urllib/request.py =================================================================== --- Lib/urllib/request.py (revision 85346) +++ Lib/urllib/request.py (working copy) @@ -1203,8 +1203,8 @@ url = req.selector if url[:2] == '//' and url[2:3] != '/' and (req.host and req.host != 'localhost'): - req.type = 'ftp' - return self.parent.open(req) + if not req.host is self.get_names(): + raise URLError("file:// scheme allowed only on localhost") else: return self.open_local_file(req) @@ -1687,7 +1687,7 @@ if not isinstance(url, str): raise URLError('file error', 'proxy support for file protocol currently not implemented') if url[:2] == '//' and url[2:3] != '/' and url[2:12].lower() != 'localhost/': - return self.open_ftp(url) + raise ValueError("file:// scheme allowed only on localhost") else: return self.open_local_file(url) Index: Lib/test/test_urllib2.py =================================================================== --- Lib/test/test_urllib2.py (revision 85346) +++ Lib/test/test_urllib2.py (working copy) @@ -731,11 +731,11 @@ # file:///blah.txt (a file) # file://ftp.example.com/blah.txt (an ftp URL) for url, ftp in [ - ("file://ftp.example.com//foo.txt", True), + ("file://ftp.example.com//foo.txt", False), ("file://ftp.example.com///foo.txt", False), # XXXX bug: fails with OSError, should be URLError ("file://ftp.example.com/foo.txt", False), - ("file://somehost//foo/something.txt", True), + ("file://somehost//foo/something.txt", False), ("file://localhost//foo/something.txt", False), ]: req = Request(url)