From: Kefu Chai Date: Tue, 27 Nov 2018 11:00:15 +0000 (+0800) Subject: ceph.in: write bytes to stdout in raw_write() X-Git-Tag: v14.1.0~782^2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=refs%2Fpull%2F25280%2Fhead;p=ceph.git 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 --- 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():