Re: [PATCH 1/3] trace-cmd: Replace PySting_FromString() with PyUnicode_FromString()

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

 



On Fri, 2019-07-19 at 18:46 -0400, Steven Rostedt wrote:

> --- a/python/ctracecmd.i
> +++ b/python/ctracecmd.i
> @@ -108,7 +108,7 @@ static PyObject *py_field_get_stack(struct tep_handle *pevent,
>  		    ((int)addr == -1))
>  			break;
>  		func = tep_find_function(event->tep, addr);
> -		if (PyList_Append(list, PyString_FromString(func))) {
> +		if (PyList_Append(list, PyUnicode_FromString(func))) {
>  			Py_DECREF(list);

This assumes that the source code is not using extended identifiers (per
C99, gcc -fextended-identifiers). I think that's probably a reasonable
assumption :-)

In theory, a bit safer would be to use PyBytes_FromString() and let the
python plugin worry about the encoding.

That really applies to all of the instances here, I think, since the
strings eventually come from (macros in the) code.

Reviewed-by: Johannes Berg <johannes@xxxxxxxxxxxxxxxx>

johannes




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

  Powered by Linux