Getting rid of pre-Carbon (MacOS8) support. All code depending on
TARGET_API_MAC_OS8 (or !TARGET_API_MAC_CARBON) is gone. Also some
TARGET_API_MAC_OSX conditional code is gone, because it is no longer
used on OSX-only Python (only in MacPython-OS9).
diff --git a/Mac/Python/macgetargv.c b/Mac/Python/macgetargv.c
index 8fdbad5..180de33 100644
--- a/Mac/Python/macgetargv.c
+++ b/Mac/Python/macgetargv.c
@@ -54,11 +54,7 @@
 #include "Python.h"
 #include "macglue.h"
 
-#ifdef TARGET_API_MAC_OSX
-#define PATHNAMELEN 1024
-#else
 #define PATHNAMELEN 256
-#endif
 
 static int arg_count;
 static char *arg_vector[256];
@@ -79,8 +75,6 @@
 }
 #endif
 
-
-#if !TARGET_API_MAC_OSX
 /* Initialize FSSpec and full name of current application */
 
 OSErr
@@ -104,7 +98,6 @@
 	applocation_inited = 1;
 	return 0;
 }
-#endif /* !TARGET_API_MAC_OSX */
 
 /* Check that there aren't any args remaining in the event */
 
@@ -229,9 +222,6 @@
 	
 	got_one = 0;
 	for (n = 0; n < 100 && !got_one; n++) {
-#if !TARGET_API_MAC_CARBON
-		SystemTask();
-#endif
 		ok = GetNextEvent(everyEvent, &event);
 		if (ok && event.what == kHighLevelEvent) {
 			AEProcessAppleEvent(&event);
@@ -245,13 +235,8 @@
 PyMac_GetArgv(char ***pargv, int noevents)
 {
 	arg_count = 0;
-#if TARGET_API_MAC_OSX
-	/* In an OSX bundle argv[0] is okay */
-	arg_count++;
-#else
 	(void)PyMac_init_process_location();
 	arg_vector[arg_count++] = strdup(PyMac_ApplicationPath);
-#endif /* TARGET_API_MAC_OSX */
 	
 	if( !noevents ) {
 		set_ae_handlers();
diff --git a/Mac/Python/macgetcompiler.c b/Mac/Python/macgetcompiler.c
index a5c72fa..b5da2bf 100644
--- a/Mac/Python/macgetcompiler.c
+++ b/Mac/Python/macgetcompiler.c
@@ -47,13 +47,7 @@
 #define HASTHREAD " WITHOUT_THREAD"
 #endif
 
-#if TARGET_API_MAC_CARBON
-#define TARGET_API ""
-#else
-#define TARGET_API " PPC"
-#endif
-
-#define COMPILER " [CW" TARGET_API HASGUSI HASTHREAD"]"
+#define COMPILER " [CW" HASGUSI HASTHREAD"]"
 #endif
 
 #ifdef MPW
diff --git a/Mac/Python/macgetpath.c b/Mac/Python/macgetpath.c
index b79d555..d98d481 100644
--- a/Mac/Python/macgetpath.c
+++ b/Mac/Python/macgetpath.c
@@ -38,11 +38,7 @@
 #include <unistd.h>
 #endif
 
-#ifdef TARGET_API_MAC_OSX
-#define PATHNAMELEN 1024
-#else
 #define PATHNAMELEN 256
-#endif
 
 /* Return the initial python search path.  This is called once from
 ** initsys() to initialize sys.path.
diff --git a/Mac/Python/macglue.c b/Mac/Python/macglue.c
index 25bc3f7..51d73ed 100644
--- a/Mac/Python/macglue.c
+++ b/Mac/Python/macglue.c
@@ -51,11 +51,6 @@
 #include <Carbon/Carbon.h>
 #endif
 
-#if !TARGET_API_MAC_OS8
-/* Unfortunately this call is probably slower... */
-#define LMGetTicks() TickCount()
-#endif
-
 #ifdef __MWERKS__
 #include <SIOUX.h>
 extern void SIOUXSetupMenus(void);
@@ -85,7 +80,6 @@
 #define MINIMUM_STACK_SIZE 8192
 #endif
 
-#if TARGET_API_MAC_CARBON
 /*
 ** On MacOSX StackSpace() lies: it gives the distance from heap end to stack pointer,
 ** but the stack cannot grow that far due to rlimit values. We cannot get at this value
@@ -93,7 +87,6 @@
 ** stack limit of 512K.
 */
 #define MAXIMUM_STACK_SIZE (256*1024)
-#endif
 
 /*
 ** We have to be careful, since we can't handle
@@ -148,23 +141,6 @@
 static MenuBarHandle sioux_mbar;
 
 /*
-** Some stuff for our GetDirectory and PromptGetFile routines
-*/
-struct hook_args {
-	int selectcur_hit;		/* Set to true when "select current" selected */
-	char *prompt;			/* The prompt */
-};
-#if !TARGET_API_MAC_OS8
-/* The StandardFile hooks don't exist in Carbon. This breaks GetDirectory,
-** but the macfsn code will replace it by a NavServices version anyway.
-*/
-#define myhook_upp NULL
-#else
-static DlgHookYDUPP myhook_upp;
-static int upp_inited = 0;
-#endif
-
-/*
 ** The python-code event handler
 */
 static PyObject *python_event_handler;
@@ -256,48 +232,6 @@
 	PyMac_ConsoleIsDead = 1;
 }
 
-#if TARGET_API_MAC_OS8
-/*
-** Replacement routines for the PLstr... functions so we don't need
-** StdCLib.
-*/
-pascal void
-PLstrcpy(unsigned char *to, unsigned char *fr)
-{
-	memcpy(to, fr, fr[0]+1);
-}
-
-pascal int
-PLstrcmp(unsigned char *s1, unsigned char *s2)
-{
-	int res;
-	int l = s1[0] < s2[0] ? s1[0] : s2[0];
-	
-	res = memcmp(s1+1, s2+1, l);
-	if ( res != 0 )
-		return res;
-	
-	if ( s1[0] < s2[0] )
-		return -1;
-	else if ( s1[0] > s2[0] )
-		return 1;
-	else
-		return 0;
-}
-
-pascal unsigned char *
-PLstrrchr(unsigned char *str, unsigned char chr)
-{
-	unsigned char *ptr = 0;
-	unsigned char *p;
-	
-	for(p=str+1; p<str+str[0]; p++)
-		if ( *p == chr )
-			ptr = p;
-	return ptr;
-}
-	
-#endif /* TARGET_API_MAC_OS8 */
 #endif /* USE_GUSI */
 
 
@@ -316,29 +250,6 @@
 	return buf;
 }
 
-#if TARGET_API_MAC_OS8
-Point
-LMGetMouse(void)
-{
-	return LMGetMouseLocation();
-}
-
-long LMGetExpandMem(void)
-{
-	return 0;
-}
-
-void
-c2pstrcpy(unsigned char *dst, const char *src)
-{
-	int len;
-	
-	len = strlen(src);
-	if ( len > 255 ) len = 255;
-	strncpy((char *)dst+1, src, len);
-	dst[0] = len;
-}
-#endif /* TARGET_API_MAC_OS8 */
 
 #ifdef USE_STACKCHECK
 /* Check for stack overflow */
@@ -420,35 +331,17 @@
 scan_event_queue(force)
 	int force;
 {
-#if !TARGET_API_MAC_OS8
 	if ( interrupted || (!schedparams.check_interrupt && !force) )
 		return;
 	if ( CheckEventQueueForUserCancel() )
 		interrupted = 1;
-#else
-	register EvQElPtr q;
-	
-	if ( interrupted || (!schedparams.check_interrupt && !force) || !PyMac_InForeground() )
-		return;
-	q = (EvQElPtr) LMGetEventQueue()->qHead;
-	
-	for (; q; q = (EvQElPtr)q->qLink) {
-		if (q->evtQWhat == keyDown &&
-				(char)q->evtQMessage == '.' &&
-				(q->evtQModifiers & cmdKey) != 0) {
-			FlushEvents(keyDownMask, 0);
-			interrupted = 1;
-			break;
-		}
-	}
-#endif
 }
 
 int
 PyErr_CheckSignals()
 {
 	if (schedparams.enabled) {
-		if ( interrupted || (unsigned long)LMGetTicks() > schedparams.next_check ) {
+		if ( interrupted || (unsigned long)TickCount() > schedparams.next_check ) {
 			scan_event_queue(0);
 			if (interrupted) {
 				interrupted = 0;
@@ -457,7 +350,7 @@
 			}
 			if ( PyMac_Yield() < 0)
 				return -1;
-			schedparams.next_check = (unsigned long)LMGetTicks()
+			schedparams.next_check = (unsigned long)TickCount()
 					 + schedparams.check_interval;
 		}
 	}
@@ -498,16 +391,6 @@
 PyMac_HandleEventIntern(evp)
 	EventRecord *evp;
 {
-#if TARGET_API_MAC_OS8
-	if ( evp->what == mouseDown ) {
-		WindowPtr wp;
-		
-		if ( FindWindow(evp->where, &wp) == inSysWindow ) {
-			SystemClick(evp, wp);
-			return;
-		}
-	}
-#endif
 #ifdef __MWERKS__
 	{
 		int siouxdidit;
@@ -568,14 +451,10 @@
 	if( in_here > 1 || !schedparams.process_events || 
 	    (python_event_handler && !maycallpython) ) {
 		if ( maxsleep >= 0 ) {
-#if TARGET_API_MAC_OS8
-			SystemTask();
-#else
-			int xxx = 0;
-#endif
+			/* XXXX Need to do something here */
 		}
 	} else {
-		latest_time_ready = LMGetTicks() + maxsleep;
+		latest_time_ready = TickCount() + maxsleep;
 		do {
 			/* XXXX Hack by Jack.
 			** In time.sleep() you can click to another application
@@ -590,7 +469,7 @@
 				in_here--;
 				return -1;
 			}
-			maxsleep = latest_time_ready - LMGetTicks();
+			maxsleep = latest_time_ready - TickCount();
 		} while ( maxsleep > 0 );
 	}
 	in_here--;
@@ -730,82 +609,3 @@
 }
 
 #endif /* !TARGET_API_MAC_OSX */
-
-#if TARGET_API_MAC_OS8
-/*
-** Helper routine for GetDirectory
-*/
-static pascal short
-myhook_proc(short item, DialogPtr theDialog, struct hook_args *dataptr)
-{
-	if ( item == sfHookFirstCall && dataptr->prompt) {
-		Handle prompth;
-		short type;
-		Rect rect;
-		
-		GetDialogItem(theDialog, PROMPT_ITEM, &type, &prompth, &rect);
-		if ( prompth )
-			SetDialogItemText(prompth, (unsigned char *)dataptr->prompt);
-	} else
-	if ( item == SELECTCUR_ITEM ) {
-		item = sfItemCancelButton;
-		dataptr->selectcur_hit = 1;
-	}
-	return item;
-}	
-
-/*
-** Ask the user for a directory. I still can't understand
-** why Apple doesn't provide a standard solution for this...
-*/
-int
-PyMac_GetDirectory(dirfss, prompt)
-	FSSpec *dirfss;
-	char *prompt;
-{
-	static SFTypeList list = {'fldr', 0, 0, 0};
-	static Point where = {-1, -1};
-	StandardFileReply reply;
-	struct hook_args hook_args;
-	
-	if ( !upp_inited ) {
-		myhook_upp = NewDlgHookYDProc(myhook_proc);
-		upp_inited = 1;
-	}
-	if ( prompt && *prompt )
-		hook_args.prompt = (char *)Pstring(prompt);
-	else
-		hook_args.prompt = NULL;
-	hook_args.selectcur_hit = 0;
-	CustomGetFile((FileFilterYDUPP)0, 1, list, &reply, GETDIR_ID, where, myhook_upp,
-				NULL, NULL, NULL, (void *)&hook_args);
-				
-	reply.sfFile.name[0] = 0;
-	if( FSMakeFSSpec(reply.sfFile.vRefNum, reply.sfFile.parID, reply.sfFile.name, dirfss) )
-		return 0;
-	return hook_args.selectcur_hit;
-}
-
-/*
-** Slightly extended StandardGetFile: accepts a prompt */
-void PyMac_PromptGetFile(short numTypes, ConstSFTypeListPtr typeList, 
-		StandardFileReply *reply, char *prompt)
-{
-	static Point where = {-1, -1};
-	struct hook_args hook_args;
-	
-	if ( !upp_inited ) {
-		myhook_upp = NewDlgHookYDProc(myhook_proc);
-		upp_inited = 1;
-	}
-	if ( prompt && *prompt )
-		hook_args.prompt = (char *)Pstring(prompt);
-	else
-		hook_args.prompt = NULL;
-	hook_args.selectcur_hit = 0;
-	CustomGetFile((FileFilterYDUPP)0, numTypes, typeList, reply, GETFILEPROMPT_ID, where,
-				myhook_upp, NULL, NULL, NULL, (void *)&hook_args);
-}
-#endif /* TARGET_API_MAC_OS8 */
-
-
diff --git a/Mac/Python/macmain.c b/Mac/Python/macmain.c
index 9e5a300..1af38eb 100644
--- a/Mac/Python/macmain.c
+++ b/Mac/Python/macmain.c
@@ -38,13 +38,11 @@
 #include <Windows.h>
 #include <Fonts.h>
 #include <Balloons.h>
-#if TARGET_API_MAC_CARBON
 #include <CFBundle.h>
 #include <CFURL.h>
 #include <CFString.h>
 #include <CFBase.h>
 #include <CFArray.h>
-#endif /* TARGET_API_MAC_CARBON */
 #include <Gestalt.h>
 #include <Appearance.h>
 #else
@@ -94,16 +92,6 @@
 static void
 init_mac_world(void)
 {
-#if !TARGET_API_MAC_CARBON
-	/* These aren't needed for carbon */
-	MaxApplZone();
-	InitGraf(&qd.thePort);
-	InitFonts();
-	InitWindows();
-	TEInit();
-	InitDialogs((long)0);
-	InitMenus();
-#endif
 	InitCursor();
 }
 
@@ -176,12 +164,6 @@
 			DisposeDialog(dialog);
 			exit(0);
 		}
-#if !TARGET_API_MAC_CARBON
-		if ( item == OPT_HELP ) {
-			HMSetBalloons(!HMGetBalloons());
-		}
-#endif
-#if !TARGET_API_MAC_OSX
 		if ( item == OPT_CMDLINE ) {
 			int old_argc = *argcp;
 			int i;
@@ -202,7 +184,6 @@
 			
 			/* XXXX Is it not safe to use free() here, apparently */
 		}
-#endif /* !TARGET_API_MAC_OSX */
 #define OPT_ITEM(num, var) \
 		if ( item == (num) ) { \
 			p->var = !p->var; \
@@ -279,9 +260,7 @@
 	/* Get options from preference file (or from applet resource fork) */
 	PyMac_options.keep_console = POPT_KEEPCONSOLE_OUTPUT;		/* default-default */
 	PyMac_options.unixnewlines = 1;
-#if !TARGET_API_MAC_OSX
 	PyMac_PreferenceOptions(&PyMac_options);
-#endif
 
 	if ( embedded ) {
 		static char *emb_argv[] = {"embedded-python", 0};
@@ -293,11 +272,7 @@
 		** In MachoPython we skip this step if we already have plausible
 		** command line arguments.
 		*/
-#if TARGET_API_MAC_OSX
-		if (*argcp == 2 && strncmp((*argvp)[1], "-psn_", 5) == 0)
-#endif
 			*argcp = PyMac_GetArgv(argvp, PyMac_options.noargs);
-#if !TARGET_API_MAC_OSX
 #ifndef NO_ARGV0_CHDIR
 		if (*argcp >= 1 && (*argvp)[0] && (*argvp)[0][0]) {
 			/* Workaround for MacOS X, which currently (DP4) doesn't set
@@ -311,7 +286,6 @@
 			chdir(app_wd);
 		}
 #endif
-#endif
 		/* Do interactive option setting, if allowed and <option> depressed */
 		PyMac_InteractiveOptions(&PyMac_options, argcp, argvp);
 	}
@@ -324,7 +298,6 @@
 	Py_NoSiteFlag = PyMac_options.nosite;
 	Py_TabcheckFlag = PyMac_options.tabwarn;
 	Py_DivisionWarningFlag = PyMac_options.divisionwarn;
-#if !TARGET_API_MAC_OSX
 	if ( PyMac_options.noargs ) {
 		/* don't process events at all without the scripts permission */
 		PyMacSchedParams scp;
@@ -334,7 +307,6 @@
 		/* Should we disable command-dot as well? */
 		PyMac_SetSchedParams(&scp);
 	}
-#endif /* !TARGET_API_MAC_OSX */
 
 	/* Set buffering */
 	if (PyMac_options.unbuffered) {
@@ -446,103 +418,6 @@
 
 #endif /* USE_MAC_APPLET_SUPPORT */
 
-#if TARGET_API_MAC_OSX /* Really: TARGET_API_MAC_CARBON */
-
-static int
-locateResourcePy(CFStringRef resourceType, char *resourceName, char *resourceURLCStr, int length)
-{
-    CFBundleRef mainBundle = NULL;
-    CFURLRef URL, absoluteURL;
-    CFStringRef filenameString, filepathString, rsrcString;
-    CFIndex size, i;
-    CFArrayRef arrayRef = NULL;
-    int success = 0;
-    
-#if TARGET_API_MAC_OSX
-	CFURLPathStyle thePathStyle = kCFURLPOSIXPathStyle;
-#else
-	CFURLPathStyle thePathStyle = kCFURLHFSPathStyle;
-#endif
-
-    /* Get a reference to our main bundle */
-    mainBundle = CFBundleGetMainBundle();
-
-	/* If we are running inside a bundle, look through it. Otherwise, do nothing. */
-	if (mainBundle) {
-	    /* Create a CFString with the resource name in it */
-	    rsrcString = CFStringCreateWithCString(0, resourceName, kCFStringEncodingMacRoman);
-
-	    /* Look for py files in the main bundle by type */
-	    arrayRef = CFBundleCopyResourceURLsOfType( mainBundle, 
-	            resourceType, 
-	           NULL );
-
-	    /* See if there are any filename matches */
-	    size = CFArrayGetCount(arrayRef);
-	    for (i = 0; i < size; i++) {
-	        URL = CFArrayGetValueAtIndex(arrayRef, i);
-	        filenameString = CFURLCopyLastPathComponent(URL);
-	        if (CFStringCompare(filenameString, rsrcString, 0) == kCFCompareEqualTo) {
-	            /* We found a match, get the file's full path */
-	            absoluteURL = CFURLCopyAbsoluteURL(URL);
-	            filepathString = CFURLCopyFileSystemPath(absoluteURL, thePathStyle);
-	            CFRelease(absoluteURL);
-
-	            /* Copy the full path into the caller's character buffer */
-	            success = CFStringGetCString(filepathString, resourceURLCStr, length,
-	                                        kCFStringEncodingMacRoman);
-
-	            CFRelease(filepathString);
-	        }
-	        CFRelease(filenameString);
-	    }
-		CFRelease(arrayRef);
-	    CFRelease(rsrcString);
-	}
-    return success;
-}
-
-#endif /* TARGET_API_MAC_CARBON */
-
-#if TARGET_API_MAC_OSX
-
-int
-main(int argc, char **argv)
-{
-    static char scriptpath[1024];
-    char *script = NULL;
-
-	/* First we see whether we have __rawmain__.py and run that if it
-	** is there
-	*/
-	if (locateResourcePy(CFSTR("py"), "__rawmain__.py", scriptpath, 1024)) {
-		/* If we have a raw main we don't do AppleEvent processing.
-		** Notice that this also means we keep the -psn.... argv[1]
-		** value intact. Not sure whether that is important to someone,
-		** but you never know...
-		*/
-		script = scriptpath;
-	} else if (locateResourcePy(CFSTR("pyc"), "__rawmain__.pyc", scriptpath, 1024)) {
-		script = scriptpath;
-	} else {
-		/* Otherwise we look for __main__.py. Whether that is
-		** found or not we also process AppleEvent arguments.
-		*/
-		if (locateResourcePy(CFSTR("py"), "__main__.py", scriptpath, 1024))
-			script = scriptpath;
-		else if (locateResourcePy(CFSTR("pyc"), "__main__.pyc", scriptpath, 1024))
-			script = scriptpath;
-			
-		init_common(&argc, &argv, 0);
-
-	}
-
-	PyMac_Main(argc, argv, script);
-    return 0;
-}
-
-#else
-
 /* For normal application */
 void
 PyMac_InitApplication(void)
@@ -556,12 +431,6 @@
 
 	init_common(&argc, &argv, 0);
 
-#if TARGET_API_MAC_OSX /* Really: TARGET_API_MAC_CARBON */
-	/* If we are running inside of a bundle, and a __main__.py is available, use it */
-	if (locateResourcePy("__main__.py", scriptpath, 1024))
-		script = scriptpath;
-#endif
-	
 	if ( argc > 1 ) {
 		/* We're running a script. Attempt to change current directory */
 		char curwd[256], *endp;
@@ -582,7 +451,6 @@
 	}
 	PyMac_Main(argc, argv, script);
 }
-#endif /* TARGET_API_MAC_OSX */
 
 /* Main program */
 
@@ -605,11 +473,7 @@
 	if (Py_VerboseFlag ||
 	    (command == NULL && filename == NULL && isatty((int)fileno(fp))))
 		fprintf(stderr, "%s %s on %s\n%s\n",
-#if !TARGET_API_MAC_OSX
 			"Python",
-#else
-			"Pythonw",
-#endif
 			Py_GetVersion(), Py_GetPlatform(), COPYRIGHT);
 	
 	if (filename != NULL) {
@@ -620,10 +484,8 @@
 		}
 	}
 	
-#if !TARGET_API_MAC_OSX
 	/* We initialize the menubar here, hoping SIOUX is initialized by now */
 	PyMac_InitMenuBar();
-#endif
 
 	Py_Initialize();
 	
@@ -651,7 +513,6 @@
 	/*NOTREACHED*/
 }
 
-#if !TARGET_API_MAC_OSX
 /*
 ** Reset the "unseen output" flag
 */
@@ -683,7 +544,6 @@
 	console_output_state = STATE_LASTWRITE;
 	PyMac_Exit(1);
 }
-#endif /* !TARGET_API_MAC_OSX */
 
 /*
 ** Terminate application
@@ -739,7 +599,6 @@
 	exit(status);
 }
 
-#if !TARGET_API_MAC_OSX
 /* Make the *original* argc/argv available to other modules.
    This is rare, but it is needed by the secureware extension. */
 
@@ -749,10 +608,8 @@
 	*argc = orig_argc;
 	*argv = orig_argv;
 }
-#endif
 
 /* More cruft that shouldn't really be here, used in sysmodule.c */
-#if !TARGET_API_MAC_OSX
 /* Return the program name -- some code out there needs this. */
 char *
 Py_GetProgramFullPath(void)
@@ -796,5 +653,4 @@
 			*p = '\r';
 }
 #endif /* WITHOUT_UNIX_NEWLINES */
-#endif /* !TARGET_API_MAC_OSX */
 
diff --git a/Mac/Python/pyGUSISIOUX.cp b/Mac/Python/pyGUSISIOUX.cp
index 8a51618..4e63ebe 100644
--- a/Mac/Python/pyGUSISIOUX.cp
+++ b/Mac/Python/pyGUSISIOUX.cp
@@ -174,19 +174,6 @@
 }
 static bool input_pending()
 {
-#if !TARGET_API_MAC_CARBON
-	// Jack thinks that completely removing this code is a bit
-	// too much...
-	QHdrPtr eventQueue = LMGetEventQueue();
-	EvQElPtr element = (EvQElPtr)eventQueue->qHead;
-	
-	// now, count the number of pending keyDown events.
-	while (element != nil) {
-		if (element->evtQWhat == keyDown || element->evtQWhat == autoKey)
-			return true;
-		element = (EvQElPtr)element->qLink;
-	}
-#endif
 	return false;
 }