From 319c8507ea3fc37f6d8a57f63181fe27c7e445fe Mon Sep 17 00:00:00 2001 From: Kefu Chai Date: Tue, 27 Nov 2018 19:00:15 +0800 Subject: [PATCH] ceph.in: write bytes to stdout in raw_write() in python3, sys.stdout.buffer is an io.BufferedWriter, while in python2 `sys.__stdout__` is a plain file. the former only accepts "bytes". so if we send it a "str", it complains: TypeError: a bytes-like object is required, not 'str' it happens when quitting from the interactive mode of ceph CLI. in that case, `new_style_command()` returns a tuple of `0, '\n', ''`, where the second element is a str. in this change, we always send `bytes` to raw_stdout. Signed-off-by: Kefu Chai --- src/ceph.in | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/ceph.in b/src/ceph.in index d73f2cf679aa..29ac6a194307 100755 --- a/src/ceph.in +++ b/src/ceph.in @@ -169,7 +169,7 @@ else: def raw_write(buf): sys.stdout.flush() - raw_stdout.write(buf) + raw_stdout.write(rados.cstr(buf, '')) def osdids(): -- 2.47.3