Path: csiph.com!usenet.pasdenom.info!news.redatomik.org!newsfeed.xs4all.nl!newsfeed8.news.xs4all.nl!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.000 X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'from:addr:yahoo.co.uk': 0.05; 'paths': 0.05; 'skip:\\ 20': 0.05; 'filename': 0.07; 'skip:\\ 10': 0.07; 'subject:file': 0.07; 'url:msdn': 0.07; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'truncate': 0.09; 'bug': 0.10; 'python': 0.11; '2.7': 0.13; '09:00,': 0.16; 'notations': 0.16; 'received:80.91.229.3': 0.16; 'received:plane.gmane.org': 0.16; 'silly': 0.16; 'subject:windows': 0.16; 'url:85)': 0.16; 'win7': 0.16; 'xp?': 0.16; 'wrote:': 0.16; 'python?': 0.18; 'language': 0.19; '(not': 0.20; 'windows': 0.20; 'extension': 0.20; 'lawrence': 0.22; 'questions:': 0.22; 'header:In-Reply-To:1': 0.24; 'header:User- Agent:1': 0.26; 'header:X-Complaints-To:1': 0.26; '[2]': 0.27; 'e.g.': 0.31; '[1]': 0.32; 'language.': 0.32; 'file': 0.34; 'to:addr:python-list': 0.35; 'fail': 0.35; 'skip:o 20': 0.35; 'too': 0.36; 'limitation': 0.36; 'url:library': 0.36; 'hi,': 0.37; 'should': 0.37; 'subject:: ': 0.37; 'received:org': 0.38; 'url:microsoft': 0.39; 'to:addr:python.org': 0.39; 'sure': 0.40; 'where': 0.40; 'mark': 0.40; 'why': 0.40; 'even': 0.61; 'more': 0.62; 'details': 0.63; 'our': 0.64; 'skip:\xe2 10': 0.70; '[error': 0.84; 'calls,': 0.84; 'prefix)': 0.84; 'pythonistas,': 0.84; 'dealt': 0.91; 'url:en-gb': 0.91 X-Injected-Via-Gmane: http://gmane.org/ To: python-list@python.org From: Mark Lawrence Subject: Re: windows and file names > 256 bytes Date: Thu, 25 Jun 2015 12:06:34 +0100 References: Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit X-Gmane-NNTP-Posting-Host: host-78-147-25-150.as13285.net User-Agent: Mozilla/5.0 (Windows NT 6.3; WOW64; rv:31.0) Gecko/20100101 Thunderbird/31.7.0 In-Reply-To: X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.20+ Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 34 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1435230406 news.xs4all.nl 2877 [2001:888:2000:d::a6]:50214 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:93134 On 25/06/2015 09: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” 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") > (Oddly, os.path.getsize(os.path.join("\\\\?", "c:\\dir\\file")) will > truncate the prefix) > > My questions: > 1. How can I get the file size of very long paths under XP? Please see https://msdn.microsoft.com/en-gb/library/windows/desktop/aa365247(v=vs.85).aspx#maxpath > 2. Is this a bug in Python? I would prefer if Python dealt with the gory > details of Windows' silly behavior. I don't see why Python should work around any particular limitation of any given OS. -- My fellow Pythonistas, ask not what our language can do for you, ask what you can do for our language. Mark Lawrence