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


Groups > comp.lang.python > #88859 > unrolled thread

Re: try..except with empty exceptions

Started byCameron Simpson <cs@zip.com.au>
First post2015-04-12 16:41 +1000
Last post2015-04-12 16:41 +1000
Articles 1 — 1 participant

Back to article view | Back to comp.lang.python

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

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

#88859 — Re: try..except with empty exceptions

FromCameron Simpson <cs@zip.com.au>
Date2015-04-12 16:41 +1000
SubjectRe: try..except with empty exceptions
Message-ID<mailman.241.1428820887.12925.python-list@python.org>
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

[toc] | [standalone]


Back to top | Article view | comp.lang.python


csiph-web