1
1
Fork 0
mirror of https://github.com/pypa/pip synced 2023-12-13 21:30:23 +01:00
pip/news/10115.bugfix.rst
Tzu-ping Chung f6b184ccaf
Strip slash before Windows drive letter in path (#10116)
Functions like urllib.parse.urlsplit() parses a file:// URL created from
a non-UNC Windows absolute path with a leading slash in the path
component:

>>> from pathlib import Path
>>> from urllib.parse import urlsplit
>>> path = Path("C:/Users/VssAdministrator")
>>> parsed = urlsplit(path.as_posix())
>>> parsed.path
'/C:/Users/VssAdministrator'

This value unfortunately does not play well with path functions like
open(), so we performs some additional cleanup to strip that leading
slash.

This commit also contains some minor cleanup to unify how Windows is
detected, and how a file:// URL is fetched.
2021-07-22 15:28:43 +08:00

4 lines
216 B
ReStructuredText

Strip leading slash from a ``file://`` URL built from an path with the Windows
drive notation. This fixes bugs where the ``file://`` URL cannot be correctly
used as requirement, constraint, or index URLs on Windows.