|
5 | 5 | #include "numpy/arrayobject.h"
|
6 | 6 | #include "path_cleanup.h"
|
7 | 7 |
|
| 8 | +#if PY_MAJOR_VERSION >= 3 |
| 9 | +#define PY3K 1 |
| 10 | +#else |
| 11 | +#define PY3K 0 |
| 12 | +#endif |
| 13 | + |
8 | 14 | /* Must define Py_TYPE for Python 2.5 or older */
|
9 | 15 | #ifndef Py_TYPE
|
10 | 16 | # define Py_TYPE(o) ((o)->ob_type)
|
@@ -714,7 +720,11 @@ static int _get_snap(GraphicsContext* self, enum e_snap_mode* mode)
|
714 | 720 | if (offset!=Py_None)
|
715 | 721 | {
|
716 | 722 | if (PyFloat_Check(offset)) phase = PyFloat_AsDouble(offset);
|
| 723 | +#if PY3K |
| 724 | + else if (PyLong_Check(offset)) phase = PyLong_AsLong(offset); |
| 725 | +#else |
717 | 726 | else if (PyInt_Check(offset)) phase = PyInt_AsLong(offset);
|
| 727 | +#endif |
718 | 728 | else
|
719 | 729 | {
|
720 | 730 | PyErr_SetString(PyExc_TypeError,
|
@@ -747,8 +757,13 @@ static int _get_snap(GraphicsContext* self, enum e_snap_mode* mode)
|
747 | 757 | PyObject* value = PyTuple_GET_ITEM(dashes, i);
|
748 | 758 | if (PyFloat_Check(value))
|
749 | 759 | 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 |
750 | 764 | else if (PyInt_Check(value))
|
751 | 765 | lengths[i] = (CGFloat) PyInt_AS_LONG(value);
|
| 766 | +#endif |
752 | 767 | else break;
|
753 | 768 | }
|
754 | 769 | Py_DECREF(dashes);
|
@@ -5847,4 +5862,8 @@ void init_macosx(void)
|
5847 | 5862 | PyModule_AddObject(module, "Timer", (PyObject*) &TimerType);
|
5848 | 5863 |
|
5849 | 5864 | PyOS_InputHook = wait_for_stdin;
|
| 5865 | + |
| 5866 | +#if PY3K |
| 5867 | + return module; |
| 5868 | +#endif |
5850 | 5869 | }
|
0 commit comments