55
66#define PYOSINPUTHOOK_REPETITIVE 1 /* Remove this once Python is fixed */
77
8- #if PY_MAJOR_VERSION >= 3
9- #define PY3K 1
10- #else
11- #define PY3K 0
12- #endif
13-
148/* Proper way to check for the OS X version we are compiling for, from
159 http://developer.apple.com/documentation/DeveloperTools/Conceptual/cross_development */
1610#if __MAC_OS_X_VERSION_MIN_REQUIRED >= 1060
@@ -325,13 +319,8 @@ static CGFloat _get_device_scale(CGContextRef cr)
325319static PyObject*
326320FigureCanvas_repr (FigureCanvas* self)
327321{
328- #if PY3K
329322 return PyUnicode_FromFormat (" FigureCanvas object %p wrapping NSView %p " ,
330323 (void *)self, (void *)(self->view ));
331- #else
332- return PyString_FromFormat (" FigureCanvas object %p wrapping NSView %p " ,
333- (void *)self, (void *)(self->view ));
334- #endif
335324}
336325
337326static PyObject*
@@ -730,13 +719,8 @@ static CGFloat _get_device_scale(CGContextRef cr)
730719static PyObject*
731720FigureManager_repr (FigureManager* self)
732721{
733- #if PY3K
734722 return PyUnicode_FromFormat (" FigureManager object %p wrapping NSWindow %p " ,
735723 (void *) self, (void *)(self->window ));
736- #else
737- return PyString_FromFormat (" FigureManager object %p wrapping NSWindow %p " ,
738- (void *) self, (void *)(self->window ));
739- #endif
740724}
741725
742726static void
@@ -1197,11 +1181,7 @@ -(void)save_figure:(id)sender
11971181static PyObject*
11981182NavigationToolbar_repr (NavigationToolbar* self)
11991183{
1200- #if PY3K
12011184 return PyUnicode_FromFormat (" NavigationToolbar object %p " , (void *)self);
1202- #else
1203- return PyString_FromFormat (" NavigationToolbar object %p " , (void *)self);
1204- #endif
12051185}
12061186
12071187static char NavigationToolbar_doc[] =
@@ -1743,11 +1723,7 @@ -(void)save_figure:(id)sender
17431723static PyObject*
17441724NavigationToolbar2_repr (NavigationToolbar2* self)
17451725{
1746- #if PY3K
17471726 return PyUnicode_FromFormat (" NavigationToolbar2 object %p " , (void *)self);
1748- #else
1749- return PyString_FromFormat (" NavigationToolbar2 object %p " , (void *)self);
1750- #endif
17511727}
17521728
17531729static char NavigationToolbar2_doc[] =
@@ -1758,11 +1734,7 @@ -(void)save_figure:(id)sender
17581734{
17591735 const char * message;
17601736
1761- #if PY3K
17621737 if (!PyArg_ParseTuple (args, " y" , &message)) return NULL ;
1763- #else
1764- if (!PyArg_ParseTuple (args, " s" , &message)) return NULL ;
1765- #endif
17661738
17671739 NSText * messagebox = self->messagebox ;
17681740
@@ -1869,11 +1841,7 @@ -(void)save_figure:(id)sender
18691841 unsigned int n = [filename length ];
18701842 unichar * buffer = malloc (n*sizeof (unichar ));
18711843 [filename getCharacters: buffer];
1872- #if PY3K
1873- PyObject* string = PyUnicode_FromKindAndData (PyUnicode_2BYTE_KIND, buffer, n);
1874- #else
1875- PyObject* string = PyUnicode_FromUnicode (buffer, n);
1876- #endif
1844+ PyObject* string = PyUnicode_FromKindAndData (PyUnicode_2BYTE_KIND, buffer, n);
18771845 free (buffer);
18781846 return string;
18791847 }
@@ -2855,13 +2823,8 @@ - (int)index
28552823static PyObject*
28562824Timer_repr (Timer* self)
28572825{
2858- #if PY3K
28592826 return PyUnicode_FromFormat (" Timer object %p wrapping CFRunLoopTimerRef %p " ,
28602827 (void *) self, (void *)(self->timer ));
2861- #else
2862- return PyString_FromFormat (" Timer object %p wrapping CFRunLoopTimerRef %p " ,
2863- (void *) self, (void *)(self->timer ));
2864- #endif
28652828}
28662829
28672830static char Timer_doc[] =
@@ -3092,8 +3055,6 @@ static bool verify_framework(void)
30923055 {NULL , NULL , 0 , NULL }/* sentinel */
30933056};
30943057
3095- #if PY3K
3096-
30973058static struct PyModuleDef moduledef = {
30983059 PyModuleDef_HEAD_INIT,
30993060 " _macosx" ,
@@ -3107,11 +3068,6 @@ static bool verify_framework(void)
31073068};
31083069
31093070PyObject* PyInit__macosx (void )
3110-
3111- #else
3112-
3113- void init_macosx (void )
3114- #endif
31153071{
31163072 PyObject *module;
31173073
@@ -3120,31 +3076,15 @@ void init_macosx(void)
31203076 || PyType_Ready (&NavigationToolbarType) < 0
31213077 || PyType_Ready (&NavigationToolbar2Type) < 0
31223078 || PyType_Ready (&TimerType) < 0 )
3123- #if PY3K
31243079 return NULL ;
3125- #else
3126- return ;
3127- #endif
31283080
31293081 NSApp = [NSApplication sharedApplication ];
31303082
31313083 if (!verify_framework ())
3132- #if PY3K
31333084 return NULL ;
3134- #else
3135- return ;
3136- #endif
31373085
3138- #if PY3K
31393086 module = PyModule_Create (&moduledef);
31403087 if (module==NULL ) return NULL ;
3141- #else
3142- module = Py_InitModule4 (" _macosx" ,
3143- methods,
3144- " Mac OS X native backend" ,
3145- NULL ,
3146- PYTHON_API_VERSION);
3147- #endif
31483088
31493089 Py_INCREF (&FigureCanvasType);
31503090 Py_INCREF (&FigureManagerType);
@@ -3168,7 +3108,5 @@ void init_macosx(void)
31683108 name: NSWorkspaceDidLaunchApplicationNotification
31693109 object: nil ];
31703110 [pool release ];
3171- #if PY3K
31723111 return module;
3173- #endif
31743112}
0 commit comments