Fixed to the extend that it now builds in CW6, and actually works
a little.
diff --git a/Mac/Modules/carbonevt/CarbonEvtsupport.py b/Mac/Modules/carbonevt/CarbonEvtsupport.py
index 2609611..fc39b08 100644
--- a/Mac/Modules/carbonevt/CarbonEvtsupport.py
+++ b/Mac/Modules/carbonevt/CarbonEvtsupport.py
@@ -24,7 +24,7 @@
 	execstr = "%(name)s = OpaqueType('%(name)s')" % {"name": typ}
 	exec execstr
 
-EventTypeSpec_ptr = OpaqueType("EventTypeSpec *", "EventTypeSpec")
+EventTypeSpec_ptr = OpaqueType("EventTypeSpec", "EventTypeSpec")
 
 # is this the right type for the void * in GetEventParameter
 #void_ptr = FixedInputBufferType(1024)
@@ -52,7 +52,12 @@
 CarbonEventsMethod = OSErrMethodGenerator
 
 includestuff = """
+#ifdef WITHOUT_FRAMEWORKS
+#include <CarbonEvents.h>
+#else
 #include <Carbon/Carbon.h>
+#endif
+
 #include "macglue.h"
 
 #define USE_MAC_MP_MULTITHREADING 1
@@ -81,7 +86,7 @@
 static int
 EventTypeSpec_Convert(PyObject *v, EventTypeSpec *out)
 {
-	if (PyArg_ParseTuple(v, "ll", &(out->eventClass), &(out->eventKind)))
+	if (PyArg_Parse(v, "(O&l)", PyMac_GetOSType, &(out->eventClass), &(out->eventKind)))
 		return 1;
 	return NULL;
 }
@@ -90,6 +95,7 @@
 
 /********** HIPoint *******/
 
+#if 0  /* XXX doesn't compile */
 static PyObject*
 HIPoint_New(HIPoint *in)
 {
@@ -103,6 +109,7 @@
 		return 1;
 	return NULL;
 }
+#endif
 
 /********** end HIPoint *******/
 
@@ -126,7 +133,9 @@
 
 /******** handlecommand ***********/
 
-pascal OSStatus CarbonEvents_HandleCommand(EventHandlerCallRef handlerRef, EventRef event, void *outPyObject) {
+static EventHandlerUPP gEventHandlerUPP;
+
+pascal OSStatus CarbonEvents_HandleEvent(EventHandlerCallRef handlerRef, EventRef event, void *outPyObject) {
 	PyObject *retValue;
 	int status;
 
@@ -150,7 +159,10 @@
 
 """
 
-module = MacModule('CarbonEvents', 'CarbonEvents', includestuff, finalstuff, initstuff)
+initstuff = initstuff + """
+gEventHandlerUPP = NewEventHandlerUPP(CarbonEvents_HandleEvent);
+"""
+module = MacModule('_CarbonEvt', 'CarbonEvents', includestuff, finalstuff, initstuff)
 
 #class CFReleaserObj(GlobalObjectDefinition):
 #	def outputFreeIt(self, name):
@@ -181,17 +193,14 @@
 PyObject *callback;
 EventHandlerRef outRef;
 OSStatus _err;
-EventHandlerUPP event;
 
 if (!PyArg_ParseTuple(_args, "O&O", EventTypeSpec_Convert, &inSpec, &callback))
 	return NULL;
 
-event = NewEventHandlerUPP(CarbonEvents_HandleCommand);
-_err = InstallEventHandler(_self->ob_itself, event, 1, &inSpec, (void *)callback, &outRef);
+_err = InstallEventHandler(_self->ob_itself, gEventHandlerUPP, 1, &inSpec, (void *)callback, &outRef);
 if (_err != noErr) return PyMac_Error(_err);
 
-return Py_BuildValue("l", outRef);
-"""
+return Py_BuildValue("O&", EventHandlerRef_New, outRef);"""
 
 f = ManualGenerator("InstallEventHandler", installeventhandler);
 f.docstring = lambda: "(EventTargetRef inTarget, EventTypeSpec inSpec, Method callback) -> (EventHandlerRef outRef)"
