Index: setup.py =================================================================== --- setup.py (revision 81023) +++ setup.py (working copy) @@ -1539,7 +1539,8 @@ frameworks.append('-arch') frameworks.append(a) - ext = Extension('_tkinter', ['_tkinter.c', 'tkappinit.c'], + + ext = Extension('_tkinter', ['_tkinter.m', 'tkappinit.c'], define_macros=[('WITH_APPINIT', 1)], include_dirs = include_dirs, libraries = [], Index: Modules/_tkinter.c =================================================================== --- Modules/_tkinter.c (revision 81023) +++ Modules/_tkinter.c (working copy) @@ -33,6 +33,12 @@ #include #endif +#ifdef __APPLE__ +#define Cursor FndCursor +#import +#undef Cursor +#endif + /* Allow using this code in Python 2.[12] */ #ifndef PyDoc_STRVAR #define PyDoc_STRVAR(name,str) static char name[] = str @@ -3100,6 +3106,10 @@ static int EventHook(void) { +#ifdef __APPLE__ + int errorInTk = 0; +#endif + #ifndef MS_WINDOWS int tfile; #endif @@ -3125,7 +3135,16 @@ if(tcl_lock)PyThread_acquire_lock(tcl_lock, 1); tcl_tstate = event_tstate; +#ifdef __APPLE__ + NS_DURING +#endif result = Tcl_DoOneEvent(TCL_DONT_WAIT); +#ifdef __APPLE__ + NS_HANDLER + result = -1; + errorInTk = 1; + NS_ENDHANDLER +#endif tcl_tstate = NULL; if(tcl_lock)PyThread_release_lock(tcl_lock); @@ -3142,6 +3161,11 @@ #ifndef MS_WINDOWS Tcl_DeleteFileHandler(tfile); #endif +#ifdef __APPLE__ + if (errorInTk) { + PySys_WriteStderr("Unexpected Objective-C exception in Tk\n"); + } +#endif if (errorInCmd) { errorInCmd = 0; PyErr_Restore(excInCmd, valInCmd, trbInCmd); Index: Modules/_tkinter.m =================================================================== --- Modules/_tkinter.m (revision 0) +++ Modules/_tkinter.m (revision 0) @@ -0,0 +1 @@ +#include "_tkinter.c"