From: Varsha Rao Date: Mon, 17 Jun 2019 08:19:06 +0000 (+0530) Subject: pybind: Fixes print of path as byte object in error message X-Git-Tag: v14.2.5~213^2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=31befd4a0e686fd440935dcdc425d5cf253a2f98;p=ceph.git pybind: Fixes print of path as byte object in error message Fixes: https://tracker.ceph.com/issues/40411 Signed-off-by: Varsha Rao (cherry picked from commit ca341581f5ae1df804ccf5674574f130ef62c4a6) --- diff --git a/src/pybind/cephfs/cephfs.pyx b/src/pybind/cephfs/cephfs.pyx index 4b6ff29c766..146c4bfe7d5 100644 --- a/src/pybind/cephfs/cephfs.pyx +++ b/src/pybind/cephfs/cephfs.pyx @@ -804,7 +804,7 @@ cdef class LibCephFS(object): with nogil: ret = ceph_mkdir(self.cluster, _path, _mode) if ret < 0: - raise make_ex(ret, "error in mkdir '%s'" % path) + raise make_ex(ret, "error in mkdir {}".format(path.decode('utf-8'))) def chmod(self, path, mode) : """ @@ -823,7 +823,7 @@ cdef class LibCephFS(object): with nogil: ret = ceph_chmod(self.cluster, _path, _mode) if ret < 0: - raise make_ex(ret, "error in chmod '%s'" % path) + raise make_ex(ret, "error in chmod {}".format(path.decode('utf-8'))) def mkdirs(self, path, mode): """ @@ -844,7 +844,7 @@ cdef class LibCephFS(object): with nogil: ret = ceph_mkdirs(self.cluster, _path, _mode) if ret < 0: - raise make_ex(ret, "error in mkdirs '%s'" % path) + raise make_ex(ret, "error in mkdirs {}".format(path.decode('utf-8'))) def rmdir(self, path): """ @@ -857,7 +857,7 @@ cdef class LibCephFS(object): cdef char* _path = path ret = ceph_rmdir(self.cluster, _path) if ret < 0: - raise make_ex(ret, "error in rmdir '%s'" % path) + raise make_ex(ret, "error in rmdir {}".format(path.decode('utf-8'))) def open(self, path, flags, mode=0): """ @@ -912,7 +912,7 @@ cdef class LibCephFS(object): with nogil: ret = ceph_open(self.cluster, _path, _flags, _mode) if ret < 0: - raise make_ex(ret, "error in open '%s'" % path) + raise make_ex(ret, "error in open {}".format(path.decode('utf-8'))) return ret def close(self, fd): @@ -1110,7 +1110,7 @@ cdef class LibCephFS(object): # FIXME: replace magic number with CEPH_STATX_BASIC_STATS ret = ceph_statx(self.cluster, _path, &stx, 0x7ffu, 0) if ret < 0: - raise make_ex(ret, "error in stat: %s" % path) + raise make_ex(ret, "error in stat: {}".format(path.decode('utf-8'))) return StatResult(st_dev=stx.stx_dev, st_ino=stx.stx_ino, st_mode=stx.stx_mode, st_nlink=stx.stx_nlink, st_uid=stx.stx_uid, st_gid=stx.stx_gid, @@ -1228,7 +1228,7 @@ cdef class LibCephFS(object): with nogil: ret = ceph_unlink(self.cluster, _path) if ret < 0: - raise make_ex(ret, "error in unlink: %s" % path) + raise make_ex(ret, "error in unlink: {}".format(path.decode('utf-8'))) def rename(self, src, dst): """ @@ -1250,7 +1250,8 @@ cdef class LibCephFS(object): with nogil: ret = ceph_rename(self.cluster, _src, _dst) if ret < 0: - raise make_ex(ret, "error in rename '%s' to '%s'" % (src, dst)) + raise make_ex(ret, "error in rename {} to {}".format(src.decode( + 'utf-8'), dst.decode('utf-8'))) def mds_command(self, mds_spec, args, input_data): """