-
-
Notifications
You must be signed in to change notification settings - Fork 32.5k
Description
Bug report
Bug description:
>>> import os
>>> os.path.exists("test")
False
>>> os.path.exists("test ")
False
>>> os.mkdir("test ")
>>> os.path.exists("test")
True
>>> os.path.exists("test ")
True
The explorer also shows the created directory as test
, i.e. without trailing spaces.
The win32 docs say about trailing spaces
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.
One could discuss whether this is user-responsibility, but silently dropping trailing spaces feels wrong. Either create the directory (though not recommended), or raise if there is a space at the end.
Note: Behaviour gets even more weird when combining trailing spaces with alternate data streams, e.g. "test : foo" (matplotlib/matplotlib#27748), which brought me here. But before going into this more difficult discussion, I'd like to learn the general position on handling trailings spaces in windows filenames.
CPython versions tested on:
3.12
Operating systems tested on:
Windows