[New-bugs-announce] [issue24154] pathlib.Path.rename moves file to Path.cwd() when argument is a string

Yuri Teixeira report at bugs.python.org
Sun May 10 03:37:48 CEST 2015


New submission from Yuri Teixeira:

from pathlib import Path
p = Path('/any/folder')
f = p / 'oldname'
f.rename('newname')

The above will rename the file 'oldname' to 'newname' but will also
move it to Path.cwd()

I thought that pathlib.Path.rename() when fed with a string would
change f.name only. I certainly did not expect the file to move. My
hypothesis is that a new Path('newname') is being created and used to
move the file so it that goes to Path.cwd() with the new name but I
don't know anything. Please disregard if this is working as intended.

The docs do not mention this behavior:
https://docs.python.org/3/library/pathlib.html#pathlib.Path.rename

I'm using Python 3.4.3 on Debian testing.

----------
components: Library (Lib)
messages: 242847
nosy: yurit
priority: normal
severity: normal
status: open
title: pathlib.Path.rename moves file to Path.cwd() when argument is a string
type: behavior
versions: Python 3.4

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


More information about the New-bugs-announce mailing list