This issue tracker has been migrated to GitHub ,
and is currently read-only.
For more information,
see the GitHub FAQs in the Python's Developer Guide.
Created on 2014年11月24日 17:10 by newbie, last changed 2022年04月11日 14:58 by admin. This issue is now closed.
| Files | ||||
|---|---|---|---|---|
| File name | Uploaded | Description | Edit | |
| shutil_2.7.patch | Mike.Short, 2015年03月22日 01:54 | review | ||
| shutil_latest.patch | Mike.Short, 2015年03月22日 01:54 | review | ||
| Messages (3) | |||
|---|---|---|---|
| msg231612 - (view) | Author: newbie (newbie) | Date: 2014年11月24日 17:10 | |
First sentence of 3rd paragraph of 10.10. "shutil" documentation for shutil.move command, "The destination directory must not already exist", is misleading and contradicts other information in the entry. I took it to mean that if dst did not exist, python would create it as a directory. What actually happens is that python renames src to dst. In my test, I was moving several files to a new directory, and the result was a file with the pathname dst and contents matching the last move command, consistent with the behavior described in the rest of the paragraph and the following one. When I changed the code to create the directory with os.mkdirs before calling shutil.move, it worked as I wanted, so obviously there's nothing wrong with the destination directory already existing. The preceding paragraph implies this with its description of behavior when dst refers to a directory. I suggest removing this sentence, and maybe adding some text indicating what to do if you want to move a file to a new directory. I was using Python 2.7.5 on Windows, and branch 2.7.8 of the documentation (there does not appear to be a branch 2.7.5 available.) |
|||
| msg231616 - (view) | Author: R. David Murray (r.david.murray) * (Python committer) | Date: 2014年11月24日 18:32 | |
I think you are correct that that sentence should just be deleted. The preceding sentence should start "If the destination is an existing directory..." I also wonder if shutil should be changed to use os.replace, but that is a separate issue. |
|||
| msg238899 - (view) | Author: Roundup Robot (python-dev) (Python triager) | Date: 2015年03月22日 14:15 | |
New changeset e5de4ee6aa4a by Benjamin Peterson in branch '3.4': clarify behavior of shutil.move when destination exists (closes #22933) https://hg.python.org/cpython/rev/e5de4ee6aa4a New changeset 4502e598fe26 by Benjamin Peterson in branch '2.7': clarify behavior of shutil.move when destination exists (closes #22933) https://hg.python.org/cpython/rev/4502e598fe26 New changeset a9f36ec5d944 by Benjamin Peterson in branch 'default': merge 3.4 (#22933) https://hg.python.org/cpython/rev/a9f36ec5d944 |
|||
| History | |||
|---|---|---|---|
| Date | User | Action | Args |
| 2022年04月11日 14:58:10 | admin | set | github: 67122 |
| 2015年03月22日 14:15:19 | python-dev | set | status: open -> closed nosy: + python-dev messages: + msg238899 resolution: fixed stage: needs patch -> resolved |
| 2015年03月22日 01:54:26 | Mike.Short | set | files: + shutil_latest.patch |
| 2015年03月22日 01:54:08 | Mike.Short | set | files:
+ shutil_2.7.patch keywords: + patch |
| 2015年03月04日 02:41:43 | berker.peksag | set | nosy:
+ berker.peksag |
| 2015年03月02日 08:31:44 | ezio.melotti | set | keywords:
+ easy stage: needs patch |
| 2014年11月24日 18:32:31 | r.david.murray | set | nosy:
+ r.david.murray messages: + msg231616 versions: + Python 3.4, Python 3.5 |
| 2014年11月24日 17:10:36 | newbie | create | |