From: Francesc A. <fa...@ca...> - 2004-12-02 18:48:08
|
Hi Robert, A Dijous 02 Desembre 2004 19:24, Norbert Nemec va escriure: > Hi there, >=20 > checking through the code of pytables, I fail to find much of a concept f= or=20 > which exception is thrown where. All the different standard exception typ= es=20 > have well defined meanings: > http://www.python.org/dev/doc/devel/lib/module-exceptions.html > but it seems to me that pytables does not really follow these too closely. I wasn't really aware of that document. I use to follow the "Python Essential Reference" by David Beazly, and I can see now that the document you pointed out is much better regarding exceptions case uses. Thanks for noting that!. > I'm mostly concerned about nonexistant objects. If I try to access/delete= such=20 > an object in different contexts, I get all kinds of different exceptions,= =20 > ranging from NameError over LookupError all the way to RuntimeError, wher= e an=20 > AttributeError would seem most appropriate. >=20 > Following the documentation > * LookupError should never be used at all, since it is just the base for= =20 > IndexError and KeyError. > * NameError is meant for global or local symbols that do not exist > * RuntimeError is just a fallback in cases where nothing else seems to fi= t. >=20 > Is this matter just not defined too well, yet or is there a hidden concep= t=20 > behind the current state of affairs, that I just fail to see? To say the truth, the first reason fits better in this case. Generally speaking, I've tried to follow the "good use manners" when exceptions raised from python code (although maybe in some cases this might not be the case). However, when an exception was raised from the Pyrex part of the code, it normally goes as a RuntimeError. I've no a good reason to do that (apart of laziness), but it is like that. If you feel like having a general overhaul about wrong exceptions and provide the pointers to the appropriate parts of code, I'll look into that. And much better if you can provide the patches, of course!. Cheers, =2D-=20 =46rancesc Altet Who's your data daddy? =A0PyTables |