[New-bugs-announce] [issue35951] os.renames() creates directories if original name doesn't exist

Chris Jerdonek report at bugs.python.org
Sat Feb 9 12:10:42 EST 2019


New submission from Chris Jerdonek <chris.jerdonek at gmail.com>:

os.renames() creates and leaves behind the intermediate directories if the original (source) path doesn't exist.

>>> import os
>>> os.mkdir('temp')
>>> os.mkdir('temp/test')
>>> os.renames('temp/not-exists', 'temp/test2/test3/test4')
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/.../3.6.5/lib/python3.6/os.py", line 267, in renames
    rename(old, new)
FileNotFoundError: [Errno 2] No such file or directory: 'temp/not-exists' -> 'temp/test2/test3/test4'
>>> os.listdir('temp/test2')
['test3']
>>> os.listdir('temp/test2/test3')
[]

----------
components: Library (Lib)
messages: 335134
nosy: chris.jerdonek
priority: normal
severity: normal
status: open
title: os.renames() creates directories if original name doesn't exist
type: behavior
versions: Python 3.6

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue35951>
_______________________________________


More information about the New-bugs-announce mailing list