[issue37506] os.mkdir creates invalid folder when path string has trailing space and slash

2019-07-05 Thread Steve Dower


Steve Dower  added the comment:

Yeah, I'd rather not do this level of validation in Python.

If Windows decides to reject or automatically correct this, fine, but Python is 
just being a thin layer over the operating system here. We shouldn't try and 
prevent things that the OS allows.

--
resolution:  -> rejected
stage:  -> resolved
status: open -> closed

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue37506] os.mkdir creates invalid folder when path string has trailing space and slash

2019-07-05 Thread Steven D'Aprano


Steven D'Aprano  added the comment:

> it would be better for an exception to be thrown rather than creating a 
> corrupt folder.

I am not convinced that Python should refuse to create a perfectly valid 
directory because some components of Windows sometimes have trouble resolving 
the pathname under some circumstances.

Microsoft say:

"Do not end a file or directory name with a space or a period. Although the 
underlying file system may support such names, the Windows shell and user 
interface does not."

https://docs.microsoft.com/en-us/windows/win32/fileio/naming-a-file#naming_conventions

but Python is talking to the file system, not the shell or Windows Explorer.

This is a common problem, with numerous solutions:

https://superuser.com/questions/198256/how-to-delete-a-folder-containing-trailing-spaces

It's apparently quite common in shared environments where (for example) Mac 
users may copy files ending with a space onto Windows drives.

--
components: +Windows
nosy: +paul.moore, steve.dower, steven.daprano, tim.golden, zach.ware

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue37506] os.mkdir creates invalid folder when path string has trailing space and slash

2019-07-05 Thread Holly


New submission from Holly :

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 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com