This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author steve.dower
Recipients brett.cannon, paul.moore, steve.dower, tim.golden, zach.ware
Date 2016-08-10.23:20:13
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1470871213.85.0.785050173072.issue27730@psf.upfronthosting.co.za>
In-reply-to
Content
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 the 260th character and split the path into two parts (path1 and path2)
* use CreateFile to get a handle to path1, then GetFinalPathNameByHandle to get a normalized npath1 (which will have the '\\?\' prefix)
* split path2 by '/' and '\' characters, trim leading and trailing spaces from each segment, trim trailing dots from each segment, and append them to npath1 separated by '\' characters
* use this normalized path instead of path

It's a relatively expensive operation, but it is the most reliable way to normalize a path. The place where it'll fall down is that trimming spaces and trailing dots and replacing '/' with '\' is not guaranteed to be the only processing that is done. However, it should solve 99% of cases which is better than the 0% that currently work.
History
Date User Action Args
2016-08-10 23:20:13steve.dowersetrecipients: + steve.dower, brett.cannon, paul.moore, tim.golden, zach.ware
2016-08-10 23:20:13steve.dowersetmessageid: <1470871213.85.0.785050173072.issue27730@psf.upfronthosting.co.za>
2016-08-10 23:20:13steve.dowerlinkissue27730 messages
2016-08-10 23:20:13steve.dowercreate