diff --git a/Lib/pathlib.py b/Lib/pathlib.py index 9db8ae2d8a389e..1b03755c9c472d 100644 --- a/Lib/pathlib.py +++ b/Lib/pathlib.py @@ -187,7 +187,7 @@ def compile_pattern(self, pattern): def resolve(self, path, strict=False): s = str(path) if not s: - return os.getcwd() + return path._accessor.getcwd() previous_s = None if _getfinalpathname is not None: if strict: @@ -352,7 +352,7 @@ def _resolve(path, rest): return path # NOTE: according to POSIX, getcwd() cannot contain path components # which are symlinks. - base = '' if path.is_absolute() else os.getcwd() + base = '' if path.is_absolute() else accessor.getcwd() return _resolve(base, str(path)) or sep def is_reserved(self, parts): @@ -469,6 +469,8 @@ def group(self, path): except ImportError: raise NotImplementedError("Path.group() is unsupported on this system") + getcwd = os.getcwd + _normal_accessor = _NormalAccessor() @@ -1104,7 +1106,7 @@ def cwd(cls): """Return a new path pointing to the current working directory (as returned by os.getcwd()). """ - return cls(os.getcwd()) + return cls(cls()._accessor.getcwd()) @classmethod def home(cls): @@ -1173,7 +1175,7 @@ def absolute(self): return self # FIXME this must defer to the specific flavour (and, under Windows, # use nt._getfullpathname()) - return self._from_parts([os.getcwd()] + self._parts) + return self._from_parts([self._accessor.getcwd()] + self._parts) def resolve(self, strict=False): """