[Python-Dev] Style for raising exceptions (python-dev Summary for 2005-08-01 through 2005-08-15 [draft])

Fred L. Drake, Jr. fdrake at acm.org
Fri Aug 26 16:01:37 CEST 2005


On Friday 26 August 2005 09:15, Michael Chermside wrote:
 > Oh my GOD! Are you saying that in order to correctly read Python code
 > that a programmer must know all of THAT! I would be entirely
 > unsurprised to learn that NO ONE on this list... in fact, no one
 > in the whole world could have reproduced that specification from
 > memory accurately. I have never seen a more convincing argument for
 > why we should allow only limited forms in Python 3.0.

No kidding.

The stuff about the tuples is particularly painful, but is specifically there 
to deal with string exceptions and the idiom that an exception could be 
defined as a tuple of exceptions.  In fact, anydbm is particularly 
eggregious:  it defines an error class derived from Exception, and then adds 
that to a tuple with the string exceptions from the specific modules it 
fronts for.  The tuple handling in raise allows anydbm.error to be raised and 
then caught again abstractly, in addition to allow anydbm.error to act as a 
"base" exception that catches the specific errors raised by the backend 
databases.


  -Fred

-- 
Fred L. Drake, Jr.   <fdrake at acm.org>


More information about the Python-Dev mailing list