Skip to content

Commit e06f920

Browse files
authored
bpo-40982: shutil docs: Remove outdated copytree() example (GH-24778)
It is not preferable to keep a copy of the implementation in the docs.
1 parent 772d808 commit e06f920

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
@@ -476,42 +476,7 @@ file then shutil will silently fallback on using less efficient
476476
copytree example
477477
~~~~~~~~~~~~~~~~
478478

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

516481
from shutil import copytree, ignore_patterns
517482

0 commit comments

Comments
 (0)