[New-bugs-announce] [issue16278] os.rename documentation slightly inaccurate

David Benjamin report at bugs.python.org
Thu Oct 18 19:36:16 CEST 2012


New submission from David Benjamin:

This is somewhat of a nitpick. os.rename's documentation says "If dst is a directory, OSError will be raised". On Unix, this isn't completely true. If the source is a directory and the destination is an empty directory, it'll overwrite the former with the latter. (Actually if the source is a directory the inverse is true; if dst is a file, OSError will be raised.)

In [1]: import os

In [2]: os.mkdir("aaa")

In [3]: open("aaa/blah", "w").close()

In [4]: os.mkdir("bbb")

In [5]: os.rename("aaa", "bbb")

In [6]: os.listdir("bbb")
Out[6]: ['blah']

----------
assignee: docs at python
components: Documentation
messages: 173285
nosy: David.Benjamin, docs at python
priority: normal
severity: normal
status: open
title: os.rename documentation slightly inaccurate
type: enhancement
versions: Python 2.7, Python 3.4, Python 3.5

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


More information about the New-bugs-announce mailing list