[Pythonmac-SIG] MacOS.Error exceptions

Donovan Preston dp@ulaluma.com
Sat, 30 Mar 2002 11:12:13 -0800


Hey everybody,

As there is a discussion right now on Python-Dev about Exceptions 
(string exceptions and others) not inheriting from Exception, I thought 
I would bring up an issue about MacOS.Error here in Python-Mac first and 
gauge people's reactions.

The issue is that MacOS.Error, which is raised as an exception from many 
of the toolbox modules, does not descend from Exception. In the 
pre-python 2.2 class-type model, I'm not sure it could have inherited 
from Exception, since it is defined in a C module; I'm wondering if it's 
possible now, and for the sake of consistency if we should try to make 
MacOS.Error descend from Exception?

This definately surprised me the first time I encountered it; I was 
trying something like

try:
	foo.SomeMacOSCall()
except Exception, e:
	print "whoops, oh well"

However, the MacOS.Error still made it through.

I'm willing to explore what it would take to fix this if 1) someone 
tells me it's possible and desirable, and 2) someone points me in the 
right direction w.r.t. having something (a type? a class? a new style 
class also being a type...) that's defined in C descend from something 
else.

Donovan