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.008 X-Spam-Evidence: '*H*': 0.98; '*S*': 0.00; 'filename': 0.07; 'shutil': 0.07; 'argument:': 0.09; 'be:': 0.09; 'terry': 0.09; 'yeah,': 0.09; 'experiment.': 0.16; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 'generate,': 0.16; 'oserror:': 0.16; 'reedy': 0.16; 'wrote:': 0.17; '>>>': 0.18; 'file.': 0.20; '"",': 0.22; 'permitted': 0.22; 'pass': 0.25; 'header:In-Reply- To:1': 0.25; '(most': 0.27; 'am,': 0.27; 'message- id:@mail.gmail.com': 0.27; "doesn't": 0.28; 'chris': 0.28; '>>>>': 0.29; "skip:' 10": 0.30; 'error': 0.30; 'file': 0.32; 'message.': 0.33; 'traceback': 0.33; 'to:addr:python-list': 0.33; 'received:google.com': 0.34; 'pm,': 0.35; 'received:209.85.220': 0.35; 'too.': 0.35; 'received:209.85': 0.35; 'there': 0.35; 'but': 0.36; "didn't": 0.36; 'subject:with': 0.36; 'should': 0.36; 'bad': 0.37; 'does': 0.37; 'received:209': 0.37; 'subject:: ': 0.38; 'skip:o 20': 0.38; 'description': 0.39; 'gives': 0.39; 'to:addr:python.org': 0.39; 'different': 0.63; '2013': 0.84; 'directory:': 0.84; 'respectable': 0.84; 'technique': 0.93 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:x-received:in-reply-to:references:date:message-id :subject:from:to:content-type; bh=Qap9l2MGuttzva4UNQz9UrnctkS4YxisvUEfZCRabos=; b=d4Fa687kGeD38aqM+SwKP7U+JwbWsX/+J7CKo1OOU4D3LvDOj0hWQzSAQ+q01j5IQv AxcB8YzIOzijzSgDQlaPM03iUfPxIxzUcpAwEW1KM7WsxFvVrCDKPTD28DkVBUTxr0VW IrijS0LTDeBVyefcdVD7u9kbe47RLhsGKgN9zyY1ETU0AChGGEB+RDa215PLIZwXhtt8 AM1ud+NJZgO2O7DU+fxtJeI05QPmAHPb0KGsRAQcRpq6dEUZI1Hj02r89NydMxC2+7hs 0XupKn9ozX0C5HSYMcN+TdKpXPyi99Taqh8ARTeW5kkQOtimb7TtrAB1pMgdXrIeZpEl 2tfQ== MIME-Version: 1.0 X-Received: by 10.52.29.209 with SMTP id m17mr5122164vdh.111.1362266275320; Sat, 02 Mar 2013 15:17:55 -0800 (PST) In-Reply-To: References: <707df78f-9a67-4ce1-8dd3-095c75a7f7da@googlegroups.com> Date: Sun, 3 Mar 2013 10:17:55 +1100 Subject: Re: Dealing with exceptions From: Chris Angelico To: python-list@python.org Content-Type: text/plain; charset=ISO-8859-1 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: 38 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1362266283 news.xs4all.nl 6885 [2001:888:2000:d::a6]:56497 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:40375 On Sun, Mar 3, 2013 at 10:08 AM, Terry Reedy wrote: > On 3/2/2013 5:16 PM, Chris Angelico wrote: >> >> On Sun, Mar 3, 2013 at 8:23 AM, Terry Reedy wrote: >>>>>> >>>>>> 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. >> >> >> That's actually a perfectly valid file name, but one that doesn't >> happen to have a corresponding file. However, the same technique will >> work with the OP's description of "a filename which the FAT32 didn't >> like" too. > > > Yeah, that gives a different error and message. >>>> open('a~`!@#$%^&*()_-+={[}]|\<,>.?/') > > Traceback (most recent call last): > File "", line 1, in > open('a~`!@#$%^&*()_-+={[}]|\<,>.?/') > OSError: [Errno 22] Invalid argument: 'a~`!@#$%^&*()_-+={[}]|\\<,>.?/' That should be: OSError: Profanity not permitted on respectable file systems ChrisA