[PATCH v2 3/3] pwclient: Fix Python 3 encoding of received strings
thomas.monjalon at 6wind.com
Thu Dec 15 21:26:01 AEDT 2016
2016-12-13 11:37, Thomas Monjalon:
> The conversion encode("utf-8") makes a byte stream which is
> poorly printed with Python 3.
> for patch_id in non_empty(h, patch_ids):
> s = rpc.patch_get_mbox(patch_id)
> if len(s) > 0:
> - print(unicode(s).encode("utf-8"))
> + print(unicode(s))
I really do not understand these conversions.
I've just found a bug with this patch (sorry it is already applied).
When running the view command with python2 from a shell script there
is an error because of a non-ascii character:
File "pwclient", line 768, in main
UnicodeEncodeError: 'ascii' codec can't encode character u'\u0142'
in position 468: ordinal not in range(128)
This error does not happen with python3.
Shell script to reproduce the error with a DPDK patch:
#! /bin/sh -e
python2 pwclient view 17892
What is the magical invocation to make it work with Python 2 and 3?
More information about the Patchwork