fix: use Windows-aware isabs for native paths under patched _IS_WINDOWS

Follow-up for salvaged PR #26790: on a POSIX host with _IS_WINDOWS
patched (test simulation), os.path.isabs rejects C:\Users\x and the
new relative-cwd recovery would mangle a perfectly absolute native
Windows path. Check ntpath.isabs first on the Windows branch.
This commit is contained in:
Teknium 2026-07-16 01:00:57 -07:00
parent 5458c76566
commit 5330b2cfad

View file

@ -63,6 +63,12 @@ def _resolve_local_initial_cwd(cwd: str) -> str:
expanded = os.path.expanduser(cwd) if cwd else os.getcwd()
if _IS_WINDOWS:
expanded = _msys_to_windows_path(expanded)
# Use the Windows-aware check explicitly: when _IS_WINDOWS is
# patched in tests on a POSIX host, os.path.isabs would reject
# ``C:\Users\x`` and mangle it through the relative branch.
import ntpath
if ntpath.isabs(expanded):
return expanded
if os.path.isabs(expanded):
return expanded