]> git.ipfire.org Git - thirdparty/patchwork.git/commitdiff
pwclient: Fix Python 3 encoding of received strings
authorThomas Monjalon <thomas.monjalon@6wind.com>
Tue, 13 Dec 2016 10:37:47 +0000 (11:37 +0100)
committerStephen Finucane <stephen@that.guru>
Tue, 13 Dec 2016 18:07:11 +0000 (18:07 +0000)
The conversion encode("utf-8") makes a byte stream which is
poorly printed with Python 3.
However this encoding is required for Popen.communicate() but must be
done after str.join() which applies to a real string.

Signed-off-by: Thomas Monjalon <thomas.monjalon@6wind.com>
Reviewed-by: Stephen Finucane <stephen@that.guru>
(cherry picked from commit 52654da17967a930a3cac962fc654e0d5de2855b)

Conflicts:
patchwork/bin/pwclient

patchwork/bin/pwclient

index e1ef944ca60b347a6c56c8c2c0c8faa18c56857c..3d5be691994e30ca95b8a0e21deff2d5efca995d 100755 (executable)
@@ -269,7 +269,7 @@ def action_check_info(rpc, check_id):
     print(s)
     print('-' * len(s))
     for key, value in sorted(check.items()):
-        print("- %- 14s: %s" % (key, unicode(value).encode("utf-8")))
+        print("- %- 14s: %s" % (key, unicode(value)))
 
 
 def action_check_create(rpc, patch_id, context, state, url, description):
@@ -293,7 +293,7 @@ def action_info(rpc, patch_id):
     print(s)
     print('-' * len(s))
     for key, value in sorted(patch.items()):
-        print("- %- 14s: %s" % (key, unicode(value).encode("utf-8")))
+        print("- %- 14s: %s" % (key, unicode(value)))
 
 
 def action_get(rpc, patch_id):
@@ -317,7 +317,7 @@ def action_get(rpc, patch_id):
         sys.exit(1)
 
     try:
-        f.write(unicode(s).encode("utf-8"))
+        f.write(unicode(s))
         f.close()
         print('Saved patch to %s' % fname)
     except:
@@ -757,15 +757,15 @@ def main():
             for patch_id in non_empty(h, patch_ids):
                 s = rpc.patch_get_mbox(patch_id)
                 if len(s) > 0:
-                    i.append(unicode(s).encode("utf-8"))
+                    i.append(unicode(s))
             if len(i) > 0:
-                pager.communicate(input="\n".join(i))
+                pager.communicate(input="\n".join(i).encode("utf-8"))
             pager.stdin.close()
         else:
             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))
 
     elif action == 'info':
         for patch_id in non_empty(h, patch_ids):