New submission from David Strobach <laloc...@gmail.com>:
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, st_uid=0, st_gid=0, st_size=8192, st_atime=1586154685, st_mtime=1586154685, st_ctime=1377178576) >>> os.stat("c:\\Program Files\\ ") os.stat_result(st_mode=16749, st_ino=281474976710717, st_dev=173025906, st_nlink=1, st_uid=0, st_gid=0, st_size=8192, st_atime=1586154685, st_mtime=1586154685, st_ctime=1377178576) >>> # consequently >>> os.path.isdir("c:\\Program Files\\ ") True >>> os.path.isdir("c:\\Program Files ") True >>> os.scandir("c:\\Program Files ") Traceback (most recent call last): File "<stdin>", line 1, in <module> FileNotFoundError: [WinError 3] The system cannot find the path specified: 'c:\\Program Files ' The same also applies to regular files, not just directories. ---------- components: Library (Lib), Windows messages: 366054 nosy: David Strobach, paul.moore, steve.dower, tim.golden, zach.ware priority: normal severity: normal status: open title: os.stat() on Windows succeeds for nonexistent paths with trailing spaces type: behavior versions: Python 3.6, Python 3.7, Python 3.8 _______________________________________ Python tracker <rep...@bugs.python.org> <https://bugs.python.org/issue40238> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com