mirror of
https://github.com/python/cpython.git
synced 2025-08-09 19:38:42 +00:00
GH-127381: pathlib ABCs: remove PathBase.cwd()
and home()
(#127427)
These classmethods presume that the user has retained the original `__init__()` signature, which may not be the case. Also, many virtual filesystems don't provide current or home directories.
This commit is contained in:
parent
4e0a4cafe8
commit
328187cc4f
3 changed files with 17 additions and 17 deletions
|
@ -735,27 +735,12 @@ class PathBase(PurePathBase):
|
|||
# Treat the root directory as the current working directory.
|
||||
return self.with_segments('/', *self._raw_paths)
|
||||
|
||||
@classmethod
|
||||
def cwd(cls):
|
||||
"""Return a new path pointing to the current working directory."""
|
||||
# We call 'absolute()' rather than using 'os.getcwd()' directly to
|
||||
# enable users to replace the implementation of 'absolute()' in a
|
||||
# subclass and benefit from the new behaviour here. This works because
|
||||
# os.path.abspath('.') == os.getcwd().
|
||||
return cls().absolute()
|
||||
|
||||
def expanduser(self):
|
||||
""" Return a new path with expanded ~ and ~user constructs
|
||||
(as returned by os.path.expanduser)
|
||||
"""
|
||||
raise UnsupportedOperation(self._unsupported_msg('expanduser()'))
|
||||
|
||||
@classmethod
|
||||
def home(cls):
|
||||
"""Return a new path pointing to expanduser('~').
|
||||
"""
|
||||
return cls("~").expanduser()
|
||||
|
||||
def readlink(self):
|
||||
"""
|
||||
Return the path to which the symbolic link points.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue