[ovs-dev] [PATCH 2/2] python: Force file system encoding on cmdline args

Lance Richardson lrichard at redhat.com
Wed Aug 16 14:03:38 UTC 2017


> From: "Alin Balutoiu" <abalutoiu at cloudbasesolutions.com>
> To: dev at openvswitch.org
> Sent: Monday, August 14, 2017 9:47:15 PM
> Subject: [ovs-dev] [PATCH 2/2] python: Force file system encoding on cmdline	args
> 
> On Windows, the default file system encoding is 'mbcs'
> resulting in a bad conversion.
> 
> To make it cross-platform tolerant use
> 'sys.getfilesystemencoding()' instead of 'utf-8'.
> 
> 
> Co-authored-by: Alin Serdean <aserdean at cloudbasesolutions.com>
> Signed-off-by: Alin Balutoiu <abalutoiu at cloudbasesolutions.com>
> Signed-off-by: Alin Serdean <aserdean at cloudbasesolutions.com>
> ---
>  tests/test-ovsdb.py | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/tests/test-ovsdb.py b/tests/test-ovsdb.py
> index df9d6d5..fc42a2d 100644
> --- a/tests/test-ovsdb.py
> +++ b/tests/test-ovsdb.py
> @@ -337,7 +337,8 @@ def idl_set(idl, commands, step):
>                  if six.PY2:
>                      s.s = args[2].decode('utf-8')
>                  else:
> -                    s.s = args[2].encode('utf-8', 'surrogateescape') \
> +                    s.s = args[2].encode(sys.getfilesystemencoding(),
> +                                         'surrogateescape') \
>                                   .decode('utf-8', 'replace')
>              elif args[1] == "u":
>                  s.u = uuid.UUID(args[2])
> --
> 2.10.0.windows.1
> _______________________________________________

LGTM, tests pass under Linux.

Acked-by: Lance Richardson <lrichard at redhat.com>


More information about the dev mailing list