Skip to content

Commit ab0f447

Browse files
committed
Address review feedback.
1 parent 4bcc143 commit ab0f447

2 files changed

Lines changed: 13 additions & 9 deletions

File tree

Doc/whatsnew/3.14.rst

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -103,13 +103,15 @@ os
103103
pathlib
104104
-------
105105

106-
* Add :meth:`pathlib.Path.copy`, which copies the content of one file to
107-
another, like :func:`shutil.copyfile`.
108-
(Contributed by Barney Gale in :gh:`73991`.)
109-
* Add :meth:`pathlib.Path.copytree`, which copies one directory tree to
110-
another.
111-
(Contributed by Barney Gale in :gh:`73991`.)
112-
* Add :meth:`pathlib.Path.rmtree`, which recursively removes a directory.
106+
* Add methods to :class:`pathlib.Path` to recursively copy or remove files:
107+
108+
* :meth:`~pathlib.Path.copy` copies the content of one file to another, like
109+
:func:`shutil.copyfile`.
110+
* :meth:`~pathlib.Path.copytree` copies one directory tree to another, like
111+
:func:`shutil.copytree`.
112+
* :meth:`~pathlib.Path.rmtree` recursively removes a directory tree, like
113+
:func:`shutil.rmtree`.
114+
113115
(Contributed by Barney Gale in :gh:`73991`.)
114116

115117
symtable

Lib/pathlib/_abc.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -912,11 +912,13 @@ def on_error(err):
912912
def on_error(err):
913913
raise err
914914
try:
915-
if self.is_symlink() or self.is_junction():
915+
if self.is_symlink():
916916
raise OSError("Cannot call rmtree on a symbolic link")
917+
elif self.is_junction():
918+
raise OSError("Cannot call rmtree on a junction")
917919
results = self.walk(
918920
on_error=on_error,
919-
top_down=False,
921+
top_down=False, # Bottom-up so we rmdir() empty directories.
920922
follow_symlinks=False)
921923
for dirpath, dirnames, filenames in results:
922924
for name in filenames:

0 commit comments

Comments
 (0)