]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
ceph-disk: convert none str to str before printing it 13501/head
authorKefu Chai <kchai@redhat.com>
Tue, 3 Jan 2017 12:40:00 +0000 (20:40 +0800)
committerShinobu Kinjo <shinobu@redhat.com>
Fri, 17 Feb 2017 18:36:26 +0000 (03:36 +0900)
Error('somethings goes wrong', e) is thrown if exception `e` is caught
in ceph-disk, where e is not a string. so we can not just concat it in
Error's __str__(). so cast it to str before doing so.

introduced by d0e29c7

Fixes: http://tracker.ceph.com/issues/18371
Signed-off-by: Kefu Chai <kchai@redhat.com>
(cherry picked from commit 5e0dd1e7df43a3be589d17878714756a22052d8e)

src/ceph-disk/ceph_disk/main.py

index dc35c2fbab027bd604261cbee301c271fa542fd5..b9a2cc57a9cbe64c51a26541ed0ed8df0b0f2027 100755 (executable)
@@ -303,7 +303,12 @@ class Error(Exception):
 
     def __str__(self):
         doc = _bytes2str(self.__doc__.strip())
-        return ': '.join([doc] + [_bytes2str(a) for a in self.args])
+        try:
+            str_type = basestring
+        except NameError:
+            str_type = str
+        args = [a if isinstance(a, str_type) else str(a) for a in self.args]
+        return ': '.join([doc] + [_bytes2str(a) for a in args])
 
 
 class MountError(Error):