Made the core toolbox modules carbon-compatible using the new greylist feature of bgen: non-carbon methods are still included in non-carbon MacPython. The issue of backward compatibility of Python code is still open.
Macmodule and macosmodule have also been carbonified. Some functionality is still missing there.
diff --git a/Mac/Modules/win/Winmodule.c b/Mac/Modules/win/Winmodule.c
index 9542447..a03d493 100644
--- a/Mac/Modules/win/Winmodule.c
+++ b/Mac/Modules/win/Winmodule.c
@@ -78,10 +78,12 @@
 	PyObject *v;
 	WindowPtr *p_itself;
 {
+#ifndef TARGET_API_MAC_CARBON
 	if (DlgObj_Check(v)) {
 		*p_itself = ((WindowObject *)v)->ob_itself;
 		return 1;
 	}
+#endif
 
 	if (v == Py_None) { *p_itself = NULL; return 1; }
 	if (PyInt_Check(v)) { *p_itself = (WindowPtr)PyInt_AsLong(v); return 1; }
@@ -102,19 +104,6 @@
 	PyMem_DEL(self);
 }
 
-static PyObject *WinObj_MacCloseWindow(_self, _args)
-	WindowObject *_self;
-	PyObject *_args;
-{
-	PyObject *_res = NULL;
-	if (!PyArg_ParseTuple(_args, ""))
-		return NULL;
-	MacCloseWindow(_self->ob_itself);
-	Py_INCREF(Py_None);
-	_res = Py_None;
-	return _res;
-}
-
 static PyObject *WinObj_GetWindowOwnerCount(_self, _args)
 	WindowObject *_self;
 	PyObject *_args;
@@ -181,6 +170,8 @@
 	return _res;
 }
 
+#ifndef TARGET_API_MAC_CARBON
+
 static PyObject *WinObj_SetWinColor(_self, _args)
 	WindowObject *_self;
 	PyObject *_args;
@@ -196,6 +187,7 @@
 	_res = Py_None;
 	return _res;
 }
+#endif
 
 static PyObject *WinObj_SetWindowContentColor(_self, _args)
 	WindowObject *_self;
@@ -280,6 +272,8 @@
 	return _res;
 }
 
+#ifndef TARGET_API_MAC_CARBON
+
 static PyObject *WinObj_SaveOld(_self, _args)
 	WindowObject *_self;
 	PyObject *_args;
@@ -292,6 +286,9 @@
 	_res = Py_None;
 	return _res;
 }
+#endif
+
+#ifndef TARGET_API_MAC_CARBON
 
 static PyObject *WinObj_DrawNew(_self, _args)
 	WindowObject *_self;
@@ -308,6 +305,7 @@
 	_res = Py_None;
 	return _res;
 }
+#endif
 
 static PyObject *WinObj_PaintOne(_self, _args)
 	WindowObject *_self;
@@ -713,7 +711,7 @@
 	                            &outFile);
 	if (_err != noErr) return PyMac_Error(_err);
 	_res = Py_BuildValue("O&",
-	                     PyMac_BuildFSSpec, &outFile);
+	                     PyMac_BuildFSSpec, outFile);
 	return _res;
 }
 
@@ -1319,6 +1317,8 @@
 	return _res;
 }
 
+#ifndef TARGET_API_MAC_CARBON
+
 static PyObject *WinObj_GetAuxWin(_self, _args)
 	WindowObject *_self;
 	PyObject *_args;
@@ -1335,6 +1335,7 @@
 	                     ResObj_New, awHndl);
 	return _res;
 }
+#endif
 
 static PyObject *WinObj_GetWindowPort(_self, _args)
 	WindowObject *_self;
@@ -1435,6 +1436,8 @@
 	return _res;
 }
 
+#ifndef TARGET_API_MAC_CARBON
+
 static PyObject *WinObj_GetWindowZoomFlag(_self, _args)
 	WindowObject *_self;
 	PyObject *_args;
@@ -1448,6 +1451,9 @@
 	                     _rv);
 	return _res;
 }
+#endif
+
+#ifndef TARGET_API_MAC_CARBON
 
 static PyObject *WinObj_GetWindowStructureRgn(_self, _args)
 	WindowObject *_self;
@@ -1464,6 +1470,9 @@
 	_res = Py_None;
 	return _res;
 }
+#endif
+
+#ifndef TARGET_API_MAC_CARBON
 
 static PyObject *WinObj_GetWindowContentRgn(_self, _args)
 	WindowObject *_self;
@@ -1480,6 +1489,9 @@
 	_res = Py_None;
 	return _res;
 }
