Path: csiph.com!usenet.pasdenom.info!weretis.net!feeder1.news.weretis.net!feeder.erje.net!eu.feeder.erje.net!newsfeed.freenet.ag!news2.euro.net!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; 'exception': 0.03; 'interpreter': 0.04; 'that?': 0.05; 'filenames': 0.07; 'shutil': 0.07; 'tests,': 0.07; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'terry': 0.09; '3.3,': 0.16; 'experiment.': 0.16; 'generate,': 0.16; 'idle,': 0.16; 'received:80.91.229.3': 0.16; 'received:plane.gmane.org': 0.16; 'reedy': 0.16; 'wrote:': 0.17; 'char': 0.17; 'unicode': 0.17; 'jan': 0.18; '>>>': 0.18; '(or': 0.18; 'error.': 0.21; '"",': 0.22; 'errors': 0.23; 'pass': 0.25; 'header:In-Reply-To:1': 0.25; 'header:User-Agent:1': 0.26; 'creating': 0.26; '(most': 0.27; 'header:X-Complaints-To:1': 0.28; "skip:' 10": 0.30; 'error': 0.30; 'figure': 0.30; 'file': 0.32; 'certain': 0.33; 'traceback': 0.33; 'to:addr:python-list': 0.33; "can't": 0.34; 'open': 0.35; 'doing': 0.35; 'pm,': 0.35; 'there': 0.35; 'received:org': 0.36; 'but': 0.36; 'subject:with': 0.36; 'should': 0.36; 'bad': 0.37; 'does': 0.37; 'well.': 0.37; 'subject:: ': 0.38; 'skip:o 20': 0.38; 'some': 0.38; 'to:addr:python.org': 0.39; 'header:Received:5': 0.40; 'think': 0.40; 'directory:': 0.84; 'received:fios.verizon.net': 0.84 X-Injected-Via-Gmane: http://gmane.org/ To: python-list@python.org From: Terry Reedy Subject: Re: Dealing with exceptions Date: Sat, 02 Mar 2013 16:23:37 -0500 References: <707df78f-9a67-4ce1-8dd3-095c75a7f7da@googlegroups.com> Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Gmane-NNTP-Posting-Host: pool-173-75-251-66.phlapa.fios.verizon.net User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:17.0) Gecko/20130215 Thunderbird/17.0.3 In-Reply-To: <707df78f-9a67-4ce1-8dd3-095c75a7f7da@googlegroups.com> X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.15 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: 26 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1362259444 news.xs4all.nl 6927 [2001:888:2000:d::a6]:56008 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:40366 On 3/2/2013 12:40 PM, bvdp wrote: > But, I know there can be other errors as well. Doing some tests, I > know that certain filenames are invalid (I think a "?" or unicode > char is invalid when writing to a FAT32 filesystem). And, so what > exception is that? Without actually creating the error, I can't > figure it out. So use the interactive interpreter (or idle, or ipython) and create the error. You should always have it open when editing. Using less time that it took you to write the above. 3.3, win7, (idle) >>> open('sdjhfjshdfkjsh') Traceback (most recent call last): File "", line 1, in open('sdjhfjshdfkjsh') FileNotFoundError: [Errno 2] No such file or directory: 'sdjhfjshdfkjsh' Now, does shutil pass on FileNotFoundError? I will let you experiment. There are error conditions that are hard to generate, but a bad file name is not one of them. -- Terry Jan Reedy