[issue10684] Folders get deleted when trying to change case with shutil.move (case insensitive file systems only)

Ronald Oussoren report at bugs.python.org
Mon Mar 14 20:31:08 CET 2011


Ronald Oussoren <ronaldoussoren at mac.com> added the comment:

The fallback to copy+remove happens because shutil.move first checks if the destination exists and is a directory, if so it moves the source into the destination, that is, given:

os.mkdir('foo')
os.mkdir('bar')

Then ``shutil.move('foo', 'bar')`` is the same as ``shutil.move('foo', 'bar/foo')``.

On filesystems that are case insensitive this triggers for ``shutil.move('foo', 'FOO')`` as wel, causing a call to ``os.rename('foo', 'FOO/foo')`` and that fails because you cannot move a folder inside itself.

The attached patch makes the test unconditional (as it should pass always when the filesystem is case sensitive) and checks if src and dst are the same when dst is a directory, in that case os.rename is called and we never try to copy.

----------
Added file: http://bugs.python.org/file21129/issue10684-py33.patch

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


More information about the Python-bugs-list mailing list