From 87d129a801c126f340273256dd355f6b5cd32763 Mon Sep 17 00:00:00 2001 From: Tzu-ping Chung Date: Tue, 1 Sep 2020 15:37:10 +0800 Subject: [PATCH] Replace custom URL parsing with url_to_path() --- src/pip/_internal/req/req_file.py | 16 ++-------------- 1 file changed, 2 insertions(+), 14 deletions(-) diff --git a/src/pip/_internal/req/req_file.py b/src/pip/_internal/req/req_file.py index 72a568bdf..c8d7a0a5a 100644 --- a/src/pip/_internal/req/req_file.py +++ b/src/pip/_internal/req/req_file.py @@ -21,7 +21,7 @@ from pip._internal.models.search_scope import SearchScope from pip._internal.network.utils import raise_for_status from pip._internal.utils.encoding import auto_decode from pip._internal.utils.typing import MYPY_CHECK_RUNNING -from pip._internal.utils.urls import get_url_scheme +from pip._internal.utils.urls import get_url_scheme, url_to_path if MYPY_CHECK_RUNNING: from optparse import Values @@ -572,16 +572,7 @@ def get_file_content(url, session, comes_from=None): 'Requirements file {} references URL {}, ' 'which is local'.format(comes_from, url) ) - - path = url.split(':', 1)[1] - path = path.replace('\\', '/') - match = _url_slash_drive_re.match(path) - if match: - path = match.group(1) + ':' + path.split('|', 1)[1] - path = urllib_parse.unquote(path) - if path.startswith('/'): - path = '/' + path.lstrip('/') - url = path + url = url_to_path(url) try: with open(url, 'rb') as f: @@ -591,6 +582,3 @@ def get_file_content(url, session, comes_from=None): 'Could not open requirements file: {}'.format(exc) ) return url, content - - -_url_slash_drive_re = re.compile(r'/*([a-z])\|', re.I)