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


Groups > comp.lang.python > #40372

Re: Dealing with exceptions

Path csiph.com!usenet.pasdenom.info!aioe.org!news.stack.nl!newsfeed.xs4all.nl!newsfeed1.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail
Return-Path <python-python-list@m.gmane.org>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.002
X-Spam-Evidence '*H*': 1.00; '*S*': 0.00; 'filename': 0.07; 'shutil': 0.07; 'argument:': 0.09; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'terry': 0.09; 'yeah,': 0.09; 'experiment.': 0.16; 'generate,': 0.16; 'oserror:': 0.16; 'received:80.91.229.3': 0.16; 'received:plane.gmane.org': 0.16; 'reedy': 0.16; 'wrote:': 0.17; 'jan': 0.18; '>>>': 0.18; 'file.': 0.20; '"",': 0.22; 'pass': 0.25; 'header:In-Reply-To:1': 0.25; 'header:User-Agent:1': 0.26; '(most': 0.27; 'am,': 0.27; "doesn't": 0.28; 'header:X-Complaints-To:1': 0.28; 'chris': 0.28; "skip:' 10": 0.30; 'error': 0.30; 'file': 0.32; 'message.': 0.33; 'traceback': 0.33; 'to:addr:python-list': 0.33; 'pm,': 0.35; 'too.': 0.35; 'there': 0.35; 'received:org': 0.36; 'but': 0.36; "didn't": 0.36; 'subject:with': 0.36; 'bad': 0.37; 'does': 0.37; 'subject:: ': 0.38; 'skip:o 20': 0.38; 'description': 0.39; 'gives': 0.39; 'to:addr:python.org': 0.39; 'header:Received:5': 0.40; 'different': 0.63; '2013': 0.84; 'directory:': 0.84; 'received:fios.verizon.net': 0.84; 'technique': 0.93
X-Injected-Via-Gmane http://gmane.org/
To python-list@python.org
From Terry Reedy <tjreedy@udel.edu>
Subject Re: Dealing with exceptions
Date Sat, 02 Mar 2013 18:08:48 -0500
References <707df78f-9a67-4ce1-8dd3-095c75a7f7da@googlegroups.com> <kgtql2$s0p$1@ger.gmane.org> <CAPTjJmoRsQKr7iwwh38KR-=LjUT620VDzsR6kgX83KYArzxr8g@mail.gmail.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 <CAPTjJmoRsQKr7iwwh38KR-=LjUT620VDzsR6kgX83KYArzxr8g@mail.gmail.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 <python-list.python.org>
List-Unsubscribe <http://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-list/>
List-Post <mailto:python-list@python.org>
List-Help <mailto:python-list-request@python.org?subject=help>
List-Subscribe <http://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.2801.1362265758.2939.python-list@python.org> (permalink)
Lines 29
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1362265758 news.xs4all.nl 6906 [2001:888:2000:d::a6]:49044
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:40372

Show key headers only | View raw


On 3/2/2013 5:16 PM, Chris Angelico wrote:
> On Sun, Mar 3, 2013 at 8:23 AM, Terry Reedy <tjreedy@udel.edu> wrote:
>>>>> open('sdjhfjshdfkjsh')
>> Traceback (most recent call last):
>>    File "<pyshell#2>", line 1, in <module>
>>      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 "<pyshell#3>", line 1, in <module>
     open('a~`!@#$%^&*()_-+={[}]|\<,>.?/')
OSError: [Errno 22] Invalid argument: 'a~`!@#$%^&*()_-+={[}]|\\<,>.?/'


-- 
Terry Jan Reedy

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


Thread

Dealing with exceptions bvdp <bob@mellowood.ca> - 2013-03-02 09:40 -0800
  Re: Dealing with exceptions Kwpolska <kwpolska@gmail.com> - 2013-03-02 18:52 +0100
    Re: Dealing with exceptions bvdp <bob@mellowood.ca> - 2013-03-02 11:35 -0800
      Re: Dealing with exceptions Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2013-03-03 01:41 +0000
    Re: Dealing with exceptions bvdp <bob@mellowood.ca> - 2013-03-02 11:35 -0800
    Re: Dealing with exceptions Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2013-03-03 00:41 +0000
      Re: Dealing with exceptions Chris Angelico <rosuav@gmail.com> - 2013-03-03 12:04 +1100
    Re: Dealing with exceptions Nobody <nobody@nowhere.com> - 2013-03-03 23:01 +0000
  Re: Dealing with exceptions Ian Kelly <ian.g.kelly@gmail.com> - 2013-03-02 10:58 -0700
  Re: Dealing with exceptions Ian Kelly <ian.g.kelly@gmail.com> - 2013-03-02 11:00 -0700
  Re: Dealing with exceptions Chris Angelico <rosuav@gmail.com> - 2013-03-03 05:21 +1100
    Re: Dealing with exceptions bvdp <bob@mellowood.ca> - 2013-03-02 11:39 -0800
    Re: Dealing with exceptions bvdp <bob@mellowood.ca> - 2013-03-02 11:39 -0800
  Re: Dealing with exceptions Mark Lawrence <breamoreboy@yahoo.co.uk> - 2013-03-02 19:18 +0000
  Re: Dealing with exceptions Devin Jeanpierre <jeanpierreda@gmail.com> - 2013-03-02 14:27 -0500
  Re: Dealing with exceptions Rick Johnson <rantingrickjohnson@gmail.com> - 2013-03-02 11:43 -0800
  Re: Dealing with exceptions Terry Reedy <tjreedy@udel.edu> - 2013-03-02 16:23 -0500
  Re: Dealing with exceptions Chris Angelico <rosuav@gmail.com> - 2013-03-03 09:16 +1100
  Re: Dealing with exceptions Terry Reedy <tjreedy@udel.edu> - 2013-03-02 18:08 -0500
  Re: Dealing with exceptions Chris Angelico <rosuav@gmail.com> - 2013-03-03 10:17 +1100

csiph-web