[issue1577] shutil.move() does not use os.rename() if dst is a directory

Ingemar Nilsson report at bugs.python.org
Mon Dec 10 00:23:25 CET 2007


New submission from Ingemar Nilsson:

If you use shutil.move(src, dst) to move a file src to a directory dst,
the file will not be renamed into the dst directory, but rather
copied-then-removed, even if src and dst is on the same filesystem.
There are several ways to fix this:

* (The easiest) Fix the documentation for shutil.move() so that this is
mentioned.
* Fix shutil.move() so that it rename a file into a new directory.
* Change os.rename() to accept a directory as a destination for a file.

The reason for this problem is that shutil.move() tries to use
os.rename(), but fails since the destination is a directory. It then
proceeds to the copy-then-remove method, even though the documentation
gives the impression that this only happens when src and dst are on
different filesystems.

----------
components: Library (Lib)
messages: 58332
nosy: init
severity: normal
status: open
title: shutil.move() does not use os.rename() if dst is a directory
type: behavior
versions: Python 2.5

__________________________________
Tracker <report at bugs.python.org>
<http://bugs.python.org/issue1577>
__________________________________


More information about the Python-bugs-list mailing list