Skip to content

Commit 5c19722

Browse files
committed
Merge pull request matplotlib#675 from nlhepler/master
Misc fixes for py3k macosx backend
2 parents ec0d33d + 6d80ff2 commit 5c19722

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

src/_macosx.m

+19
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,12 @@
55
#include "numpy/arrayobject.h"
66
#include "path_cleanup.h"
77

8+
#if PY_MAJOR_VERSION >= 3
9+
#define PY3K 1
10+
#else
11+
#define PY3K 0
12+
#endif
13+
814
/* Must define Py_TYPE for Python 2.5 or older */
915
#ifndef Py_TYPE
1016
# define Py_TYPE(o) ((o)->ob_type)
@@ -714,7 +720,11 @@ static int _get_snap(GraphicsContext* self, enum e_snap_mode* mode)
714720
if (offset!=Py_None)
715721
{
716722
if (PyFloat_Check(offset)) phase = PyFloat_AsDouble(offset);
723+
#if PY3K
724+
else if (PyLong_Check(offset)) phase = PyLong_AsLong(offset);
725+
#else
717726
else if (PyInt_Check(offset)) phase = PyInt_AsLong(offset);
727+
#endif
718728
else
719729
{
720730
PyErr_SetString(PyExc_TypeError,
@@ -747,8 +757,13 @@ static int _get_snap(GraphicsContext* self, enum e_snap_mode* mode)
747757
PyObject* value = PyTuple_GET_ITEM(dashes, i);
748758
if (PyFloat_Check(value))
749759
lengths[i] = (CGFloat) PyFloat_AS_DOUBLE(value);
760+
#if PY3K
761+
else if (PyLong_Check(value))
762+
lengths[i] = (CGFloat) PyLong_AsLong(value);
763+
#else
750764
else if (PyInt_Check(value))
751765
lengths[i] = (CGFloat) PyInt_AS_LONG(value);
766+
#endif
752767
else break;
753768
}
754769
Py_DECREF(dashes);
@@ -5847,4 +5862,8 @@ void init_macosx(void)
58475862
PyModule_AddObject(module, "Timer", (PyObject*) &TimerType);
58485863

58495864
PyOS_InputHook = wait_for_stdin;
5865+
5866+
#if PY3K
5867+
return module;
5868+
#endif
58505869
}

0 commit comments

Comments
 (0)