--- shutil.py.old 2006-02-25 22:16:52.000000000 -0600 +++ shutil.py 2006-02-25 23:06:35.000000000 -0600 @@ -75,23 +75,48 @@ The destination may be a directory. + If copying the file succeeds but copying the mode fails, no error + is reported. + """ if os.path.isdir(dst): dst = os.path.join(dst, os.path.basename(src)) copyfile(src, dst) - copymode(src, dst) + try: copymode(src, dst) + except OSError, err: + trace = sys.exc_info()[2] + try: + from errno import EACCES, EPERM + except ImportError: + raise OSError, err, trace + else: + if err.errno not in [EACCES, EPERM]: + raise OSerror, err, trace + else: return True def copy2(src, dst): """Copy data and all stat info ("cp -p src dst"). The destination may be a directory. + If copying the file succeeds but copying the mode fails, no error + is reported. + """ if os.path.isdir(dst): dst = os.path.join(dst, os.path.basename(src)) copyfile(src, dst) - copystat(src, dst) - + try: copystat(src, dst) + except OSError, err: + trace = sys.exc_info()[2] + try: + from errno import EACCES, EPERM + except ImportError: + raise OSError, err, trace + else: + if err.errno not in [EACCES, EPERM]: + raise OSerror, err, trace + else: return True def copytree(src, dst, symlinks=False): """Recursively copy a directory tree using copy2().