Skip to content

Commit 857cf55

Browse files
bpo-40982: shutil docs: Remove outdated copytree() example (GH-24778)
It is not preferable to keep a copy of the implementation in the docs. (cherry picked from commit e06f920) Co-authored-by: Zackery Spytz <zspytz@gmail.com>
1 parent 97151e1 commit 857cf55

File tree

1 file changed

+1
-36
lines changed

1 file changed

+1
-36
lines changed

Doc/library/shutil.rst

Lines changed: 1 addition & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -470,42 +470,7 @@ file then shutil will silently fallback on using less efficient
470470
copytree example
471471
~~~~~~~~~~~~~~~~
472472

473-
This example is the implementation of the :func:`copytree` function, described
474-
above, with the docstring omitted. It demonstrates many of the other functions
475-
provided by this module. ::
476-
477-
def copytree(src, dst, symlinks=False):
478-
names = os.listdir(src)
479-
os.makedirs(dst)
480-
errors = []
481-
for name in names:
482-
srcname = os.path.join(src, name)
483-
dstname = os.path.join(dst, name)
484-
try:
485-
if symlinks and os.path.islink(srcname):
486-
linkto = os.readlink(srcname)
487-
os.symlink(linkto, dstname)
488-
elif os.path.isdir(srcname):
489-
copytree(srcname, dstname, symlinks)
490-
else:
491-
copy2(srcname, dstname)
492-
# XXX What about devices, sockets etc.?
493-
except OSError as why:
494-
errors.append((srcname, dstname, str(why)))
495-
# catch the Error from the recursive copytree so that we can
496-
# continue with other files
497-
except Error as err:
498-
errors.extend(err.args[0])
499-
try:
500-
copystat(src, dst)
501-
except OSError as why:
502-
# can't copy file access times on Windows
503-
if why.winerror is None:
504-
errors.extend((src, dst, str(why)))
505-
if errors:
506-
raise Error(errors)
507-
508-
Another example that uses the :func:`ignore_patterns` helper::
473+
An example that uses the :func:`ignore_patterns` helper::
509474

510475
from shutil import copytree, ignore_patterns
511476

0 commit comments

Comments
 (0)