[issue40238] os.stat() on Windows succeeds for nonexistent paths with trailing spaces

2020-04-10 Thread Eryk Sun
Eryk Sun added the comment: > I'd say os.path.normpath() should perform the same (GetFullPathNameW?) > normalization as os.stat() and friends do. ntpath.abspath calls GetFullPathNameW (i.e. nt._getfullpathname) in Windows, but ntpath.normpath is pure Python. I agree that normpath should trim

[issue40238] os.stat() on Windows succeeds for nonexistent paths with trailing spaces

2020-04-10 Thread David Strobach
David Strobach added the comment: Hi Eryk, thanks for your time and for the explanation. > The Windows file API normalizes paths to replace forward slashes with > backslashes; resolve relative paths and "." and ".." components; strip > trailing spaces and dots from the final component; and m

[issue40238] os.stat() on Windows succeeds for nonexistent paths with trailing spaces

2020-04-10 Thread Eryk Sun
Eryk Sun added the comment: > While I agree that Windows is safe to transform paths as he wishes to, > the bug reported here is that os.stat/os.path.isdir behaves > differently than os.scandir. Can we make them behave the same? os.listdir and os.scandir can be modified to behave like os.stat

[issue40238] os.stat() on Windows succeeds for nonexistent paths with trailing spaces

2020-04-10 Thread gaborbernat
gaborbernat added the comment: While I agree that Windows is safe to transform paths as he wishes to, the bug reported here is that os.stat/os.path.isdir behaves differently than os.scandir. Can we make them behave the same? -- nosy: +gaborbernat

[issue40238] os.stat() on Windows succeeds for nonexistent paths with trailing spaces

2020-04-09 Thread Eryk Sun
Eryk Sun added the comment: > os.stat() seems to be striping significant trailing spaces off > the path argument The Windows file API normalizes paths to replace forward slashes with backslashes; resolve relative paths and "." and ".." components; strip trailing spaces and dots from the fin

[issue40238] os.stat() on Windows succeeds for nonexistent paths with trailing spaces

2020-04-09 Thread Karthikeyan Singaravelan
Change by Karthikeyan Singaravelan : -- nosy: +eryksun ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscribe: https:

[issue40238] os.stat() on Windows succeeds for nonexistent paths with trailing spaces

2020-04-09 Thread David Strobach
New submission from David Strobach : On Windows (Server 2012 R2 in my case) os.stat() seems to be striping significant trailing spaces off the path argument: >>> import os >>> os.stat("c:\\Program Files ") os.stat_result(st_mode=16749, st_ino=281474976710717, st_dev=173025906, st_nlink=1,