Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #93154

Re: windows and file names > 256 bytes

From Terry Reedy <tjreedy@udel.edu>
Subject Re: windows and file names > 256 bytes
Date 2015-06-25 13:03 -0400
References <mailman.44.1435219506.3674.python-list@python.org> <558bc6f1$0$11104$c3e8da3@news.astraweb.com>
Newsgroups comp.lang.python
Message-ID <mailman.73.1435251908.3674.python-list@python.org> (permalink)

Show all headers | View raw


On 6/25/2015 5:16 AM, Steven D'Aprano wrote:
> On Thursday 25 June 2015 18:00, Albert-Jan Roskam wrote:
>
>> Hi,
>>
>> Consider the following calls, where very_long_path is more than 256 bytes:
>> [1] os.mkdir(very_long_path)
>> [2] os.getsize(very_long_path)
>> [3] shutil.rmtree(very_long_path)
>>
>> I am using Python 2.7 and [1] and [2] fail under Windows XP [3] fails
>> under Win7 (not sure about XP). It throws: “WindowsError: [Error 206] The
>> filename or extension is too long”
>
> I don't think this is a bug. It seems to be a limitation of Windows.
>
> https://msdn.microsoft.com/en-
> us/library/windows/desktop/aa365247%28v=vs.85%29.aspx#maxpath
>
>> This is even when I use the "special"
>> notations \\?\c:\dir\file or \\?\UNC\server\share\file, e.g.
>> os.path.getsize("\\\\?\\" + "c:\\dir\\file")
>
> However, that may be a bug.
>
> What happens if you use a Unicode string?
>
> path = u"\\\\?\\c:a\\very\\long\\path"
> os.mkdir(path)
>
>
> Can you open an existing file?
>
> open(u"\\\\?\\c:a\\very\\long\\path\\file.txt")
>
>
>
>> (Oddly, os.path.getsize(os.path.join("\\\\?", "c:\\dir\\file")) will
>> truncate the prefix)
>
> That's worth reporting as a bug.

If possible, please try the same operations with Python 3.4 or .5 before 
making a report


-- 
Terry Jan Reedy

Back to comp.lang.python | Previous | NextPrevious in thread | Find similar | Unroll thread


Thread

windows and file names > 256 bytes Albert-Jan Roskam <sjeik_appie@hotmail.com> - 2015-06-25 08:00 +0000
  Re: windows and file names > 256 bytes Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2015-06-25 19:16 +1000
    Re: windows and file names > 256 bytes Chris Angelico <rosuav@gmail.com> - 2015-06-25 19:23 +1000
    Re: windows and file names > 256 bytes Tim Golden <mail@timgolden.me.uk> - 2015-06-25 11:10 +0100
    Re: windows and file names > 256 bytes Chris Angelico <rosuav@gmail.com> - 2015-06-25 20:23 +1000
    Re: windows and file names > 256 bytes Terry Reedy <tjreedy@udel.edu> - 2015-06-25 13:03 -0400

csiph-web