First step in porting MacPython modules to OSX/unix: break all references between modules except for the obj_New() and obj_Convert() routines, the PyArg_Parse and Py_BuildValue helpers.
And these can now be vectored through glue routines (by defining USE_TOOLBOX_OBJECT_GLUE) which will do the necessary imports, whereupon the module's init routine will tell the glue routine about the real conversion routine address and everything is fine again.
diff --git a/Mac/Modules/res/Resmodule.c b/Mac/Modules/res/Resmodule.c
index bd6a42d..26007b4 100644
--- a/Mac/Modules/res/Resmodule.c
+++ b/Mac/Modules/res/Resmodule.c
@@ -11,6 +11,17 @@
#include <Resources.h>
#include <string.h>
+#ifdef USE_TOOLBOX_OBJECT_GLUE
+extern PyObject *_ResObj_New(Handle);
+extern int _ResObj_Convert(PyObject *, Handle *);
+extern PyObject *_OptResObj_New(Handle);
+extern int _OptResObj_Convert(PyObject *, Handle *);
+#define ResObj_New _ResObj_New
+#define ResObj_Convert _ResObj_Convert
+#define OptResObj_New _OptResObj_New
+#define OptResObj_Convert _OptResObj_Convert
+#endif
+
/* Function to dispose a resource, with a "normal" calling sequence */
static void
PyMac_AutoDisposeHandle(Handle h)
@@ -1678,6 +1689,10 @@
+ PyMac_INIT_TOOLBOX_OBJECT_NEW(ResObj_New);
+ PyMac_INIT_TOOLBOX_OBJECT_CONVERT(ResObj_Convert);
+ PyMac_INIT_TOOLBOX_OBJECT_NEW(OptResObj_New);
+ PyMac_INIT_TOOLBOX_OBJECT_CONVERT(OptResObj_Convert);
m = Py_InitModule("Res", Res_methods);