MSYS2-packages/python/920-allow-win-drives-in-os-path-isabs.patch
Christoph Reiter 2b65957fb9 python: pretend to be cygwin in more places
The main change here is that sys.platform == 'cygwin', which allows
us to drop various changes for extending cygwin checks. Fewer patches
and less likely that we miss to patch a new cygwin check on updates.

If one really needs to check for msys Python then this still works:

sysconfig.get_platform().startswith("msys")
2021-05-11 22:57:55 +02:00

30 lines
847 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 == 'cygwin' and \
+ len(s) > 2 and \
+ s[1] == ':' and \
+ (s[2] == sep or s[2] == altsep))
# Join pathnames.