mirror of
https://github.com/python/cpython.git
synced 2025-08-28 12:45:07 +00:00
bpo-39659: Route calls from pathlib.Path to os.getcwd() via the path accessor (GH-18834)
This commit is contained in:
parent
8aac1bea2e
commit
b05440c52b
1 changed files with 6 additions and 4 deletions
|
@ -187,7 +187,7 @@ class _WindowsFlavour(_Flavour):
|
||||||
def resolve(self, path, strict=False):
|
def resolve(self, path, strict=False):
|
||||||
s = str(path)
|
s = str(path)
|
||||||
if not s:
|
if not s:
|
||||||
return os.getcwd()
|
return path._accessor.getcwd()
|
||||||
previous_s = None
|
previous_s = None
|
||||||
if _getfinalpathname is not None:
|
if _getfinalpathname is not None:
|
||||||
if strict:
|
if strict:
|
||||||
|
@ -352,7 +352,7 @@ class _PosixFlavour(_Flavour):
|
||||||
return path
|
return path
|
||||||
# NOTE: according to POSIX, getcwd() cannot contain path components
|
# NOTE: according to POSIX, getcwd() cannot contain path components
|
||||||
# which are symlinks.
|
# 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
|
return _resolve(base, str(path)) or sep
|
||||||
|
|
||||||
def is_reserved(self, parts):
|
def is_reserved(self, parts):
|
||||||
|
@ -461,6 +461,8 @@ class _NormalAccessor(_Accessor):
|
||||||
except ImportError:
|
except ImportError:
|
||||||
raise NotImplementedError("Path.group() is unsupported on this system")
|
raise NotImplementedError("Path.group() is unsupported on this system")
|
||||||
|
|
||||||
|
getcwd = os.getcwd
|
||||||
|
|
||||||
|
|
||||||
_normal_accessor = _NormalAccessor()
|
_normal_accessor = _NormalAccessor()
|
||||||
|
|
||||||
|
@ -1096,7 +1098,7 @@ class Path(PurePath):
|
||||||
"""Return a new path pointing to the current working directory
|
"""Return a new path pointing to the current working directory
|
||||||
(as returned by os.getcwd()).
|
(as returned by os.getcwd()).
|
||||||
"""
|
"""
|
||||||
return cls(os.getcwd())
|
return cls(cls()._accessor.getcwd())
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def home(cls):
|
def home(cls):
|
||||||
|
@ -1165,7 +1167,7 @@ class Path(PurePath):
|
||||||
return self
|
return self
|
||||||
# FIXME this must defer to the specific flavour (and, under Windows,
|
# FIXME this must defer to the specific flavour (and, under Windows,
|
||||||
# use nt._getfullpathname())
|
# 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):
|
def resolve(self, strict=False):
|
||||||
"""
|
"""
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue