[Bf-python] API inconsistencies: Exception types

Ken Hughes khughes at pacific.edu
Fri Aug 19 00:12:09 CEST 2005


Another rant/question for API inconsistencies:

Is there some general consensus (and if so, is it already in of the 
Blender coding docs, and if not can someone put it there?) as to what
type of exceptions to throw when?  I've seen PyExc_TypeError, 
PyExc_ValueError and PyExc_AttributeError used somewhat interchangeably 
(and I'm guilty too).  Would the following be Good Rules(tm)?

(1) PyExc_TypeError: the user passes a parameter which is of the wrong 
type (string instead of int, list instead of tuple, whatever), such that
  it would cause PyArg_ParseTuple() to fail
(2) PyExc_AttributeError: the user refers to an attribute which doesn't 
exist ("print Blender.Object.Get('Cube').bogus")
(3) PyExc_ValueError: the user passes a parameter of the correct type, 
but with an invalid value ("Blender.Object.New.('Bogus')")

I know this isn't a big deal, but I've had a lot of caffiene today.

Ken



More information about the Bf-python mailing list