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:
Barney Gale 2022-01-28 23:40:55 +00:00 committed by GitHub
parent 1f036ede59
commit 18cb2ef46c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 78 additions and 11 deletions

View file

@ -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):