MSYS2-packages/python/920-allow-win-drives-in-os-path-isabs.patch
2020-03-02 12:44:15 +03:00

30 lines
845 B
Diff

--- a/Lib/posixpath.py 2013-11-27 06:57:57.000000000 +0000
+++ b/Lib/posixpath.py 2014-02-21 10:43:34.423932700 +0000
@@ -42,6 +42,12 @@
else:
return '/'
+def _get_altsep(path):
+ if isinstance(path, bytes):
+ return b'\\'
+ else:
+ return '\\'
+
# Normalize the case of a pathname. Trivial in Posix, string.lower on Mac.
# On MS-DOS this may also turn slashes into backslashes; however, other
# normalizations (such as optimizing '../' away) are not allowed
@@ -63,7 +69,12 @@
"""Test whether a path is absolute"""
s = os.fspath(s)
sep = _get_sep(s)
- return s.startswith(sep)
+ altsep = _get_altsep(s)
+ return s.startswith(sep) or \
+ (sys.platform == 'msys' and \
+ len(s) > 2 and \
+ s[1] == ':' and \
+ (s[2] == sep or s[2] == altsep))
# Join pathnames.