File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 103103pathlib
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
115117symtable
Original file line number Diff line number Diff 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 :
You can’t perform that action at this time.
0 commit comments