[Pythonmac-SIG] What to do about missing toolbox routines

Jack Jansen jack@oratrix.nl
Sun, 12 Dec 1999 22:32:32 +0100


Folks,
now that I'm regenerating lots of the toolbox modules to support the
new MacOS 8.6 calls I'm again running into the question of how to
handle toolbox calls that don't exist on the current machine.

The current "solution" is that the various libraries like DragLib, QuickTime,
etc. are imported weak, which means that if the library doesn't exist
at runtime (or if the library exists but not all calls exist) Python
will silently continue. However, attmpting to use a non-existent
method from Python will result in a call to address zero, and hence a
crash. This is suboptimal:-)

I can think of two decent solutions, and I'd like feedback on the
preferred one (but note that the actual implementation will also depend on 
the amount of time I have, so even though everyone agrees on an
optimal one that doesn't imply it'll actualy be implemented:-):

1. Upon first call of a toolbox method check whether it actually
   exists and raise an exception if it doesn't.
2. Upon import of a plugin module test all toolbox routines for
   existence (by comparing the routine address to 0) and for those that 
   don't exist don't export the Python method either. This is a lot
   more work.

But, of course, an answer of "ah well, leave it as it is, it hasn't
bitten me yet" is also welcome,

--
Jack Jansen             | ++++ stop the execution of Mumia Abu-Jamal ++++
Jack.Jansen@oratrix.com | ++++ if you agree copy these lines to your sig ++++
www.oratrix.nl/~jack    | see http://www.xs4all.nl/~tank/spg-l/sigaction.htm