Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replace custom URL parsing with url_to_path() #8830

Merged
merged 1 commit into from
Sep 8, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 2 additions & 14 deletions src/pip/_internal/req/req_file.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
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
Expand Down Expand Up @@ -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:
Expand All @@ -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)