Eryk Sun added the comment:
I overlooked some aspects of the problem:
* A short relative path may end up exceeding MAX_PATH when normalized as a
fully qualified path.
* The working directory may be a UNC path or may already have the \\?\ prefix.
It's not thread-safe to check this beforehand.
*
Steve Dower added the comment:
I thought I'd tested GetFullPathNameW and seen the limit kick in at 260, but if
that's not actually the case (across all platforms we support) then yes, let's
use that.
When I reread the documentation yesterday it didn't guarantee the result would
include the pr
Eryk Sun added the comment:
Standard users have SeChangeNotifyPrivilege, which allows traversing a
directory that they can't access, so Python should only work with paths as
strings instead of trying to open a directory handle.
I think it's best to make Windows do as much of the normalization
Steve Dower added the comment:
Issue #27731 will resolve this for the latest versions of Windows 10, but if we
want to support this for earlier versions of Windows here's the algorithm I'd
suggest:
* if len(path) < 260 - we're good, don't do anything
* get the last '\' or '/' character before
New submission from Brett Cannon:
It would be nice to have a place in the stdlib that can work with long file
names on Windows no matter what. shutils seems like a possibly reasonable place.
--
components: Windows
messages: 272384
nosy: brett.cannon, paul.moore, steve.dower, tim.golden,