diff options
author | Steven Rostedt (VMware) <rostedt@goodmis.org> | 2019-07-19 18:46:16 -0400 |
---|---|---|
committer | Steven Rostedt (VMware) <rostedt@goodmis.org> | 2019-07-23 09:10:23 -0400 |
commit | 2091de2221e9640b2816c7896ece7c6cb1a108b7 (patch) | |
tree | 10353ab99bcbd726001ef48135d35397638ce4d3 | |
parent | dbddc64834a7ab93a9ea47e0d2a8fb97185138ec (diff) | |
download | trace-cmd-2091de2221e9640b2816c7896ece7c6cb1a108b7.tar.gz |
trace-cmd: Use PyLong_AsLong() for Python 3
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
Link: http://lore.kernel.org/linux-trace-devel/20190719225030.507227790@goodmis.org
Reported-by: Troy Engel <troyengel@gmail.com>
Signed-off-by: Steven Rostedt (VMware) <rostedt@goodmis.org>
-rw-r--r-- | python/ctracecmd.i | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/python/ctracecmd.i b/python/ctracecmd.i index 63e5dcb8..2601d39a 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 |