ChrisDenton · GitHub

Python has to append \\* to the path before calling FindFirstFileW. This slightly changes how paths are parsed by the OS.

I think our policy of "as close to the OS behaviour as is portable" still applies here, but because we're the ones appending \\* to the path for scandir, trimming spaces first isn't unreasonable. I'd rather use an API that doesn't involve us modifying the path, but if that doesn't exist, then we don't have a lot of choice.

But since the original issue was opened for "what's the general policy on this" and that's been answered, let's start a new issue specifically for scandir.

Originally posted by @zooba in #115104

To fix this, GetFullPathNameW could be used before appending \\* to the path and calling FindFirstFileW. This will create a normalized absolute path without changing the meaning of the path (as far as the OS is concerned). So it'll be consistent with other filesystem APIs.

Linked PRs

Read the original on github.com ↗