+#endif
+
+#ifndef TARGET_API_MAC_CARBON
 
 static PyObject *WinObj_GetWindowUpdateRgn(_self, _args)
 	WindowObject *_self;
@@ -1496,6 +1508,9 @@
 	_res = Py_None;
 	return _res;
 }
+#endif
+
+#ifndef TARGET_API_MAC_CARBON
 
 static PyObject *WinObj_GetWindowTitleWidth(_self, _args)
 	WindowObject *_self;
@@ -1510,6 +1525,7 @@
 	                     _rv);
 	return _res;
 }
+#endif
 
 static PyObject *WinObj_GetNextWindow(_self, _args)
 	WindowObject *_self;
@@ -1587,35 +1603,7 @@
 	return _res;
 }
 
-static PyObject *WinObj_GetWindowDataHandle(_self, _args)
-	WindowObject *_self;
-	PyObject *_args;
-{
-	PyObject *_res = NULL;
-	Handle _rv;
-	if (!PyArg_ParseTuple(_args, ""))
-		return NULL;
-	_rv = GetWindowDataHandle(_self->ob_itself);
-	_res = Py_BuildValue("O&",
-	                     ResObj_New, _rv);
-	return _res;
-}
-
-static PyObject *WinObj_SetWindowDataHandle(_self, _args)
-	WindowObject *_self;
-	PyObject *_args;
-{
-	PyObject *_res = NULL;
-	Handle data;
-	if (!PyArg_ParseTuple(_args, "O&",
-	                      ResObj_Convert, &data))
-		return NULL;
-	SetWindowDataHandle(_self->ob_itself,
-	                    data);
-	Py_INCREF(Py_None);
-	_res = Py_None;
-	return _res;
-}
+#ifndef TARGET_API_MAC_CARBON
 
 static PyObject *WinObj_CloseWindow(_self, _args)
 	WindowObject *_self;
@@ -1629,6 +1617,7 @@
 	_res = Py_None;
 	return _res;
 }
+#endif
 
 static PyObject *WinObj_MoveWindow(_self, _args)
 	WindowObject *_self;
