Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(59)

Side by Side Diff: Lib/shutil.py

Issue 21697: shutil.copytree() handles symbolic directory incorrectly
Patch Set: Created 4 years, 8 months ago
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | Lib/test/test_shutil.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 """Utility functions for copying and archiving files and directory trees. 1 """Utility functions for copying and archiving files and directory trees.
2 2
3 XXX The functions here don't copy the resource fork or other metadata on Mac. 3 XXX The functions here don't copy the resource fork or other metadata on Mac.
4 4
5 """ 5 """
6 6
7 import os 7 import os
8 import sys 8 import sys
9 import stat 9 import stat
10 import fnmatch 10 import fnmatch
(...skipping 309 matching lines...) Expand 10 before | Expand all | Expand 10 after
320 # We can't just leave it to `copy_function` because legacy 320 # We can't just leave it to `copy_function` because legacy
321 # code with a custom `copy_function` may rely on copytree 321 # code with a custom `copy_function` may rely on copytree
322 # doing the right thing. 322 # doing the right thing.
323 os.symlink(linkto, dstname) 323 os.symlink(linkto, dstname)
324 copystat(srcname, dstname, follow_symlinks=not symlinks) 324 copystat(srcname, dstname, follow_symlinks=not symlinks)
325 else: 325 else:
326 # ignore dangling symlink if the flag is on 326 # ignore dangling symlink if the flag is on
327 if not os.path.exists(linkto) and ignore_dangling_symlinks: 327 if not os.path.exists(linkto) and ignore_dangling_symlinks:
328 continue 328 continue
329 # otherwise let the copy occurs. copy2 will raise an error 329 # otherwise let the copy occurs. copy2 will raise an error
330 copy_function(srcname, dstname) 330 if os.path.isdir(srcname):
331 copytree(srcname, dstname, symlinks, ignore,
332 copy_function)
333 else:
334 copy_function(srcname, dstname)
331 elif os.path.isdir(srcname): 335 elif os.path.isdir(srcname):
332 copytree(srcname, dstname, symlinks, ignore, copy_function) 336 copytree(srcname, dstname, symlinks, ignore, copy_function)
333 else: 337 else:
334 # Will raise a SpecialFileError for unsupported file types 338 # Will raise a SpecialFileError for unsupported file types
335 copy_function(srcname, dstname) 339 copy_function(srcname, dstname)
336 # catch the Error from the recursive copytree so that we can 340 # catch the Error from the recursive copytree so that we can
337 # continue with other files 341 # continue with other files
338 except Error as err: 342 except Error as err:
339 errors.extend(err.args[0]) 343 errors.extend(err.args[0])
340 except OSError as why: 344 except OSError as why:
(...skipping 778 matching lines...) Expand 10 before | Expand all | Expand 10 after
1119 seen = set() 1123 seen = set()
1120 for dir in path: 1124 for dir in path:
1121 normdir = os.path.normcase(dir) 1125 normdir = os.path.normcase(dir)
1122 if not normdir in seen: 1126 if not normdir in seen:
1123 seen.add(normdir) 1127 seen.add(normdir)
1124 for thefile in files: 1128 for thefile in files:
1125 name = os.path.join(dir, thefile) 1129 name = os.path.join(dir, thefile)
1126 if _access_check(name, mode): 1130 if _access_check(name, mode):
1127 return name 1131 return name
1128 return None 1132 return None
OLDNEW
« no previous file with comments | « no previous file | Lib/test/test_shutil.py » ('j') | no next file with comments »

RSS Feeds Recent Issues | This issue
This is Rietveld 894c83f36cb7+