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


Groups > comp.lang.python > #88859

Re: try..except with empty exceptions

Date 2015-04-12 16:41 +1000
From Cameron Simpson <cs@zip.com.au>
Subject Re: try..except with empty exceptions
References <20150412063339.GA16977@cskk.homeip.net>
Newsgroups comp.lang.python
Message-ID <mailman.241.1428820887.12925.python-list@python.org> (permalink)

Show all headers | View raw


On 12Apr2015 16:33, Cameron Simpson <cs@zip.com.au> wrote:
>Finally, if we were to expunge support for "except:", one would also need a 
>cast iron guarrentee that no exception could possibly occur which was not a 
>subclass of BaseException. I'd expect that to mean that "raise" of a 
>non-instance of BaseException to itself raise a TypeError.

And I see that Steven D'Aprano has already pointed out PEP 352:

  http://www.python.org/dev/peps/pep-0352/

which is marked "Status: Final". It says:

  The raise statement will be changed to require that any object passed to it 
  must inherit from BaseException. This will make sure that all exceptions fall 
  within a single hierarchy that is anchored at BaseException [2] . This also 
  guarantees a basic interface that is inherited from BaseException. The change 
  to raise will be enforced starting in Python 3.0 (see the Transition Plan 
  below).

Hmm. Not in 2.7? I can see the breakage it could cause, but where does that 
leave me? I think I could probably move to catching Exception almost across the 
board even in 2.5+ and feel pretty good.

Cheers,
Cameron Simpson <cs@zip.com.au>

If your new theorem can be stated with great simplicity, then there
will exist a pathological exception.    - Adrian Mathesis

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


Thread

Re: try..except with empty exceptions Cameron Simpson <cs@zip.com.au> - 2015-04-12 16:41 +1000

csiph-web