From f19d139f6488afff8a831a853d0e6d5edfb4e8ed Mon Sep 17 00:00:00 2001 From: Lars Immisch Date: Fri, 24 Feb 2017 13:25:36 +0100 Subject: [PATCH] Fix C-API usage for Python 3. Closes #29 --- alsaaudio.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/alsaaudio.c b/alsaaudio.c index 8edce00..76c0ffe 100644 --- a/alsaaudio.c +++ b/alsaaudio.c @@ -20,6 +20,11 @@ #define PyLong_Check PyInt_Check #define PyLong_AS_LONG PyInt_AS_LONG #endif + +#if PY_MAJOR_VERSION < 3 + #define PyLong_FromLong PyInt_FromLong +#endif + #include #include #include @@ -187,7 +192,7 @@ alsacard_list_indexes(PyObject *self, PyObject *args) for (rc = snd_card_next(&card); !rc && (card >= 0); rc = snd_card_next(&card)) { - PyObject *item = PyInt_FromLong(card); + PyObject *item = PyLong_FromLong(card); PyList_Append(result, item); Py_DECREF(item);