[dpdk-dev] [dpdk-stable] [PATCH] usertools: add telemetry python3 compatibility

Robin Jarry robin.jarry at 6wind.com
Mon Jan 20 09:47:07 CET 2020


16/01/2020 18:24, Ciara Power:
> The client script for use with the telemetry library did not support
> python3, as the data being sent over the socket was in string format.
> Python3 requires the data be explicitly converted to bytes before being
> sent.  Similarily, the received bytes need to be decoded into string
> format.
> 
> Cc: stable at dpdk.org
> 
> Signed-off-by: Ciara Power <ciara.power at intel.com>

Overall, it looks good to me. One minor grudge:

Mind that when using this script with python2, the literal strings
actually are bytes. This means that .encode() does not make any sense on
them. As it turns out, the str objects of python2 do have an .encode()
method that does not do anything (it returns the byte string object
unchanged), so calling it does not cause any problem.

Long story short, for consistency you should consider adding a future
import at the top:

    from __future__ import unicode_literals

So that all literal strings are unicode with python2 as with python3.
See related commit 4da069194ef4 ("usertools: fix pmdinfo with python
3 and pyelftools>=0.24").

Maybe the patch title should contain the word "fix" and some Fixes:
lines as there already were some attemps to make this script python3
compatible.

Reviewed-by: Robin Jarry <robin.jarry at 6wind.com>

-- 
Robin


More information about the dev mailing list