Skip to content

Commit cfe8b7b

Browse files
Thomas Monjalonstephenfin
authored andcommitted
pwclient: Fix Python 3 encoding of received strings
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 52654da) Conflicts: patchwork/bin/pwclient
1 parent 0d0d5c5 commit cfe8b7b

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

patchwork/bin/pwclient

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -269,7 +269,7 @@ def action_check_info(rpc, check_id):
269269
print(s)
270270
print('-' * len(s))
271271
for key, value in sorted(check.items()):
272-
print("- %- 14s: %s" % (key, unicode(value).encode("utf-8")))
272+
print("- %- 14s: %s" % (key, unicode(value)))
273273

274274

275275
def action_check_create(rpc, patch_id, context, state, url, description):
@@ -293,7 +293,7 @@ def action_info(rpc, patch_id):
293293
print(s)
294294
print('-' * len(s))
295295
for key, value in sorted(patch.items()):
296-
print("- %- 14s: %s" % (key, unicode(value).encode("utf-8")))
296+
print("- %- 14s: %s" % (key, unicode(value)))
297297

298298

299299
def action_get(rpc, patch_id):
@@ -317,7 +317,7 @@ def action_get(rpc, patch_id):
317317
sys.exit(1)
318318

319319
try:
320-
f.write(unicode(s).encode("utf-8"))
320+
f.write(unicode(s))
321321
f.close()
322322
print('Saved patch to %s' % fname)
323323
except:
@@ -757,15 +757,15 @@ def main():
757757
for patch_id in non_empty(h, patch_ids):
758758
s = rpc.patch_get_mbox(patch_id)
759759
if len(s) > 0:
760-
i.append(unicode(s).encode("utf-8"))
760+
i.append(unicode(s))
761761
if len(i) > 0:
762-
pager.communicate(input="\n".join(i))
762+
pager.communicate(input="\n".join(i).encode("utf-8"))
763763
pager.stdin.close()
764764
else:
765765
for patch_id in non_empty(h, patch_ids):
766766
s = rpc.patch_get_mbox(patch_id)
767767
if len(s) > 0:
768-
print(unicode(s).encode("utf-8"))
768+
print(unicode(s))
769769

770770
elif action == 'info':
771771
for patch_id in non_empty(h, patch_ids):

0 commit comments

Comments
 (0)