[PATCH] pwclient fix for handling messages with UTF-8

Mauro Carvalho Chehab mchehab at infradead.org
Tue Feb 17 21:34:51 EST 2009


pwclient works fine viewing utf-8 messages, if you don't try to redirect stdout.

However, if you do things like pwclient view 5063 >/tmp/patch, it fails
due to the weird character handling logic in python:

Traceback (most recent call last):
  File "/usr/local/bin/pwclient", line 446, in ?
    main()
  File "/usr/local/bin/pwclient", line 411, in main
    print s
UnicodeEncodeError: 'ascii' codec can't encode character u'\xe1' in position 249: ordinal not in range(128)

Signed-off-by: Mauro Carvalho Chehab <mchehab at redhat.com>

diff --git a/apps/patchwork/bin/pwclient b/apps/patchwork/bin/pwclient
index 55bce68..ac67a2b 100755
--- a/apps/patchwork/bin/pwclient
+++ b/apps/patchwork/bin/pwclient
@@ -408,7 +409,7 @@ def main():
 
         s = rpc.patch_get_mbox(patch_id)
         if len(s) > 0:
-            print s
+            print unicode(s).encode("utf-8")
 
     elif action == 'get' or action == 'save':
         try:



More information about the Patchwork mailing list