Fix --windows-filenames removing / from UNIX paths

:ci skip all
This commit is contained in:
pukkandan 2021-02-25 00:02:44 +05:30
parent a17417e8ca
commit c4218ac3f1

View file

@ -2128,6 +2128,7 @@ def replace_insane(char):
def sanitize_path(s, force=False): def sanitize_path(s, force=False):
"""Sanitizes and normalizes path on Windows""" """Sanitizes and normalizes path on Windows"""
if sys.platform == 'win32': if sys.platform == 'win32':
force = False
drive_or_unc, _ = os.path.splitdrive(s) drive_or_unc, _ = os.path.splitdrive(s)
if sys.version_info < (2, 7) and not drive_or_unc: if sys.version_info < (2, 7) and not drive_or_unc:
drive_or_unc, _ = os.path.splitunc(s) drive_or_unc, _ = os.path.splitunc(s)
@ -2144,6 +2145,8 @@ def sanitize_path(s, force=False):
for path_part in norm_path] for path_part in norm_path]
if drive_or_unc: if drive_or_unc:
sanitized_path.insert(0, drive_or_unc + os.path.sep) sanitized_path.insert(0, drive_or_unc + os.path.sep)
elif force and s[0] == os.path.sep:
sanitized_path.insert(0, os.path.sep)
return os.path.join(*sanitized_path) return os.path.join(*sanitized_path)