]> git.ozlabs.org Git - patchwork/commitdiff
pwclient: fix handling UTF-8 in patch info
authorAndreas Bießmann <andreas@biessmann.de>
Mon, 9 Dec 2013 12:30:53 +0000 (13:30 +0100)
committerJeremy Kerr <jk@ozlabs.org>
Tue, 28 Jan 2014 12:54:40 +0000 (20:54 +0800)
This patch fixes following error when redirecting 'pwclient info' output:

---8<---
andreas@dockstar % pwclient info 295268 > /tmp/test.out
Traceback (most recent call last):
  File "/home/andreas/bin/pwclient", line 508, in <module>
    main()
  File "/home/andreas/bin/pwclient", line 471, in main
    action_info(rpc, patch_id)
  File "/home/andreas/bin/pwclient", line 242, in action_info
    print("- %- 14s: %s" % (key, value))
UnicodeEncodeError: 'ascii' codec can't encode character u'\xdf' in position 29: ordinal not in range(128)
--->8---

Signed-off-by: Andreas Bießmann <andreas@biessmann.de>
Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
apps/patchwork/bin/pwclient

index 5fce359e591ab213f34719ca414b9875960e0595..0c0ccaff7fd25372f50bcda7ebfb4ddd3e4f54f4 100755 (executable)
@@ -231,7 +231,7 @@ def action_info(rpc, patch_id):
     print(s)
     print('-' * len(s))
     for key, value in sorted(patch.iteritems()):
-        print("- %- 14s: %s" % (key, value))
+        print("- %- 14s: %s" % (key, unicode(value).encode("utf-8")))
 
 def action_get(rpc, patch_id):
     patch = rpc.patch_get(patch_id)