@@ -1666,8 +1655,6 @@
 }
 
 static PyMethodDef WinObj_methods[] = {
-	{"MacCloseWindow", (PyCFunction)WinObj_MacCloseWindow, 1,
-	 "() -> None"},
 	{"GetWindowOwnerCount", (PyCFunction)WinObj_GetWindowOwnerCount, 1,
 	 "() -> (UInt32 outCount)"},
 	{"CloneWindow", (PyCFunction)WinObj_CloneWindow, 1,
@@ -1676,8 +1663,11 @@
 	 "() -> (WindowClass outClass)"},
 	{"GetWindowAttributes", (PyCFunction)WinObj_GetWindowAttributes, 1,
 	 "() -> (WindowAttributes outAttributes)"},
+
+#ifndef TARGET_API_MAC_CARBON
 	{"SetWinColor", (PyCFunction)WinObj_SetWinColor, 1,
 	 "(WCTabHandle newColorTable) -> None"},
+#endif
 	{"SetWindowContentColor", (PyCFunction)WinObj_SetWindowContentColor, 1,
 	 "() -> (RGBColor color)"},
 	{"GetWindowContentColor", (PyCFunction)WinObj_GetWindowContentColor, 1,
@@ -1688,10 +1678,16 @@
 	 "(PixPatHandle pixPat) -> None"},
 	{"ClipAbove", (PyCFunction)WinObj_ClipAbove, 1,
 	 "() -> None"},
+
+#ifndef TARGET_API_MAC_CARBON
 	{"SaveOld", (PyCFunction)WinObj_SaveOld, 1,
 	 "() -> None"},
+#endif
+
+#ifndef TARGET_API_MAC_CARBON
 	{"DrawNew", (PyCFunction)WinObj_DrawNew, 1,
 	 "(Boolean update) -> None"},
+#endif
 	{"PaintOne", (PyCFunction)WinObj_PaintOne, 1,
 	 "(RgnHandle clobberedRgn) -> None"},
 	{"PaintBehind", (PyCFunction)WinObj_PaintBehind, 1,
@@ -1810,8 +1806,11 @@
 	 "(Point thePt, short partCode) -> (Boolean _rv)"},
 	{"TrackGoAway", (PyCFunction)WinObj_TrackGoAway, 1,
 	 "(Point thePt) -> (Boolean _rv)"},
+
+#ifndef TARGET_API_MAC_CARBON
 	{"GetAuxWin", (PyCFunction)WinObj_GetAuxWin, 1,
 	 "() -> (Boolean _rv, AuxWinHandle awHndl)"},
+#endif
 	{"GetWindowPort", (PyCFunction)WinObj_GetWindowPort, 1,
 	 "() -> (CGrafPtr _rv)"},
 	{"SetPortWindowPort", (PyCFunction)WinObj_SetPortWindowPort, 1,
@@ -1826,16 +1825,31 @@
 	 "() -> (Boolean _rv)"},
 	{"GetWindowGoAwayFlag", (PyCFunction)WinObj_GetWindowGoAwayFlag, 1,
 	 "() -> (Boolean _rv)"},
+
+#ifndef TARGET_API_MAC_CARBON
 	{"GetWindowZoomFlag", (PyCFunction)WinObj_GetWindowZoomFlag, 1,
 	 "() -> (Boolean _rv)"},
+#endif
+
+#ifndef TARGET_API_MAC_CARBON
 	{"GetWindowStructureRgn", (PyCFunction)WinObj_GetWindowStructureRgn, 1,
 	 "(RgnHandle r) -> None"},
+#endif
+
+#ifndef TARGET_API_MAC_CARBON
 	{"GetWindowContentRgn", (PyCFunction)WinObj_GetWindowContentRgn, 1,
 	 "(RgnHandle r) -> None"},
+#endif
+
+#ifndef TARGET_API_MAC_CARBON
 	{"GetWindowUpdateRgn", (PyCFunction)WinObj_GetWindowUpdateRgn, 1,
 	 "(RgnHandle r) -> None"},
+#endif
+
+#ifndef TARGET_API_MAC_CARBON
 	{"GetWindowTitleWidth", (PyCFunction)WinObj_GetWindowTitleWidth, 1,
 	 "() -> (short _rv)"},
+#endif
 	{"GetNextWindow", (PyCFunction)WinObj_GetNextWindow, 1,
 	 "() -> (WindowPtr _rv)"},
 	{"GetWindowStandardState", (PyCFunction)WinObj_GetWindowStandardState, 1,
@@ -1846,12 +1860,11 @@
 	 "(Rect r) -> None"},
 	{"SetWindowUserState", (PyCFunction)WinObj_SetWindowUserState, 1,
 	 "(Rect r) -> None"},
-	{"GetWindowDataHandle", (PyCFunction)WinObj_GetWindowDataHandle, 1,
-	 "() -> (Handle _rv)"},
-	{"SetWindowDataHandle", (PyCFunction)WinObj_SetWindowDataHandle, 1,
-	 "(Handle data) -> None"},
+
+#ifndef TARGET_API_MAC_CARBON
 	{"CloseWindow", (PyCFunction)WinObj_CloseWindow, 1,
 	 "() -> None"},
+#endif
 	{"MoveWindow", (PyCFunction)WinObj_MoveWindow, 1,
 	 "(short hGlobal, short vGlobal, Boolean front) -> None"},
 	{"ShowWindow", (PyCFunction)WinObj_ShowWindow, 1,
@@ -2110,6 +2123,8 @@
 	return _res;
 }
 
+#ifndef TARGET_API_MAC_CARBON
+
 static PyObject *Win_SetDeskCPat(_self, _args)
 	PyObject *_self;
 	PyObject *_args;
@@ -2124,6 +2139,7 @@
 	_res = Py_None;
 	return _res;
 }
+#endif
 
 static PyObject *Win_CheckUpdate(_self, _args)
 	PyObject *_self;
@@ -2174,6 +2190,8 @@
 	return _res;
 }
 
+#ifndef TARGET_API_MAC_CARBON
+
 static PyObject *Win_InitWindows(_self, _args)
 	PyObject *_self;
 	PyObject *_args;
@@ -2186,6 +2204,9 @@
 	_res = Py_None;
 	return _res;
 }
+#endif
+
+#ifndef TARGET_API_MAC_CARBON
 
 static PyObject *Win_GetWMgrPort(_self, _args)
 	PyObject *_self;
@@ -2200,6 +2221,9 @@
 	                     GrafObj_New, wPort);
 	return _res;
 }
+#endif
+
+#ifndef TARGET_API_MAC_CARBON
 
 static PyObject *Win_GetCWMgrPort(_self, _args)
 	PyObject *_self;
@@ -2214,6 +2238,9 @@
 	                     GrafObj_New, wMgrCPort);
 	return _res;
 }
+#endif
+
+#ifndef TARGET_API_MAC_CARBON_NOTYET
 
 static PyObject *Win_IsValidWindowPtr(_self, _args)
 	PyObject *_self;
