From: "Steven Rostedt (VMware)" <rostedt@xxxxxxxxxxx> Python 3 has deprecated PyInt_AS_LONG. Add code to use PyLong_AsLong() if Python 3 is detected. As Python 2 is going to be EOL soon, we need to support Python 3. Bugzilla: https://bugzilla.kernel.org/show_bug.cgi?id=204231 Reported-by: Troy Engel <troyengel@xxxxxxxxx> Signed-off-by: Steven Rostedt (VMware) <rostedt@xxxxxxxxxxx> --- python/ctracecmd.i | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/python/ctracecmd.i b/python/ctracecmd.i index 63e5dcb813f1..2601d39a76be 100644 --- a/python/ctracecmd.i +++ b/python/ctracecmd.i @@ -117,14 +117,21 @@ static PyObject *py_field_get_stack(struct tep_handle *pevent, return list; } +#if PY_MAJOR_VERSION >= 3 static PyObject *fromMemory(void *buf, size_t len) { -#if PY_MAJOR_VERSION >= 3 return PyMemoryView_FromMemory(buf, len, PyBUF_READ); +} +#define PY_INT_AS_LONG PyLong_AsLong #else +static PyObject *fromMemory(void *buf, size_t len) +{ return PyBuffer_FromMemory(buf, len); -#endif } +#define PY_INT_AS_LONG PyInt_AS_LONG +#endif + + static PyObject *py_field_get_data(struct tep_format_field *f, struct tep_record *r) { @@ -226,7 +233,7 @@ static int python_callback(struct trace_seq *s, Py_XDECREF(result); return 0; } - r = PyInt_AS_LONG(result); + r = PY_INT_AS_LONG(result); } else if (result == Py_None) r = 0; else -- 2.20.1
![]() |