diff options
author | Barney Gale <barney.gale@gmail.com> | 2021-04-07 16:31:49 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-04-07 16:31:49 (GMT) |
commit | b05440c52b9814dbd47f679d47367e87855bd7b5 (patch) | |
tree | a725c4f21bcf73c411fcebc46e568ff936904733 /Lib/pathlib.py | |
parent | 8aac1bea2eeac25a49f8912b67aacbedf9bc7934 (diff) | |
download | cpython-b05440c52b9814dbd47f679d47367e87855bd7b5.zip cpython-b05440c52b9814dbd47f679d47367e87855bd7b5.tar.gz cpython-b05440c52b9814dbd47f679d47367e87855bd7b5.tar.bz2 |
bpo-39659: Route calls from pathlib.Path to os.getcwd() via the path accessor (GH-18834)
Diffstat (limited to 'Lib/pathlib.py')
-rw-r--r-- | Lib/pathlib.py | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/Lib/pathlib.py b/Lib/pathlib.py index 6838fea..9e682dc 100644 --- a/Lib/pathlib.py +++ b/Lib/pathlib.py @@ -187,7 +187,7 @@ class _WindowsFlavour(_Flavour): 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 @@ class _PosixFlavour(_Flavour): 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): @@ -461,6 +461,8 @@ class _NormalAccessor(_Accessor): except ImportError: raise NotImplementedError("Path.group() is unsupported on this system") + getcwd = os.getcwd + _normal_accessor = _NormalAccessor() @@ -1096,7 +1098,7 @@ class Path(PurePath): """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): @@ -1165,7 +1167,7 @@ class Path(PurePath): 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): """ |