@@ -200,7 +209,7 @@
 runappeventloop = """
 #if USE_MAC_MP_MULTITHREADING
 if (MPCreateCriticalRegion(&reentrantLock) != noErr) {
-	printf("lock failure\n");
+	printf("lock failure\\n");
 	return NULL;
 }
 _save = PyEval_SaveThread();
@@ -223,7 +232,7 @@
 f.docstring = lambda: "() -> ()"
 module.add(f)
 
-SetOutputFileName('_CarbonEvt.c')
+SetOutputFileName('_CarbonEvtmodule.c')
 module.generate()
 
 ##import os
diff --git a/Mac/Modules/carbonevt/_CarbonEvt.c b/Mac/Modules/carbonevt/_CarbonEvtmodule.c
old mode 100644
new mode 100755
similarity index 95%
rename from Mac/Modules/carbonevt/_CarbonEvt.c
rename to Mac/Modules/carbonevt/_CarbonEvtmodule.c
index 731a2fa..1230dda
--- a/Mac/Modules/carbonevt/_CarbonEvt.c
+++ b/Mac/Modules/carbonevt/_CarbonEvtmodule.c
@@ -1,11 +1,16 @@
 
-/* ====================== Module CarbonEvents ======================= */
+/* ======================= Module _CarbonEvt ======================== */
 
 #include "Python.h"
 
 
 
+#ifdef WITHOUT_FRAMEWORKS
+#include <CarbonEvents.h>
+#else
 #include <Carbon/Carbon.h>
+#endif
+
 #include "macglue.h"
 
 #define USE_MAC_MP_MULTITHREADING 1
@@ -34,7 +39,7 @@
 static int
 EventTypeSpec_Convert(PyObject *v, EventTypeSpec *out)
 {
-	if (PyArg_ParseTuple(v, "ll", &(out->eventClass), &(out->eventKind)))
+	if (PyArg_Parse(v, "(O&l)", PyMac_GetOSType, &(out->eventClass), &(out->eventKind)))
 		return 1;
 	return NULL;
 }
@@ -43,6 +48,7 @@
 
 /********** HIPoint *******/
 
+#if 0  /* XXX doesn't compile */
 static PyObject*
 HIPoint_New(HIPoint *in)
 {
@@ -56,6 +62,7 @@
 		return 1;
 	return NULL;
 }
+#endif
 
 /********** end HIPoint *******/
 
@@ -79,7 +86,9 @@
 
 /******** handlecommand ***********/
 
-pascal OSStatus CarbonEvents_HandleCommand(EventHandlerCallRef handlerRef, EventRef event, void *outPyObject) {
+static EventHandlerUPP gEventHandlerUPP;
+
+pascal OSStatus CarbonEvents_HandleEvent(EventHandlerCallRef handlerRef, EventRef event, void *outPyObject) {
 	PyObject *retValue;
 	int status;
 
@@ -354,9 +363,9 @@
 #define EventRef_hash NULL
 
 PyTypeObject EventRef_Type = {
-	PyObject_HEAD_INIT(&PyType_Type)
+	PyObject_HEAD_INIT(NULL)
 	0, /*ob_size*/
-	"CarbonEvents.EventRef", /*tp_name*/
+	"_CarbonEvt.EventRef", /*tp_name*/
 	sizeof(EventRefObject), /*tp_basicsize*/
 	0, /*tp_itemsize*/
 	/* methods */
@@ -435,7 +444,7 @@
 	PyObject *_res = NULL;
 	OSStatus _err;
 	UInt32 inNumTypes;
-	EventTypeSpec * inList;
+	EventTypeSpec inList;
 	if (!PyArg_ParseTuple(_args, "lO&",
 	                      &inNumTypes,
 	                      EventTypeSpec_Convert, &inList))
@@ -509,7 +518,7 @@
 	{"PostEventToQueue", (PyCFunction)EventQueueRef_PostEventToQueue, 1,
 	 "(EventRef inEvent, SInt16 inPriority) -> None"},
 	{"FlushEventsMatchingListFromQueue", (PyCFunction)EventQueueRef_FlushEventsMatchingListFromQueue, 1,
-	 "(UInt32 inNumTypes, EventTypeSpec * inList) -> None"},
+	 "(UInt32 inNumTypes, EventTypeSpec inList) -> None"},
 	{"FlushEventQueue", (PyCFunction)EventQueueRef_FlushEventQueue, 1,
 	 "() -> None"},
 	{"GetNumEventsInQueue", (PyCFunction)EventQueueRef_GetNumEventsInQueue, 1,
@@ -537,9 +546,9 @@
 #define EventQueueRef_hash NULL
 
 PyTypeObject EventQueueRef_Type = {
-	PyObject_HEAD_INIT(&PyType_Type)
+	PyObject_HEAD_INIT(NULL)
 	0, /*ob_size*/
-	"CarbonEvents.EventQueueRef", /*tp_name*/
+	"_CarbonEvt.EventQueueRef", /*tp_name*/
 	sizeof(EventQueueRefObject), /*tp_basicsize*/
 	0, /*tp_itemsize*/
 	/* methods */
@@ -629,9 +638,9 @@
 #define EventLoopRef_hash NULL
 
 PyTypeObject EventLoopRef_Type = {
-	PyObject_HEAD_INIT(&PyType_Type)
+	PyObject_HEAD_INIT(NULL)
 	0, /*ob_size*/
-	"CarbonEvents.EventLoopRef", /*tp_name*/
+	"_CarbonEvt.EventLoopRef", /*tp_name*/
 	sizeof(EventLoopRefObject), /*tp_basicsize*/
 	0, /*tp_itemsize*/
 	/* methods */
@@ -739,9 +748,9 @@
 #define EventLoopTimerRef_hash NULL
 
 PyTypeObject EventLoopTimerRef_Type = {
-	PyObject_HEAD_INIT(&PyType_Type)
+	PyObject_HEAD_INIT(NULL)
 	0, /*ob_size*/
-	"CarbonEvents.EventLoopTimerRef", /*tp_name*/
+	"_CarbonEvt.EventLoopTimerRef", /*tp_name*/
 	sizeof(EventLoopTimerRefObject), /*tp_basicsize*/
 	0, /*tp_itemsize*/
 	/* methods */
@@ -814,7 +823,7 @@
 	PyObject *_res = NULL;
 	OSStatus _err;
 	UInt32 inNumTypes;
-	EventTypeSpec * inList;
+	EventTypeSpec inList;
 	if (!PyArg_ParseTuple(_args, "lO&",
 	                      &inNumTypes,
 	                      EventTypeSpec_Convert, &inList))
@@ -833,7 +842,7 @@
 	PyObject *_res = NULL;
 	OSStatus _err;
 	UInt32 inNumTypes;
-	EventTypeSpec * inList;
+	EventTypeSpec inList;
 	if (!PyArg_ParseTuple(_args, "lO&",
 	                      &inNumTypes,
 	                      EventTypeSpec_Convert, &inList))
@@ -851,9 +860,9 @@
 	{"RemoveEventHandler", (PyCFunction)EventHandlerRef_RemoveEventHandler, 1,
 	 "() -> None"},
 	{"AddEventTypesToHandler", (PyCFunction)EventHandlerRef_AddEventTypesToHandler, 1,
-	 "(UInt32 inNumTypes, EventTypeSpec * inList) -> None"},
+	 "(UInt32 inNumTypes, EventTypeSpec inList) -> None"},
 	{"RemoveEventTypesFromHandler", (PyCFunction)EventHandlerRef_RemoveEventTypesFromHandler, 1,
-	 "(UInt32 inNumTypes, EventTypeSpec * inList) -> None"},
+	 "(UInt32 inNumTypes, EventTypeSpec inList) -> None"},
 	{NULL, NULL, 0}
 };
 
@@ -873,9 +882,9 @@
 #define EventHandlerRef_hash NULL
 
 PyTypeObject EventHandlerRef_Type = {
-	PyObject_HEAD_INIT(&PyType_Type)
+	PyObject_HEAD_INIT(NULL)
 	0, /*ob_size*/
-	"CarbonEvents.EventHandlerRef", /*tp_name*/
+	"_CarbonEvt.EventHandlerRef", /*tp_name*/
 	sizeof(EventHandlerRefObject), /*tp_basicsize*/
 	0, /*tp_itemsize*/
 	/* methods */
@@ -968,9 +977,9 @@
 #define EventHandlerCallRef_hash NULL
 
 PyTypeObject EventHandlerCallRef_Type = {
-	PyObject_HEAD_INIT(&PyType_Type)
+	PyObject_HEAD_INIT(NULL)
 	0, /*ob_size*/
-	"CarbonEvents.EventHandlerCallRef", /*tp_name*/
+	"_CarbonEvt.EventHandlerCallRef", /*tp_name*/
 	sizeof(EventHandlerCallRefObject), /*tp_basicsize*/
 	0, /*tp_itemsize*/
 	/* methods */
@@ -1046,17 +1055,14 @@
 	PyObject *callback;
 	EventHandlerRef outRef;
 	OSStatus _err;
-	EventHandlerUPP event;
 
 	if (!PyArg_ParseTuple(_args, "O&O", EventTypeSpec_Convert, &inSpec, &callback))
 		return NULL;
 
-	event = NewEventHandlerUPP(CarbonEvents_HandleCommand);
-	_err = InstallEventHandler(_self->ob_itself, event, 1, &inSpec, (void *)callback, &outRef);
+	_err = InstallEventHandler(_self->ob_itself, gEventHandlerUPP, 1, &inSpec, (void *)callback, &outRef);
 	if (_err != noErr) return PyMac_Error(_err);
 
-	return Py_BuildValue("l", outRef);
-
+	return Py_BuildValue("O&", EventHandlerRef_New, outRef);
 }
 
 static PyMethodDef EventTargetRef_methods[] = {
@@ -1083,9 +1089,9 @@
 #define EventTargetRef_hash NULL
 
 PyTypeObject EventTargetRef_Type = {
-	PyObject_HEAD_INIT(&PyType_Type)
+	PyObject_HEAD_INIT(NULL)
 	0, /*ob_size*/
-	"CarbonEvents.EventTargetRef", /*tp_name*/
+	"_CarbonEvt.EventTargetRef", /*tp_name*/
 	sizeof(EventTargetRefObject), /*tp_basicsize*/
 	0, /*tp_itemsize*/
 	/* methods */
@@ -1160,9 +1166,9 @@
 #define EventHotKeyRef_hash NULL
 
 PyTypeObject EventHotKeyRef_Type = {
-	PyObject_HEAD_INIT(&PyType_Type)
+	PyObject_HEAD_INIT(NULL)
 	0, /*ob_size*/
-	"CarbonEvents.EventHotKeyRef", /*tp_name*/
+	"_CarbonEvt.EventHotKeyRef", /*tp_name*/
 	sizeof(EventHotKeyRefObject), /*tp_basicsize*/
 	0, /*tp_itemsize*/
 	/* methods */
@@ -1225,7 +1231,7 @@
 	PyObject *_res = NULL;
 	OSStatus _err;
 	UInt32 inNumTypes;
-	EventTypeSpec * inList;
+	EventTypeSpec inList;
 	double inTimeout;
 	Boolean inPullEvent;
 	EventRef outEvent;
@@ -1474,8 +1480,7 @@
 
 #if USE_MAC_MP_MULTITHREADING
 	if (MPCreateCriticalRegion(&reentrantLock) != noErr) {
-		printf("lock failure
-	");
+		printf("lock failure\n");
 		return NULL;
 	}
 	_save = PyEval_SaveThread();
@@ -1503,7 +1508,7 @@
 	{"RunCurrentEventLoop", (PyCFunction)CarbonEvents_RunCurrentEventLoop, 1,
 	 "(double inTimeout) -> None"},
 	{"ReceiveNextEvent", (PyCFunction)CarbonEvents_ReceiveNextEvent, 1,
-	 "(UInt32 inNumTypes, EventTypeSpec * inList, double inTimeout, Boolean inPullEvent) -> (EventRef outEvent)"},
+	 "(UInt32 inNumTypes, EventTypeSpec inList, double inTimeout, Boolean inPullEvent) -> (EventRef outEvent)"},
 	{"GetCurrentEventQueue", (PyCFunction)CarbonEvents_GetCurrentEventQueue, 1,
 	 "() -> (EventQueueRef _rv)"},
 	{"GetMainEventQueue", (PyCFunction)CarbonEvents_GetMainEventQueue, 1,
@@ -1544,15 +1549,17 @@
 
 
 
-void initCarbonEvents(void)
+void init_CarbonEvt(void)
 {
 	PyObject *m;
 	PyObject *d;
 
 
 
+	gEventHandlerUPP = NewEventHandlerUPP(CarbonEvents_HandleEvent);
 
-	m = Py_InitModule("CarbonEvents", CarbonEvents_methods);
+
+	m = Py_InitModule("_CarbonEvt", CarbonEvents_methods);
 	d = PyModule_GetDict(m);
 	CarbonEvents_Error = PyMac_GetOSErrException();
 	if (CarbonEvents_Error == NULL ||
@@ -1592,5 +1599,5 @@
 		Py_FatalError("can't initialize EventHotKeyRefType");
 }
 
-/* ==================== End module CarbonEvents ===================== */
+/* ===================== End module _CarbonEvt ====================== */