Bugs item #1438480, was opened at 2006-02-25 06:26 Message generated for change (Comment added) made by thomaswaldmann You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1438480&group_id=5470
Please note that this message will contain a full copy of the comment thread, including the initial issue submission, for this request, not just the latest update. Category: Python Library Group: Python 2.4 Status: Open Resolution: None Priority: 5 Private: No Submitted By: Joe Wreschnig (piman) Assigned to: Nobody/Anonymous (nobody) Summary: shutil.move raises OSError when copystat fails Initial Comment: If you are on a Linux system, and shutil.move a file from anywhere onto a partition where you have write permission but are not the owner, os.utime will fail with an EPERM OSError. This can (and did) happen moving a file on a vfat partition mounted with umask=0000, so every user had read/write/execute but all files were owned by root. This happens in shutil.copystat, so shutil.move doesn't remove the old file. The resulting error code (OSError, EPERM) is not distinguishable from several other permission errors that can happen during shutil.move, even though a failure to set a utime is not fatal for most move operations (mv(1) succeeds, for example). I would suggest either ignoring an EPERM from copystat, or catching it in shutil.copy2 and raising a more specific exception so that it can be easily distinguished from genuine failure due to permissions. ---------------------------------------------------------------------- Comment By: Thomas Waldmann (thomaswaldmann) Date: 2007-03-24 19:51 Message: Logged In: YES user_id=100649 Originator: NO See also http://sourceforge.net/tracker/index.php?func=detail&aid=1666318&group_id=5470&atid=105470 for a similar problem with copystat. ---------------------------------------------------------------------- Comment By: Joe Wreschnig (piman) Date: 2006-02-26 06:08 Message: Logged In: YES user_id=796 The attached patch causes shutil.copy and shutil.copy2 (and so copytree, and move) to ignore EACCES and EPERM from copymode and copystat respectively. Other errors are reraised with the original traceback. Any error copying the file, rather than the metadata, is still considered fatal. User calls to copymode and copystat still fail as before. Justification: On Linux, utime(2) says the distinction between EACCES and EPERM is blurry and "Linux is not careful to distinguish between the EACCES and EPERM" so the patch ignores both. In my opinion, anyone wanting to deal with low-level details like mtimes and modes is probably not using shutil, so ignoring is better than a new exception (which would just result in complicated new code, and surprise old code). It's also easy for a caller to check if the mode/utimes were copied, if it's important to them. ---------------------------------------------------------------------- You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1438480&group_id=5470 _______________________________________________ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com