Re: [PATCH 1/3] trace-cmd: in python plugin, use PyUnicode_FromString on Python 3

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Thu, 25 Jul 2019 10:41:36 -0700
Patrick McLean <chutzpah@xxxxxxxxxx> wrote:

> From: Patrick McLean <patrick.mclean@xxxxxxxx>
> 
> All strings are unicode in Python 3, so PyString_* is no longer
> reccommended. This uses PyUnicode_* instead.
> 
> Signed-off-by: Patrick McLean <patrick.mclean@xxxxxxxx>
> ---
>  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;
>  




[Index of Archives]     [Linux USB Development]     [Linux USB Development]     [Linux Audio Users]     [Yosemite Hiking]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux