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


Groups > comp.lang.python > #77737

Re: exit code of a script that raises an Exception?

Path csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!weretis.net!feeder4.news.weretis.net!feeds.phibee-telecom.net!newsfeed.xs4all.nl!newsfeed3.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!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.000
X-Spam-Evidence '*H*': 1.00; '*S*': 0.00; '(especially': 0.07; 'subject:code': 0.07; 'exception.': 0.09; 'exit': 0.09; 'exits': 0.09; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'subject:script': 0.09; 'undefined': 0.09; 'python': 0.11; '2.7': 0.14; 'btw:': 0.16; 'distinct': 0.16; 'exception:': 0.16; 'exited': 0.16; 'received:80.91.229.3': 0.16; 'received:plane.gmane.org': 0.16; 'threw': 0.16; 'throw': 0.16; 'types,': 0.16; 'exception': 0.16; 'thanks,': 0.17; 'wrote:': 0.18; 'appears': 0.22; 'code,': 0.22; 'header:User-Agent:1': 0.23; 'script': 0.25; 'header:X-Complaints-To:1': 0.27; 'header:In- Reply-To:1': 0.27; 'am,': 0.29; 'wonder': 0.29; 'code': 0.31; 'exceptions': 0.31; 'subject:that': 0.31; 'url:python': 0.33; 'could': 0.34; 'there': 0.35; 'subject:?': 0.36; 'url:org': 0.36; 'url:library': 0.38; 'to:addr:python-list': 0.38; 'to:addr:python.org': 0.39; 'received:org': 0.40; 'how': 0.40; 'skip:u 10': 0.60; 'new': 0.61; 'email addr:gmail.com': 0.63; 'information': 0.63; 'guaranteed': 0.75; 'behavior': 0.77; 'bounded': 0.84; 'demonstrates': 0.84
X-Injected-Via-Gmane http://gmane.org/
To python-list@python.org
From Ned Batchelder <ned@nedbatchelder.com>
Subject Re: exit code of a script that raises an Exception?
Date Tue, 09 Sep 2014 11:22:05 -0400
References <efb77e4a-0510-49d3-8873-96714632a154@googlegroups.com>
Mime-Version 1.0
Content-Type text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding 7bit
X-Gmane-NNTP-Posting-Host 18.189.8.234
User-Agent Mozilla/5.0 (Macintosh; Intel Mac OS X 10.8; rv:24.0) Gecko/20100101 Thunderbird/24.6.0
In-Reply-To <efb77e4a-0510-49d3-8873-96714632a154@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 <python-list.python.org>
List-Unsubscribe <https://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 <https://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.13901.1410276152.18130.python-list@python.org> (permalink)
Lines 22
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1410276152 news.xs4all.nl 2905 [2001:888:2000:d::a6]:56410
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:77737

Show key headers only | View raw


On 9/9/14 9:55 AM, thequietcenter@gmail.com wrote:
> Hello, after looking at the docs for Exception:
> https://docs.python.org/2/library/exceptions.html
>
> I do not see any information on the guaranteed exit code a script that exits because Python threw an exception.
>
> I wonder if all exceptions throw the exact same non-zero exit code, or whether a specific exit code is assigned to each exception uniquely. Or whether the exit code behavior is undefined (especially since it appears to be undocumented).
>
> Thanks,
> Terrence
>

A quick check demonstrates that exceptions do not get distinct status 
codes.  BTW: how could they?, you can create new exception types, there 
is not a bounded number of them.

On my Mac, Python 2.7 exited with a status code of 1 for 
ZeroDivisionError, NameError, SyntaxError, IndexError, and KeyError.

-- 
Ned Batchelder, http://nedbatchelder.com

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


Thread

exit code of a script that raises an Exception? thequietcenter@gmail.com - 2014-09-09 06:55 -0700
  Re: exit code of a script that raises an Exception? thequietcenter@gmail.com - 2014-09-09 07:41 -0700
  Re: exit code of a script that raises an Exception? Ned Batchelder <ned@nedbatchelder.com> - 2014-09-09 11:22 -0400

csiph-web