diff --git a/Doc/library/pathlib.rst b/Doc/library/pathlib.rst index ab92c142c37a4f..709e7b49632c73 100644 --- a/Doc/library/pathlib.rst +++ b/Doc/library/pathlib.rst @@ -131,10 +131,11 @@ we also call *flavours*: >>> PurePath(Path('foo'), Path('bar')) PurePosixPath('foo/bar') - When *pathsegments* is empty, the current directory is assumed:: + When *pathsegments* is empty or consists only of empty strings, + the current directory is assumed:: - >>> PurePath() - PurePosixPath('.') + >>> PurePath(), PurePath('') + (PurePosixPath('.'), PurePosixPath('.')) If a segment is an absolute path, all previous segments are ignored (like :func:`os.path.join`):: @@ -1040,8 +1041,8 @@ Querying file type and status .. method:: Path.exists(*, follow_symlinks=True) - Return ``True`` if the path points to an existing file or directory. - ``False`` will be returned if the path is invalid, inaccessible or missing. + Return ``True`` if the path points to an existing file or directory and + ``False`` if the path is invalid, inaccessible or missing. Use :meth:`Path.stat` to distinguish between these cases. This method normally follows symlinks; to check if a symlink exists, add @@ -1049,6 +1050,8 @@ Querying file type and status :: + >>> Path('').exists() # The current directory. + True >>> Path('.').exists() True >>> Path('setup.py').exists() diff --git a/Lib/test/test_shutil.py b/Lib/test/test_shutil.py index 06ebdf9b68f20f..a7825adf923c19 100644 --- a/Lib/test/test_shutil.py +++ b/Lib/test/test_shutil.py @@ -552,11 +552,7 @@ def raiser(fn, *args, **kwargs): os.lstat = orig_lstat def test_rmtree_uses_safe_fd_version_if_available(self): - _use_fd_functions = ({os.open, os.stat, os.unlink, os.rmdir} <= - os.supports_dir_fd and - os.listdir in os.supports_fd and - os.stat in os.supports_follow_symlinks) - if _use_fd_functions: + if shutil._use_fd_functions: self.assertTrue(shutil.rmtree.avoids_symlink_attacks) tmp_dir = self.mkdtemp() d = os.path.join(tmp_dir, 'a')