]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
ceph.in: write bytes to stdout in raw_write() 25280/head
authorKefu Chai <kchai@redhat.com>
Tue, 27 Nov 2018 11:00:15 +0000 (19:00 +0800)
committerKefu Chai <kchai@redhat.com>
Tue, 27 Nov 2018 11:26:08 +0000 (19:26 +0800)
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 <kchai@redhat.com>
src/ceph.in

index d73f2cf679aa7bea1e6cf1fceca3acc2cdb57cf2..29ac6a194307d3901f70861e338a1dcd20d24aaa 100755 (executable)
@@ -169,7 +169,7 @@ else:
 
 def raw_write(buf):
     sys.stdout.flush()
-    raw_stdout.write(buf)
+    raw_stdout.write(rados.cstr(buf, ''))
 
 
 def osdids():