[Python-checkins] r82780 - in python/branches/py3k/Lib: test/test_urllib2.py urllib/request.py
senthil.kumaran
python-checkins at python.org
Sun Jul 11 05:12:43 CEST 2010
Author: senthil.kumaran
Date: Sun Jul 11 05:12:43 2010
New Revision: 82780
Log:
Stricter verification for file based url scheme and reliance on ftp protocol.
Modified:
python/branches/py3k/Lib/test/test_urllib2.py
python/branches/py3k/Lib/urllib/request.py
Modified: python/branches/py3k/Lib/test/test_urllib2.py
==============================================================================
--- python/branches/py3k/Lib/test/test_urllib2.py (original)
+++ python/branches/py3k/Lib/test/test_urllib2.py Sun Jul 11 05:12:43 2010
@@ -731,6 +731,8 @@
("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://localhost//foo/something.txt", False),
]:
req = Request(url)
try:
@@ -741,6 +743,7 @@
else:
self.assertTrue(o.req is req)
self.assertEqual(req.type, "ftp")
+ self.assertEqual(req.type is "ftp", ftp)
def test_http(self):
Modified: python/branches/py3k/Lib/urllib/request.py
==============================================================================
--- python/branches/py3k/Lib/urllib/request.py (original)
+++ python/branches/py3k/Lib/urllib/request.py Sun Jul 11 05:12:43 2010
@@ -1188,7 +1188,8 @@
# Use local file or FTP depending on form of URL
def file_open(self, req):
url = req.selector
- if url[:2] == '//' and url[2:3] != '/':
+ if url[:2] == '//' and url[2:3] != '/' and (req.host and
+ req.host != 'localhost'):
req.type = 'ftp'
return self.parent.open(req)
else:
More information about the Python-checkins
mailing list