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-24 20:40:03 -0400 |
commit | f01557461b9fd7cae9a83f89f0be691e0a2f9011 (patch) | |
tree | 215e8aea4e817a3407580804e3e52474a57818cc | |
parent | f2721db1f13170a556591fc4977a03c9846efe38 (diff) | |
download | trace-cmd-f01557461b9fd7cae9a83f89f0be691e0a2f9011.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 |