mirror of
https://github.com/python/cpython.git
synced 2025-08-31 05:58:33 +00:00
bpo-29688: document and test pathlib.Path.absolute()
(GH-26153)
Co-authored-by: Brett Cannon <brett@python.org> Co-authored-by: Brian Helba <brian.helba@kitware.com>
This commit is contained in:
parent
1f036ede59
commit
18cb2ef46c
4 changed files with 78 additions and 11 deletions
|
@ -1043,24 +1043,19 @@ class Path(PurePath):
|
|||
yield p
|
||||
|
||||
def absolute(self):
|
||||
"""Return an absolute version of this path. This function works
|
||||
even if the path doesn't point to anything.
|
||||
"""Return an absolute version of this path by prepending the current
|
||||
working directory. No normalization or symlink resolution is performed.
|
||||
|
||||
No normalization is done, i.e. all '.' and '..' will be kept along.
|
||||
Use resolve() to get the canonical path to a file.
|
||||
"""
|
||||
# XXX untested yet!
|
||||
if self.is_absolute():
|
||||
return self
|
||||
# FIXME this must defer to the specific flavour (and, under Windows,
|
||||
# use nt._getfullpathname())
|
||||
return self._from_parts([self._accessor.getcwd()] + self._parts)
|
||||
|
||||
def resolve(self, strict=False):
|
||||
"""
|
||||
Make the path absolute, resolving all symlinks on the way and also
|
||||
normalizing it (for example turning slashes into backslashes under
|
||||
Windows).
|
||||
normalizing it.
|
||||
"""
|
||||
|
||||
def check_eloop(e):
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue