Skip to content

Commit 8663855

Browse files
authored
Merge pull request #8830 from uranusjr/env-var-req-file
Replace custom URL parsing with url_to_path()
2 parents 35d321f + 87d129a commit 8663855

File tree

1 file changed

+2
-14
lines changed

1 file changed

+2
-14
lines changed

src/pip/_internal/req/req_file.py

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
from pip._internal.network.utils import raise_for_status
2222
from pip._internal.utils.encoding import auto_decode
2323
from pip._internal.utils.typing import MYPY_CHECK_RUNNING
24-
from pip._internal.utils.urls import get_url_scheme
24+
from pip._internal.utils.urls import get_url_scheme, url_to_path
2525

2626
if MYPY_CHECK_RUNNING:
2727
from optparse import Values
@@ -572,16 +572,7 @@ def get_file_content(url, session, comes_from=None):
572572
'Requirements file {} references URL {}, '
573573
'which is local'.format(comes_from, url)
574574
)
575-
576-
path = url.split(':', 1)[1]
577-
path = path.replace('\\', '/')
578-
match = _url_slash_drive_re.match(path)
579-
if match:
580-
path = match.group(1) + ':' + path.split('|', 1)[1]
581-
path = urllib_parse.unquote(path)
582-
if path.startswith('/'):
583-
path = '/' + path.lstrip('/')
584-
url = path
575+
url = url_to_path(url)
585576

586577
try:
587578
with open(url, 'rb') as f:
@@ -591,6 +582,3 @@ def get_file_content(url, session, comes_from=None):
591582
'Could not open requirements file: {}'.format(exc)
592583
)
593584
return url, content
594-
595-
596-
_url_slash_drive_re = re.compile(r'/*([a-z])\|', re.I)

0 commit comments

Comments
 (0)