better directory-ness checking for file: scheme index URLs

This commit is contained in:
Carl Meyer 2010-05-27 12:36:40 -04:00
parent 5618ec1634
commit 1734bf0d6c
6 changed files with 7 additions and 3 deletions

View File

@ -386,8 +386,8 @@ class HTMLPage(object):
logger.debug('Getting page %s' % url)
# Tack index.html onto file:// URLs that point to directories
# normcase helpfully translates path separators for us on Windows
if url.startswith('file://') and os.path.isdir(os.path.normcase(url[7:])):
(scheme, netloc, path, params, query, fragment) = urlparse.urlparse(url)
if scheme == 'file' and os.path.isdir(urllib.url2pathname(path)):
url = urllib.basejoin(url, 'index.html')
resp = urlopen(url)

2
tests/in dex/README.txt Normal file
View File

@ -0,0 +1,2 @@
This directory has the odd space in its name in order to test urlquoting and
dequoting of file:// scheme index URLs.

View File

@ -1,7 +1,9 @@
import urllib2
from test_pip import here, reset_env, run_pip, pyversion
from path import Path
index_url = 'file://' + str(Path(here).abspath/'index').replace('\\', '/')
index_url = 'file://' + urllib2.quote(str(Path(here).abspath/'in dex').replace('\\', '/'))
def test_install():
"""