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.

classification
Title: Wrong OSError message from os.rename() when dst is a non-empty directory
Type: behavior Stage:
Components: Library (Lib) Versions: Python 3.4
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: Nosy List: doko, jderose, jwilk, mitya57, vstinner
Priority: normal Keywords:

Created on 2013-12-29 00:50 by jderose, last changed 2022-04-11 14:57 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
test_os_rename.py jderose, 2013-12-29 00:50 Test case
Messages (3)
msg207058 - (view) Author: Jason Gerard DeRose (jderose) Date: 2013-12-29 00:50
Under Python 3.3, if renaming a directory with `os.rename()` when the destination is an existing, non-empty directory, like this:

os.rename('/tmp/foo', '/tmp/bar')

You'll get an OSError with a message like this:

OSError: [Errno 39] Directory not empty: '/tmp/bar'

However, in the current Python 3.4.0b1 package in Ubuntu Trusty, this error message will contain the source directory name instead of the destination directory name, like this:

OSError: [Errno 39] Directory not empty: '/tmp/foo'

I've attached a test case, which also covers renaming directories relative to an open directory descriptor. This test case works on Python 3.3, fails on Python 3.4 Beta1.
msg207077 - (view) Author: Dmitry Shachnev (mitya57) * Date: 2013-12-29 15:20
This is a result of http://hg.python.org/cpython/rev/6903f5214e99.

Looks like we should check the error code and conditionally set the file name to either src or dst.
msg224072 - (view) Author: Matthias Klose (doko) * (Python committer) Date: 2014-07-26 16:18
3.4.0 has this fixed. resolutions in http://bugs.python.org/issue16074 and http://bugs.python.org/issue20517
History
Date User Action Args
2022-04-11 14:57:56adminsetgithub: 64292
2014-07-26 16:18:39dokosetstatus: open -> closed

nosy: + doko
messages: + msg224072

resolution: fixed
2014-01-02 12:41:35jwilksetnosy: + jwilk
2013-12-29 15:20:29mitya57setnosy: + vstinner, mitya57
messages: + msg207077
2013-12-29 00:50:27jderosecreate