Skip to content

Commit

Permalink
python: Force file system encoding on cmdline args
Browse files Browse the repository at this point in the history
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@cloudbasesolutions.com>
Signed-off-by: Alin Balutoiu <abalutoiu@cloudbasesolutions.com>
Signed-off-by: Alin Serdean <aserdean@cloudbasesolutions.com>
Acked-by: Lance Richardson <lrichard@redhat.com>
Signed-off-by: Russell Bryant <russell@ovn.org>
  • Loading branch information
2 people authored and russellb committed Aug 18, 2017
1 parent e2c7064 commit 294db17
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion tests/test-ovsdb.py
Expand Up @@ -336,7 +336,8 @@ def notify(event, row, updates=None):
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])
Expand Down

0 comments on commit 294db17

Please sign in to comment.