@@ -2230,6 +2257,9 @@
 	                     _rv);
 	return _res;
 }
+#endif
+
+#ifndef TARGET_API_MAC_CARBON
 
 static PyObject *Win_InitFloatingWindows(_self, _args)
 	PyObject *_self;
@@ -2245,6 +2275,9 @@
 	_res = Py_None;
 	return _res;
 }
+#endif
+
+#ifndef TARGET_API_MAC_CARBON
 
 static PyObject *Win_InvalRect(_self, _args)
 	PyObject *_self;
@@ -2260,6 +2293,9 @@
 	_res = Py_None;
 	return _res;
 }
+#endif
+
+#ifndef TARGET_API_MAC_CARBON
 
 static PyObject *Win_InvalRgn(_self, _args)
 	PyObject *_self;
@@ -2275,6 +2311,9 @@
 	_res = Py_None;
 	return _res;
 }
+#endif
+
+#ifndef TARGET_API_MAC_CARBON
 
 static PyObject *Win_ValidRect(_self, _args)
 	PyObject *_self;
@@ -2290,6 +2329,9 @@
 	_res = Py_None;
 	return _res;
 }
+#endif
+
+#ifndef TARGET_API_MAC_CARBON
 
 static PyObject *Win_ValidRgn(_self, _args)
 	PyObject *_self;
@@ -2305,6 +2347,7 @@
 	_res = Py_None;
 	return _res;
 }
+#endif
 
 static PyObject *Win_CollapseAllWindows(_self, _args)
 	PyObject *_self;
@@ -2410,32 +2453,62 @@
 	 "() -> (Boolean _rv)"},
 	{"FrontNonFloatingWindow", (PyCFunction)Win_FrontNonFloatingWindow, 1,
 	 "() -> (WindowPtr _rv)"},
+
+#ifndef TARGET_API_MAC_CARBON
 	{"SetDeskCPat", (PyCFunction)Win_SetDeskCPat, 1,
 	 "(PixPatHandle deskPixPat) -> None"},
+#endif
 	{"CheckUpdate", (PyCFunction)Win_CheckUpdate, 1,
 	 "() -> (Boolean _rv, EventRecord theEvent)"},
 	{"MacFindWindow", (PyCFunction)Win_MacFindWindow, 1,
 	 "(Point thePoint) -> (short _rv, WindowPtr window)"},
 	{"FrontWindow", (PyCFunction)Win_FrontWindow, 1,
 	 "() -> (WindowPtr _rv)"},
+
+#ifndef TARGET_API_MAC_CARBON
 	{"InitWindows", (PyCFunction)Win_InitWindows, 1,
 	 "() -> None"},
+#endif
+
+#ifndef TARGET_API_MAC_CARBON
 	{"GetWMgrPort", (PyCFunction)Win_GetWMgrPort, 1,
 	 "() -> (GrafPtr wPort)"},
+#endif
+
+#ifndef TARGET_API_MAC_CARBON
 	{"GetCWMgrPort", (PyCFunction)Win_GetCWMgrPort, 1,
 	 "() -> (CGrafPtr wMgrCPort)"},
+#endif
+
+#ifndef TARGET_API_MAC_CARBON_NOTYET
 	{"IsValidWindowPtr", (PyCFunction)Win_IsValidWindowPtr, 1,
 	 "(GrafPtr grafPort) -> (Boolean _rv)"},
+#endif
+
+#ifndef TARGET_API_MAC_CARBON
 	{"InitFloatingWindows", (PyCFunction)Win_InitFloatingWindows, 1,
 	 "() -> None"},
+#endif
+
+#ifndef TARGET_API_MAC_CARBON
 	{"InvalRect", (PyCFunction)Win_InvalRect, 1,
 	 "(Rect badRect) -> None"},
+#endif
+
+#ifndef TARGET_API_MAC_CARBON
 	{"InvalRgn", (PyCFunction)Win_InvalRgn, 1,
 	 "(RgnHandle badRgn) -> None"},
+#endif
+
+#ifndef TARGET_API_MAC_CARBON
 	{"ValidRect", (PyCFunction)Win_ValidRect, 1,
 	 "(Rect goodRect) -> None"},
+#endif
+
+#ifndef TARGET_API_MAC_CARBON
 	{"ValidRgn", (PyCFunction)Win_ValidRgn, 1,
 	 "(RgnHandle goodRgn) -> None"},
+#endif
 	{"CollapseAllWindows", (PyCFunction)Win_CollapseAllWindows, 1,
 	 "(Boolean collapse) -> None"},
 	{"PinRect", (PyCFunction)Win_PinRect, 1,