[issue1076515] shutil.move clobbers read-only files.

R. David Murray report at bugs.python.org
Sun Mar 10 21:32:37 CET 2013


R. David Murray added the comment:

Since I spent some time thinking about this, I want to leave some notes:

The linux 'mv' command issues the following prompt:

  > mv t2/myfile t1
  mv: try to overwrite ‘t1/myfile’, overriding mode 0000 (---------)?

So modern linux, at least, will not overwrite the file unless the '-f' flag is given explicitly (or you answer yes to the prompt, but that's not relevant to shutil.move).

However, shutil.move does not claim to implement 'mv'.  The release note in 3.3 indicates we've adapted its symlink handling to mimic mv, but the rest of the text is explicit about the implementation *in terms of other stdlib functions*.

So really the only way to understand the behavior of shutil.move is to understand what those other functions do on your platform.  The OP's confusion had to do with the behavior of *the Unix file system* in the face of a rename operation, not with the definition of shutil.move itself (which says that it uses rename, and links to its description).

Someone could think through the description of 'rename' and open an issue to improve *its* documentation if that seems warranted, but I think that "has permission" is somewhat platform dependent and so it probably isn't appropriate to change that doc, either.

Thus, I agree that this should be closed.

----------
nosy: +r.david.murray
resolution: rejected -> invalid
stage:  -> committed/rejected

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue1076515>
_______________________________________


More information about the Python-bugs-list mailing list