Message ID | 20190725174138.3724131-2-chutzpah@gentoo.org (mailing list archive) |
---|---|
State | Superseded |
Headers | show |
Series | trace-cmd: More Python 3 cleanups | expand |
On Thu, 25 Jul 2019 10:41:36 -0700 Patrick McLean <chutzpah@gentoo.org> wrote: > From: Patrick McLean <patrick.mclean@sony.com> > > All strings are unicode in Python 3, so PyString_* is no longer > reccommended. This uses PyUnicode_* instead. > > Signed-off-by: Patrick McLean <patrick.mclean@sony.com> > --- > plugins/plugin_python.c | 4 ++++ > 1 file changed, 4 insertions(+) > > diff --git a/plugins/plugin_python.c b/plugins/plugin_python.c > index e725ad8..dc7932e 100644 > --- a/plugins/plugin_python.c > +++ b/plugins/plugin_python.c > @@ -81,7 +81,11 @@ int TEP_PLUGIN_LOADER(struct tep_handle *pevent) > } else > Py_DECREF(res); > > +#if PY_MAJOR_VERSION >= 3 > + str = PyUnicode_FromString("pevent"); > +#else > str = PyString_FromString("pevent"); > +#endif I believe using just PyUnicode_FromString() will work for both v2 and v3. That's what I did in my other patches. -- Steve > if (!str) > return -ENOMEM; >
On Thu, 25 Jul 2019 14:04:09 -0400 Steven Rostedt <rostedt@goodmis.org> wrote: > > --- a/plugins/plugin_python.c > > +++ b/plugins/plugin_python.c > > @@ -81,7 +81,11 @@ int TEP_PLUGIN_LOADER(struct tep_handle *pevent) > > } else > > Py_DECREF(res); > > > > +#if PY_MAJOR_VERSION >= 3 > > + str = PyUnicode_FromString("pevent"); > > +#else > > str = PyString_FromString("pevent"); > > +#endif > > I believe using just PyUnicode_FromString() will work for both v2 and > v3. That's what I did in my other patches. FYI, I applied this instead: -- Steve From ccca93c8f24b66beea1d68b7207e8de1ede8d108 Mon Sep 17 00:00:00 2001 From: "Steven Rostedt (VMware)" <rostedt@goodmis.org> Date: Thu, 25 Jul 2019 15:20:10 -0400 Subject: [PATCH] trace-cmd: Replace PyString_FromString() with PyUnicode_FromString() As PyString_FromString() is no longer available with Python 3, use PyUnicode_FromString() which is available in both Python 2 and 3. Link: http://lkml.kernel.org/r/20190725174138.3724131-2-chutzpah@gentoo.org Reported-by: Patrick McLean <patrick.mclean@sony.com> Signed-off-by: Steven Rostedt (VMware) <rostedt@goodmis.org> --- plugins/plugin_python.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/plugin_python.c b/plugins/plugin_python.c index e725ad84..196b8256 100644 --- a/plugins/plugin_python.c +++ b/plugins/plugin_python.c @@ -81,7 +81,7 @@ int TEP_PLUGIN_LOADER(struct tep_handle *pevent) } else Py_DECREF(res); - str = PyString_FromString("pevent"); + str = PyUnicode_FromString("pevent"); if (!str) return -ENOMEM;
diff --git a/plugins/plugin_python.c b/plugins/plugin_python.c index e725ad8..dc7932e 100644 --- a/plugins/plugin_python.c +++ b/plugins/plugin_python.c @@ -81,7 +81,11 @@ int TEP_PLUGIN_LOADER(struct tep_handle *pevent) } else Py_DECREF(res); +#if PY_MAJOR_VERSION >= 3 + str = PyUnicode_FromString("pevent"); +#else str = PyString_FromString("pevent"); +#endif if (!str) return -ENOMEM;