[New-bugs-announce] [issue37506] os.mkdir creates invalid folder when path string has trailing space and slash
Holly
report at bugs.python.org
Fri Jul 5 10:01:48 EDT 2019
New submission from Holly <hollyrobertsgb at gmail.com>:
If we use os.mkdir to create a folder as follows:
os.mkdir("C:/test /")
Then we successfully create a folder with name "test ". This folder can be accessed normally, but it cannot be renamed or deleted. Instead we get the following error message:
Could not find this item
This is no longer located in C:\. Verify the item's location and try again.
I used Python 3.7.3 (64 bit) and Windows 1809
Obviously this is down to how windows doesn't handle paths particularly nicely, so it's not really python's fault. However even if it's decided that python shouldn't handle this then it would be better for an exception to be thrown rather than creating a corrupt folder.
Note: We can delete the folder by using the Long UNC path, eg. rd "\\?\C:\test "
----------
components: IO
messages: 347346
nosy: hollyroberts
priority: normal
severity: normal
status: open
title: os.mkdir creates invalid folder when path string has trailing space and slash
type: behavior
versions: Python 3.7
_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue37506>
_______________________________________
More information about the New-bugs-announce
mailing list