On Fri, 12 Apr 2013 19:42:25 +0200 Ralf Schmitt <r...@systemexit.de> wrote: > Guido van Rossum <gu...@python.org> writes: > > > Actually, I've heard of code that dynamically falls back on short > > names when paths using long names exceed the system limit for path > > length (either 256 or 1024 IIRC). But short names pretty much require > > consulting the filesystem, so we can probably ignore them. > > The limit is 260 characters. But longer paths can be handled by > prepending \\?\ and using the unicode APIs. > > see http://msdn.microsoft.com/en-us/library/aa365247.aspx#maxpath
Indeed. I thought I might use them by default in pathlib but there are other pains: notably, extended paths (those starting with \\?\) can only be absolute. So pathlib supports *passing* them explicitly (kind of, there are very few tests for them) but it doesn't constructs them implicitly. (as Dirkjan pointed out, Mercurial also has domain-specific code to handle Windows paths quirks; this is where I took the idea of having a is_reserved() method for NUL, CON, etc.) Regards Antoine. > > we have the following code to handle the above insanity: > ,---- > | def prepend_magic_win32(path): > | assert isinstance(path, unicode), "path must be of type unicode" > | > | if path.startswith(u"\\\\"): > | if path.startswith(u"\\\\?\\"): > | return path > | else: > | return u"\\\\?\\UNC\\" + path[2:] > | else: > | return u"\\\\?\\" + path > `---- > _______________________________________________ Python-Dev mailing list Python-Dev@python.org http://mail.python.org/mailman/listinfo/python-dev Unsubscribe: http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com